项目作者: felixchenfy

项目描述 :
A python script to publish color or depth images from a folder to ROS topic.
高级语言: Python
项目地址: git://github.com/felixchenfy/ros_images_publisher.git
创建时间: 2019-11-28T18:32:21Z
项目社区:https://github.com/felixchenfy/ros_images_publisher

开源协议:MIT License

下载


ROS Images Publisher

A self-contained python script publish_images.py for publishing color or depth images from a folder to ROS topic.

For a fast unit test, run: bash run_test_case.sh

Download

  1. cd ~/catkin_ws/src
  2. git clone https://github.com/felixchenfy/ros_images_publisher
  3. cd ros_images_publisher
  4. chmod a+x publish_images.py

See help by -h

  1. $ rosrun ros_images_publisher publish_images.py -h
  2. usage: publish_images.py [-h] -i IMAGES_FOLDER [-c CAMERA_INFO_FILE]
  3. [-t TOPIC_NAME] [-r PUBLISH_RATE] [-f {color,depth}]
  4. Publish color or depth images from a folder to ROS topic.
  5. optional arguments:
  6. -h, --help show this help message and exit
  7. -i IMAGES_FOLDER, --images_folder IMAGES_FOLDER
  8. A data folder which contains .jpg or .png images for
  9. publishing. (default: /home/feiyu/catkin_ws/src/ros_im
  10. ages_publisher/data/color/)
  11. -c CAMERA_INFO_FILE, --camera_info_file CAMERA_INFO_FILE
  12. File path of camera parameters. No distortion.
  13. (default: /home/feiyu/catkin_ws/src/ros_images_publish
  14. er/data/cam_params_realsense.json)
  15. -t TOPIC_NAME, --topic_name TOPIC_NAME
  16. ROS topic name to publish image. (default:
  17. test_data/image_raw)
  18. -r PUBLISH_RATE, --publish_rate PUBLISH_RATE
  19. How many images to publish per second. (default: 1.0)
  20. -f {color,depth}, --format {color,depth}
  21. Format of image: color (uint8, 3 channels), or depth
  22. (uint16, 1 channel). (default: color)

Exampe of usage

  1. publish_color_images(){
  2. roscd ros_images_publisher; ROOT=$PWD
  3. rosrun ros_images_publisher publish_images.py \
  4. --images_folder $ROOT/data/color/ \
  5. --topic_name test_data/color \
  6. --camera_info_file $ROOT/data/cam_params_realsense.json
  7. }
  8. publish_depth_images(){
  9. roscd ros_images_publisher; ROOT=$PWD
  10. rosrun ros_images_publisher publish_images.py \
  11. --images_folder $ROOT/data/depth/ \
  12. --topic_name test_data/depth \
  13. --camera_info_file "" \
  14. --format depth
  15. }
  16. set_camera_at_origin(){
  17. rosrun tf static_transform_publisher 0 0 0 0 0 0 1 map head_camera 10
  18. }
  19. run_rviz(){
  20. roscd ros_images_publisher; ROOT=$PWD
  21. rosrun rviz rviz -d $ROOT/rviz_for_color_and_depth_images.rviz
  22. }
  23. # https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script
  24. # Run above 4 functions in parallel:
  25. (trap 'kill 0' SIGINT; publish_color_images & publish_depth_images & set_camera_at_origin & run_rviz)

The result is shown below: