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

Add software device python #4269

Conversation

callendorph
Copy link
Contributor

Hi,

This PR is targeting issue #4197. This PR is not a merge candidate - I'm trying to get feedback about direction only.

I've implement the functionality that allows me to emulate a D435i device on a rs2.context object. I can create a pipeline object and pass in a configuration that targets the emulated device by serial number. I can subsequently interrogate for camera_info, options, and grab frames. All of these settings are configured through the API. Here is an example python session where I create a trivial emulated device.

Keep in mind, that my goal here was to get something functional - not to have the end all, be all, perfect solution and API. I've also not added unit tests yet because I want to make sure that the direction I'm heading is reasonable before investing time and energy into that.

I've primarily attempted to add this functionality by adding to the API only - not modifying it. There are very clearly ways that we could make the API for the software device more concise if we changed the signature of certain methods. For example, rs2_software_sensor_add_writable_option and rs2_software_sensor_add_read_only_option are redundantly and could probably be combined into a single method with a readonly argument. Are you accepting of this kind of consolidation of the software device API or would you prefer to have maximum backward compatibility?

The current implementation adds a new emulated device backend because I didn't want to break functionality related to the playback devices. I would appreciate any feedback on this approach and how it integrates with the rest of the project. Specifically, in the context object I have added a vector of emulated devices, and this has caused the context::create_devices and context::on_device_change method signatures to expand and become rather ugly. I could integrate this into the platform::backend_device_group object but I wasn't sure because the playback devices are stored separately from this group object. Thoughts?

I did not see any unit tests for the python wrapper. Do you have a preferred platform for python unit tests if I were to try and add some ?

Carl Allendorph added 6 commits June 23, 2019 09:55
The API methods for rs2_software_sensor_add_*_stream can return an
error in various cases. In the old implementation, the returned error code
was not checked before sending the result to the `stream_profile` constructor.
This was causing the originating error to get swallowed and made debugging
the actual problem harder. This fixes this method so that the
first error is reported and not subsequent errors.
This adds a new private method for software_sensor for searching
for profiles by UID. This also makes this code more readable.
The cached value of the `_default` flag was causing problems with
the ability to set the default profile flag on the software device's
sensor profiles.
Issue IntelRealSense#4197

This adds the ability for the user with access to the `software_device` and
`software_sensor` classes to configure and set the `camera_info`, `option`,
and stream profile parameters. This allows for serial number, name, etc
to be written and configured. This also expands the `software_device` to
accept an explicit context argument.
Issue IntelRealSense#4197

This commit adds a new group of devices in the backend for emulated
devices. I tried to find a way to make the `playback` devices operate
like emulated devices, but I couldn't find a way that wouldn't break
existing funcionality. I ended up adding a separate emulated devices
group that gets treated similar to hardware devices when used with the
`pipeline` and other context configurations.
Issue IntelRealSense#4197

This commit adds new interfaces to the python wrapper to support
emulated realsense devices for testing. The emulated device can be
define completely in python. Allows for image publishing. The
motion (accel/gyro) is untested. I've only replicated a D435i
due to hardware availability limits. Emulated Device is operable with
the `pipeline` and config construction.
@dorodnic
Copy link
Contributor

Hi @callendorph
Thank you for contributing. I'd like to review the C++ part and @lramati can confirm python is good (python looks good to me)

@dorodnic dorodnic mentioned this pull request Dec 5, 2019
@dorodnic
Copy link
Contributor

Hi @callendorph
I'm closing this PR, @lramati has merged your contribution into #5333 and continues to work on better software device support in C++ and python. Thanks!

@dorodnic dorodnic closed this Dec 30, 2019
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.

2 participants