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

Frame callbacks #160

Merged
merged 6 commits into from
Dec 15, 2016
Merged

Conversation

mkhansenbot
Copy link

@mkhansenbot mkhansenbot commented Dec 1, 2016

Please ensure the above guidelines for contributing are met.

Fixes Issue: #

Changes proposed in this pull request:

  • Changes all streams to using callbacks instead of using rs_wait_for_frames
  • Adds needed mutex to imu callback for zr300
  • Refactors code to remove duplicated code
  • Removes the topic_thread since rs_wait_for_frames is removed and everything done via callbacks

@mkhansenbot mkhansenbot force-pushed the frame_callbacks branch 2 times, most recently from 1a9223e to 879eb59 Compare December 14, 2016 18:45
void BaseNodelet::setStreams()
{
// Enable streams
for (int stream=0; stream < STREAM_COUNT; stream++)
Copy link

Choose a reason for hiding this comment

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

Change the type of stream to be type 'rs_stream' and remove the casts.

Copy link
Author

Choose a reason for hiding this comment

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

Since STREAM_COUNT is an int, I can't change stream to an rs_stream type. Instead, I'm using static_cast<rs_stream>(stream) to pass the stream var.

Copy link

Choose a reason for hiding this comment

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

Why not cast STREAM_COUNT once instead of stream twice?

Copy link

@mdhorn mdhorn Dec 15, 2016

Choose a reason for hiding this comment

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

Or can we change STREAM_COUNT to a rs_stream type?

Copy link
Author

Choose a reason for hiding this comment

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

No ++ operator is defined for the enum type rs_stream, so you get this compiler error:
error: no ‘operator++(int)’ declared for postfix ‘++’ [-fpermissive]
for (rs_stream stream; stream < (rs_stream) STREAM_COUNT; stream++)

Copy link
Author

Choose a reason for hiding this comment

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

We cant change STREAM_COUNT to an rs_stream type, since we are setting the value to 5 in constants.h. I would like us to actually remove the constant in a future patch and do this a different way, as I agree this is non-ideal. I would prefer a member variable num_streams_ that isn't hard-coded and varies depending on the camera type, set in the onInit() function for each type to the correct value for that camera. But that's another patch for another day.

image_depth16_ = reinterpret_cast<const uint16_t *>(rs_get_frame_data(rs_device_, stream_index, 0));
if (depth_scale_meters_ == MILLIMETER_METERS)
image_depth16_ = reinterpret_cast<const uint16_t *>(frame.get_data());
float depth_scale_meters = rs_get_device_depth_scale(rs_device_, &rs_error_);
Copy link

Choose a reason for hiding this comment

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

Should this function be called in here? getStreamData is called the most frequently in the code.
Can we initialize this something else? Or make it a local static and initialize it once.

At a minimum we need to add a check error for the rs_error_

Copy link
Author

Choose a reason for hiding this comment

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

The value rs_get_device_depth_scale returns is device.config.depth_scale a member variable in the rs_device_ object. Do you still think it's an issue?


publishTopics();
if (rs_is_stream_enabled(rs_device_, (rs_stream) stream_index, 0) == 1)
Copy link

Choose a reason for hiding this comment

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

Since we are called by the callback, we have to be enabled. We should remove this check.

virtual void publishTopic(rs_stream stream_index);
virtual void getStreamData(rs_stream stream_index);
virtual void publishTopic(rs_stream stream_index, rs::frame & frame);
virtual void getStreamData(rs_stream stream_index, rs::frame & frame);
Copy link

Choose a reason for hiding this comment

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

Rename to setImageData

@@ -724,81 +726,94 @@ namespace realsense_camera
/*
* Copy frame data from realsense to member cv images.
*/
void BaseNodelet::getStreamData(rs_stream stream_index)
void BaseNodelet::getStreamData(rs_stream stream_index, rs::frame & frame)
Copy link

Choose a reason for hiding this comment

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

Rename to setImageData

@mkhansenbot mkhansenbot force-pushed the frame_callbacks branch 2 times, most recently from 8aa11da to a68ed0c Compare December 15, 2016 22:34
@mkhansenbot
Copy link
Author

I squashed the commits down to 6, this is ready for final review and approval.

Copy link

@mdhorn mdhorn left a comment

Choose a reason for hiding this comment

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

Previous discussion items implemented.

LGTM 👍

Copy link

@reaganlo reaganlo left a comment

Choose a reason for hiding this comment

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

Approved

@mkhansenbot mkhansenbot merged commit 7340761 into IntelRealSense:indigo-devel Dec 15, 2016
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