Skip to content

Added ISignalProducers and IMultipleImages interfaces - #96

Open
S-Dafarra wants to merge 11 commits into
mainfrom
camera_interface
Open

S-Dafarra wants to merge 11 commits into
mainfrom
camera_interface

Conversation

@S-Dafarra

Copy link
Copy Markdown
Contributor

This is the first PR to address #85. In particular, it adds two interfaces:

  • ISignalProducers: this allows getting the information of who is producing a given signal. Can be useful for syncronization across signals (e.g. cameras and IMUs)
  • IMultipleImages: this allows getting multiple synchronized images, their intristics and extrinsics

This PR only adds the interfaces. NWS/NWC and interop are coming later

@traversaro

Copy link
Copy Markdown
Contributor

Can you ask the agent to take inspiration from #75 for moving the opencv-using interfaces in a different cmake subproject, instead of having dinrail-core that can be configured in two ways? Otherwise it would be difficult to package that without adding the opencv dependency to dinrail-core ? dinrail-camera or any other name is perfectly fine for me.

@S-Dafarra

Copy link
Copy Markdown
Contributor Author

Can you ask the agent to take inspiration from #75 for moving the opencv-using interfaces in a different cmake subproject, instead of having dinrail-core that can be configured in two ways? Otherwise it would be difficult to package that without adding the opencv dependency to dinrail-core ? dinrail-camera or any other name is perfectly fine for me.

Done in 785ed6b

*
* A signal is any stream of data of a device, for example an encoder, an IMU or a camera,
* identified by its name (e.g. the sensor name returned by the `get<Sensor>Name` methods of
* the interfaces in `MultipleAnalogSensorsInterfaces.h`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A common practice is to share names across several sensors (so for example in IMU, for accelerometer, gyro and others). I think if two sensors share the name it may be a reasonable assumption that they share the producer, but it is a assumption I would explicitly document.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understood what you would like to be documented. Maybe it is only a bad example. If the name is exactly the same, the two methods down below will have to produce the same result. If instead the sensor names are different, but they contain a shared substring, I think there are still cases where the assumption would fail. For example, a chest IMU could be read from one board, while the chest cameras might be read from another board

Comment thread pixi.toml Resolved
Comment thread src/core/dinrail/ISignalProducers.h Resolved
Comment thread src/camera/dinrail/IMultipleImages.h Resolved
Comment thread src/camera/dinrail/IMultipleImages.h Resolved
* this reason they share one timestamp. Use toSeconds() to convert it to a timestamp in
* seconds, for example to compare it with the one of other sensors.
*/
Stamp stamp;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move the timestamp in ImageSample? There might be case where the images are not necessarily synchronized.

We could also keep stamp in MultipleImagesData as well to keep record of when the bundle was produced.

An helper method areSyncrhonized(std::string name1, std::string name2) (or a variadic version of this) could be provided as well if users wants to know about syncrhonization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was that all the images retrieved are synchronized by default, so having a single stamp would have avoided confusions

Comment thread src/camera/dinrail/IMultipleImages.h Outdated
Comment on lines +284 to +286
virtual Status
getImagesExtrinsics(const std::string& referenceFrameName,
std::unordered_map<std::string, cv::Matx44d>& transforms) = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about having

getImageFrameTransform(const std::string& referenceFrameName, const std::string& frameName, cv::Matx44d& transform)

instead?

I think this would:

  1. Reflect better consumer's flow
  2. Allow for easier proxying. Rather than returning the full list of transforms, the implementor could act in some cases as a proxy to a transform server for example, or a device attached to another IMultipleImage (e.g. a Rectifier) could provide some relative transforms between some frames of the attached and some of its own

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why I preferred in this way is to keep consistency with the getImages call, where all images are retrieved at once. Since the interface is supposed to provide synchronized images, also the extrinsics would need to be synchronized. I then realized that there was no way to check if the extrinsics and images are synchronized among each other, so I added the possibility to get also the stamp in 1b0ecdd

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be worth having a fake multiple images device and a test application for prototyping or do you want to address also this implementations in a future PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this PR is only for the interfaces

@traversaro traversaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go for me, I have some doubts on how ISignalProducers would work in practice, but I think it would be better to see how it is used in following PRs.

@S-Dafarra

S-Dafarra commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Go for me, I have some doubts on how ISignalProducers would work in practice, but I think it would be better to see how it is used in following PRs.

My plan was simply to have the physical devices implement this specifying an ID for the sensor, documented somewhere. This could be used to adopt other types of synchronization, for example with another interface that collects clock diffs between producers to have extra synchronization.

@S-Dafarra

Copy link
Copy Markdown
Contributor Author

for example with another interface that collects clock diffs between producers to have extra synchronization.

ChatGPT found this C++ library that does this https://github.com/sccn/liblsl. See https://labstreaminglayer.readthedocs.io/projects/liblsl/internals/time_sync.html

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.

3 participants