orbbec / ros_astra_camera

ROS wrapper for Astra camera
Apache License 2.0
68 stars 28 forks source link
3dcamera robot ros sensor

astra_camera

The ros_astra_camera package is an OpenNI2 ROS wrapper created for Orbbec 3D cameras. This package allows the usage of Orbbec 3D cameras with ROS Kinetic, Melodic, and Noetic distributions

Install dependencies

ROS

other dependencies

Getting start

mkdir -p ~/ros_ws/src
 cd ~/ros_ws/src
 git clone https://github.com/orbbec/ros_astra_camera.git
cd ~/ros_ws
catkin_make
cd ~/ros_ws
source ./devel/setup.bash
roscd astra_camera
./scripts/create_udev_rules
sudo udevadm control --reload && sudo  udevadm trigger

Start the camera

source ./devel/setup.bash 
roslaunch astra_camera astra.launch
source ./devel/setup.bash
rviz

Select the topic you want to display

rostopic list
rosservice list
rosparam list
rostopic echo /camera/extrinsic/depth_to_color
rosservice call /camera/get_camera_params "{}"
rostopic echo /camera/depth/camera_info
rostopic echo /camera/color/camera_info
rosservice call /camera/get_device_info "{}" 
rosservice call /camera/get_version "{}"
rosservice call /camera/set_color_auto_exposure '{data: false}' 
rosservice call /camera/set_uvc_auto_exposure  '{data: false}'
rosservice call /camera/set_ir_auto_exposure  "{data: false}"

# Setting exposure values (Be careful with the data range, the following example may not be correct.)
rosservice call /camera/set_ir_exposure  "{data: 2000}"
roservice call /camera/set_color_exposure  "{data: 2000}"
rosservice call /camera/set_uvc_exposure  "{data: 2000}"
 # Get exposure
 rosservice call /camera/get_ir_exposure  "{}"
 rosservice call /camera/get_color_exposure "{}"
 rosservice call /camera/get_uvc_exposure "{}"
# Get Gain
rosservice call /camera/get_color_gain '{}' # OpenNI camera
rosservice call /camera/get_ir_gain '{}' # OpenNI camera
rosservice call /camera/get_uvc_gain "{}" # UVC camera
# Setting the gain (Be careful with the data range, the following example may not be correct.)
rosservice call /camera/set_color_gain  "{data: 200}"
rosservice call /camera/set_ir_gain "{data: 200}"
roservice call /camera/set_uvc_gain "{data: 200}"
rosservice call /camera/set_color_mirror  "{data: true}"
rosservice call /camera/set_depth_mirror  "{data: true}"
rosservice call /camera/set_ir_mirror  "{data: true}"
rosservice call /camera/set_uvc_mirror  "{data: true}"
rosservice call /camera/set_uvc_auto_white_balance  "{data: false}"
#(Be careful with the data range, the following example may not be correct.)
rosservice call /camera/set_uvc_white_balance  "{data: 200}"
rosservice call /camera/set_laser '{data: true}' # Turn on
rosservice call /camera/set_laser '{data: false}' # Turn off
 rosservice call /camera/set_fan  '{data: true}' # Turn on
 rosservice call /camera/set_fan  '{data: false}' # Turn off
rosservice call /camera/set_ldp '{data: true}'
rosservice call /camera/set_ldp '{data: false}'
rosservice call  /camera/toggle_ir "{data: true}"
rosservice call  /camera/toggle_color "{data: true}"
rosservice call  /camera/toggle_depth "{data: true}"
rosservice call  /camera/toggle_uvc_camera "{data : true}"
rosservice call /camera/save_images "{}"

For dabai and dabai dcw (RGB camera is UVC protocol), run:

rosservice call /camera/save_uvc_image "{}" 

NOTE: The images are saved under ~/.ros/image and are only available when the sensor is on.

rosservice call /camera/save_point_cloud_xyz "{}" # xyz
rosservice call /camera/save_point_cloud_xyz_rgb "{}" # xyzrgb

NOTE: Point cloud are only available if it is running and saved under ~/.ros/point_cloud.

Multiple cameras

  <launch>
    <!-- unique camera name-->
    <arg name="camera_name" default="camera"/>
    <!-- Hardware depth registration -->
    <arg name="3d_sensor" default="astra"/>
    <!-- stereo_s_u3, astrapro, astra -->
    <arg name="camera1_prefix" default="01"/>
    <arg name="camera2_prefix" default="02"/>
    <arg name="camera1_serila_number" default="AALXB1301YW"/>
    <arg name="camera2_serila_number" default="AD7J7230031"/>
    <arg name="device_num" default="2"/>
    <include file="$(find astra_camera)/launch/$(arg 3d_sensor).launch">
        <arg name="camera_name" value="$(arg camera_name)_$(arg camera1_prefix)"/>
        <arg name="serial_number" value="$(arg camera1_serila_number)"/>
        <arg name="device_num" value="$(arg device_num)"/>
    </include>

    <include file="$(find astra_camera)/launch/$(arg 3d_sensor).launch">
        <arg name="camera_name" value="$(arg camera_name)_$(arg camera2_prefix)"/>
        <arg name="serial_number" value="$(arg camera2_serila_number)"/>
        <arg name="device_num" value="$(arg device_num)"/>
    </include>
    <node pkg="tf2_ros" type="static_transform_publisher" name="camera_tf" args="0 0 0 0 0 0 camera01_link camera02_link"/>
</launch>
rosrun astra_camera cleanup_shm_node 

This command will clean up all semaphore files in the /dev/shm directory, ensuring that the camera will not get stuck during the next start.

roslaunch astra_camera multi_astra.launch

Use calibration camera parameter


<launch>
    <!--...-->
    <arg name="ir_info_uri" default="file:///you_ir_camera_calib_path/depth_camera.yaml"/>
    <arg name="color_info_uri" default="file:///you_depth_camera_calib_path/rgb_camera.yaml"/>
    <!--...-->
</launch>
image_width: 640
image_height: 480
# The camera name is fixed. The color camera is rgb_camera, the depth/IR camera name is ir_camera
camera_name: rgb_camera
camera_matrix:
  rows: 3
  cols: 3
  data: [517.301, 0, 326.785, 0, 519.291, 244.563, 0, 0, 1]
distortion_model: plumb_bob
distortion_coefficients:
  rows: 1
  cols: 5
  data: [-0.41527, 0.31874, -0.00197, 0.00071, 0]
rectification_matrix:
  rows: 3
  cols: 3
  data: [0.999973, 0.00612598, -0.00406652, -0.00610201, 0.999964, 0.00588094, 0.0041024, -0.00585596, 0.999974 ]
projection_matrix:
  rows: 3
  cols: 4
  data: [517.301, 0, 326.785, -25.3167, 0, 519.291, 244.563, 0.282065, 0, 0, 1, 0.0777703]

Launch parameters

Frequently Asked Questions

License

Copyright 2023 Orbbec Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an " AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Other names and brands may be claimed as the property of others