Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle dynamic extents #15

Merged
merged 10 commits into from
Aug 17, 2024
Merged

handle dynamic extents #15

merged 10 commits into from
Aug 17, 2024

Conversation

christianrauch
Copy link
Owner

@christianrauch christianrauch commented Oct 29, 2023

Dynamic Spans have a maximum extent for the Control<Span<Type>> but a variable number of elements for the ControlValue in the ControlInfo. For dynamic Spans with a single element, this previously caused the exception std::length_error since a vector with "maximum extent" (dynamic_extent) elements was constructed. Additionally, libcamera allows controls to have default and min/max values of different types than the control.

This PR thus changes the behaviour of how libcamera controls are mapped and converted to ROS parameters in the following way:

  • ignore the control extent of a Span for conversion of default ControlValue and use the actual number of elements to prevent memory allocation with the "maximum extent"
  • enforce from now on that an extent of 0 means that the original Control contains a scalar type, such as Control<Type>, and not a Span, such as Control<Span<Type>>
  • check compatible libcamera control to ROS parameter type conversions based on the Control type and not the ControlValue

Altogether, this will ensure that we do not attempt to convert controls that are typed with an unsupported type, such as arrays of complex types (e.g. Control<Span<const Rectangle>>), independently of the variable types in the ControlInfo which is set by the IPA or pipeline.

Fixes #13, Fixes #50.

@christianrauch christianrauch force-pushed the fix_dynamic_extent branch 3 times, most recently from ea3f6a5 to 56c9e13 Compare October 30, 2023 22:41
@christianrauch christianrauch changed the title handle dynamic extents in cv_to_pv handle dynamic extents Oct 30, 2023
@christianrauch christianrauch force-pushed the fix_dynamic_extent branch 2 times, most recently from 56c9e13 to 5e04f2d Compare October 31, 2023 23:06
@christianrauch christianrauch force-pushed the fix_dynamic_extent branch 5 times, most recently from 121fd17 to c4db1f2 Compare June 12, 2024 18:28
@christianrauch christianrauch force-pushed the fix_dynamic_extent branch 4 times, most recently from c8ed14b to 4873473 Compare June 22, 2024 11:33
@christianrauch christianrauch force-pushed the fix_dynamic_extent branch 3 times, most recently from 36b8504 to bf1fa07 Compare August 5, 2024 19:27
@christianrauch christianrauch force-pushed the fix_dynamic_extent branch 2 times, most recently from e040af9 to 31d860d Compare August 17, 2024 17:57
Dynamic Spans have a maximum extent ('dynamic_extent') but their associated
'ControlInfo' can contain a variable number of elements. For dynamic Spans
with a single element in the default 'ControlValue', this previously caused
the exception 'std::length_error' since a vector with "maximum extent"
elements was constructed.

Fix this by ignoring the extent and using the actual number of elements.
Previously 'get_extent' would return the original 'extent' of a Span and 0
for non-span controls. This is ambiguous as an extent of 0 means that the
original control type is either not a span or an empty span that can store
no elements.

Resolve this ambiguity by enforcing that libcamera controls cannot contain
empty spans via a compile time assertion and clarify that an extent of 0
is only returned for non-span types.
…value

libcamera 'Control<T>' and their related 'ControlInfo' do not necessarily
have the same control and value types. This previously caused issues when
an unsupported control type, such as a span of a complex type, is mapped
to a ROS parameter via the type of the default 'ControlValue'.

Fix this by using the the actual control type, regardless of the types of
the values in the 'ControlInfo'.
@christianrauch christianrauch merged commit 6cff7b0 into main Aug 17, 2024
2 checks passed
@christianrauch christianrauch deleted the fix_dynamic_extent branch August 17, 2024 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Std::length_error in running the camera_node 'AfWindows' parameter occurs error.
1 participant