Skip to content

Instantly share code, notes, and snippets.

@acmiyaguchi
Last active April 12, 2023 05:50
Show Gist options
  • Save acmiyaguchi/8df0e0cbcfe53bae92da490f8c64dc5e to your computer and use it in GitHub Desktop.
Save acmiyaguchi/8df0e0cbcfe53bae92da490f8c64dc5e to your computer and use it in GitHub Desktop.
Testing realsense-ros with a physical camera

testing realsense-ros

The pick and place simulation repo and the segmentation repo rely on camera functionality. We'd like to test rickstaa/realsense-ros-gazebo on a physical camera.

quickstart

Questions to answer:

  • What is the dimensions of the color and depth channels on the camera?
  • Does the ros module work on the physical camera?
  • What is the behavior of the aligned depth image?

Ensure the realsense camera is plugged in and functional.

  1. verify that the camera is working using the realsense viewer

Install and test the realsense2 ros module and test the gazebo module

  1. checkout https://github.com/rickstaa/realsense-ros-gazebo into your catkin workspace under src
  2. install dependencies via rosdep install --from-paths src --ignore-src -r -y
  3. run catkin build
  4. launch the gazebo example in the repo: roslaunch realsense2_description view_d435_model_rviz_gazebo.launch
  5. save information from the simulated camera
    • use rostopic list and note all of the camera topics
    • use rostopic echo $TOPIC_NAME | head -n100 and get camera intrinsics information for the color and depth sensors

Run and test the physical camera via the ros module

  1. read https://github.com/rickstaa/realsense-ros/tree/fa319702d34f1ca71149cddf5768bcb8e644f63b#usage-instructions
  2. run roslaunch realsense2_camera rs_camera.launch
    • see instructions above and capture information about launched topics
  3. configure the camera stream in rviz: http://wiki.ros.org/rviz
    • rosrun rviz rviz

Lastly, run the physical camera via ros module again, but set align_depth to true. Find out how to set parameters via roslaunch. Note down topics and camera intrinsics again for color and depth images.

@azheng987
Copy link

The command roslaunch realsense2_description view_d435_model_rviz_gazebo.launch opens rviz:

Screenshot from 2023-04-11 15-39-37
And gazebo:
Screenshot from 2023-04-11 15-41-25

Open realsense by entering:
realsense-viewer

Screenshot from 2023-04-11 15-43-41

@azheng987
Copy link

Running the physical camera with roslaunch realsense2_camera rs_camera.launch and then running rostopic echo /camera/depth/camera_info gives an ongoing stream of things that look like:

---
header: 
  seq: 1102
  stamp: 
    secs: 1681243046
    nsecs:  30952930
  frame_id: "camera_depth_optical_frame"
height: 480
width: 848
distortion_model: "plumb_bob"
D: [0.0, 0.0, 0.0, 0.0, 0.0]
K: [420.2537841796875, 0.0, 424.7379150390625, 0.0, 420.2537841796875, 244.26292419433594, 0.0, 0.0, 1.0]
R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
P: [420.2537841796875, 0.0, 424.7379150390625, 0.0, 0.0, 420.2537841796875, 244.26292419433594, 0.0, 0.0, 0.0, 1.0, 0.0]
binning_x: 0
binning_y: 0
roi: 
  x_offset: 0
  y_offset: 0
  height: 0
  width: 0
  do_rectify: False
---

The sequence number goes up each time
We think that the | head -n100 gives the BrokenPipeError somehow? We're not too sure what it does but it's probably printing that information at every frame?

@acmiyaguchi
Copy link
Author

We think that the | head -n100 gives the BrokenPipeError somehow? We're not too sure what it does but it's probably printing that information at every frame?

Just to clear this up in writing, rostopic echo will write to STDOUT continuously until it receives a signal from the user to stop. head is a unix command that will read the first n lines of STDIN and then exit. The broken pipe comes from head killing rostopic echo while it was running. And you are right that this is printing out information with every frame; there are other topics that are associated with accelerometers and other sensors that may need some information about the camera intrinsics here.


Linking a report with consolidated information here: https://gist.github.com/azheng987/2e714dc5097eaf1b50c0e175240fe1cb

Here is also a link that has a dockerfile that could be useful for using with the realsense: https://gist.github.com/acmiyaguchi/a0efca3b3265247d45bb4b8408e4b815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment