diff --git a/examples/README.md b/examples/README.md index 993d0272..48d52cc1 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,3 +4,5 @@ How to use the ZED ROS node with other ROS packages * `zed_nodelet_example`: shows how to use the nodelet intraprocess communication to generate a virtual laser scan using the [depthimage_to_laserscan](http://wiki.ros.org/depthimage_to_laserscan) package * `zed_rtabmap_example`: shows how to use the ZED with the RTABMap package to generate a 3D map with the [rtabmap_ros](http://wiki.ros.org/rtabmap_ros) package + +* `zed_ar_track_alvar_example`: shows how to use the ZED with the [ar_track_alvar](http://wiki.ros.org/ar_track_alvar) package to detect and track the position of AR tags diff --git a/examples/zed_ar_track_alvar_example/CMakeLists.txt b/examples/zed_ar_track_alvar_example/CMakeLists.txt new file mode 100644 index 00000000..640b763d --- /dev/null +++ b/examples/zed_ar_track_alvar_example/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 2.8.7) + +project(zed_ar_track_alvar_example) + +find_package(catkin REQUIRED) + +catkin_package() + +############################################################################### +#Add all files in subdirectories of the project in +# a dummy_target so qtcreator have access to all files +FILE(GLOB_RECURSE extra_files ${CMAKE_SOURCE_DIR}/*) +add_custom_target(dummy_${PROJECT_NAME} SOURCES ${extra_files}) + +############################################################################### +# INSTALL + +install(DIRECTORY + launch + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) diff --git a/examples/zed_ar_track_alvar_example/README.md b/examples/zed_ar_track_alvar_example/README.md new file mode 100644 index 00000000..936b6cd0 --- /dev/null +++ b/examples/zed_ar_track_alvar_example/README.md @@ -0,0 +1,85 @@ +# Stereolabs ZED Camera - Alvar AR tag example + +This package shows how to use the ZED Wrapper with [ar_track_alvar](http://wiki.ros.org/ar_track_alvar) to detect AR markers and localize them in the space. + +The [ar_track_alvar](http://wiki.ros.org/ar_track_alvar) package is a ROS wrapper for [Alvar](http://virtual.vtt.fi/virtual/proj2/multimedia/index.html), an open source AR tag tracking library. + +## Install the ar_track_alvar package + +Open a terminal and launch + + $ sudo apt install ros-kinetic-ar-track-alvar + +## Run the program + +To launch the example, open a terminal and launch: + + $ roslaunch zed_ar_track_alvar_example zed_ar_track_alvar.launch + +The launch file automatically starts the `zed_wrapper` node, the `ar_track_alvar` node and `RVIZ` with a preconfigured view: + +![Example of indoor 3D mapping](images/ar_track_alvar.png) + +* the `Left Image` view shows the RGB stream from the left camera of the ZED. +* the `Left Camera` view shows the "world" as seen by the left camera. The `TF` and the `Tags` are selected to be shown in 3D projection +* the 3D view shows the ZED camera localized in the space and the position of the `Tags` as coloured markers. + +*Note* It is important to subscribe the `/zed/pose` topic to be able to localize the camera in the space. + +*Note* the tags used in the example are available following this [link](images/markers0to8.png) + +## The launch file explained + +To use the ZED wrapper with the `ar_track_alvar` node we need to correctly set the following ar_track_alvar parameters: + +- `camera_image` -> the name of the topic that provides camera frames for detecting the AR tags. +- `camera_info` -> the name of the topic of camera parameters used to correctly localize the tag in the 3D world +- `output_frame` -> the name of the TF frame associated to the camera position + +It is important that the `zed_wrapper` node and the `ar_track_alvar` node use the same values for these three parameters to be able to correctly communicate. + +The values associated to the above parameters are the following: + +``` + + + +``` + +The corresponding parameters of the ZED node are the following: + +- `cam_image_topic` -> `rgb_topic` +- `cam_info_topic` -> `rgb_info_topic` +- `camera_frame` -> `left_camera_frame` + +The corresponding parameters of the `rtabmap_ros` node are the following: + +- `cam_image_topic` -> `camera_image` +- `cam_info_topic` -> `camera_info` +- `camera_frame` -> `output_frame` + +It is also important to set the correct `marker_size` in centimeters. Better if the real size of the markers is measured after printing them: + + + +Other parameters that can be tuned: +* `max_new_marker_error` -> A threshold determining when new markers can be detected under uncertainty +* `max_track_error` -> A threshold determining how much tracking error can be observed before an tag is considered to have disappeared + +Their values in the launch file: + + + + +## Markers + +Following two examples of markers with ID numbers from 0 to 17: + +![Markers 0-8](images/markers0to8.png) +![Markers 9-17](images/markers9to17.png) + + + + + + diff --git a/examples/zed_ar_track_alvar_example/images/ar_track_alvar.png b/examples/zed_ar_track_alvar_example/images/ar_track_alvar.png new file mode 100644 index 00000000..767e9b6a Binary files /dev/null and b/examples/zed_ar_track_alvar_example/images/ar_track_alvar.png differ diff --git a/examples/zed_ar_track_alvar_example/images/markers0to8.png b/examples/zed_ar_track_alvar_example/images/markers0to8.png new file mode 100644 index 00000000..15690e6f Binary files /dev/null and b/examples/zed_ar_track_alvar_example/images/markers0to8.png differ diff --git a/examples/zed_ar_track_alvar_example/images/markers9to17.png b/examples/zed_ar_track_alvar_example/images/markers9to17.png new file mode 100644 index 00000000..92ca31fa Binary files /dev/null and b/examples/zed_ar_track_alvar_example/images/markers9to17.png differ diff --git a/examples/zed_ar_track_alvar_example/launch/zed_ar_track_alvar.launch b/examples/zed_ar_track_alvar_example/launch/zed_ar_track_alvar.launch new file mode 100644 index 00000000..c163ee03 --- /dev/null +++ b/examples/zed_ar_track_alvar_example/launch/zed_ar_track_alvar.launch @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/zed_ar_track_alvar_example/package.xml b/examples/zed_ar_track_alvar_example/package.xml new file mode 100644 index 00000000..a2c07989 --- /dev/null +++ b/examples/zed_ar_track_alvar_example/package.xml @@ -0,0 +1,17 @@ + + + zed_ar_track_alvar_example + 2.6.0 + + "zed_ar_track_alvar_example" is a ROS package to show how to use the ROS wrapper with "ar_track_alvar" + + + STEREOLABS + MIT + + catkin + + ar_track_alvar + ar_track_alvar_msgs + zed_wrapper + diff --git a/examples/zed_ar_track_alvar_example/rviz/zed_ar_track_alvar_example.rviz b/examples/zed_ar_track_alvar_example/rviz/zed_ar_track_alvar_example.rviz new file mode 100644 index 00000000..9dafd007 --- /dev/null +++ b/examples/zed_ar_track_alvar_example/rviz/zed_ar_track_alvar_example.rviz @@ -0,0 +1,316 @@ +Panels: + - Class: rviz/Displays + Help Height: 0 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /TF1 + - /TF1/Frames1 + - /Left Camera1/Visibility1 + - /Pose1 + - /Tags1 + - /Left Image1 + Splitter Ratio: 0.483870953 + Tree Height: 853 + - Class: rviz/Selection + Name: Selection + - Class: rviz/Tool Properties + Expanded: + - /2D Pose Estimate1 + - /2D Nav Goal1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.588679016 + - Class: rviz/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: Left Camera +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.0299999993 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Alpha: 1 + Class: rviz/RobotModel + Collision Enabled: false + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + imu_link: + Alpha: 1 + Show Axes: false + Show Trail: false + zed_camera_center: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + zed_left_camera_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + zed_left_camera_optical_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + zed_right_camera_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + zed_right_camera_optical_frame: + Alpha: 1 + Show Axes: false + Show Trail: false + Name: Camera Model + Robot Description: /zed/zed_description + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Class: rviz/TF + Enabled: true + Frame Timeout: 1 + Frames: + All Enabled: false + ar_marker_0: + Value: true + ar_marker_1: + Value: true + ar_marker_14: + Value: true + ar_marker_144: + Value: true + ar_marker_192: + Value: true + ar_marker_2: + Value: true + ar_marker_3: + Value: true + ar_marker_4: + Value: true + ar_marker_48: + Value: true + ar_marker_5: + Value: true + ar_marker_6: + Value: true + ar_marker_64: + Value: true + ar_marker_7: + Value: true + ar_marker_8: + Value: true + ar_marker_80: + Value: true + ar_marker_9: + Value: true + map: + Value: true + odom: + Value: true + zed_camera_center: + Value: true + zed_left_camera_frame: + Value: true + zed_left_camera_optical_frame: + Value: false + zed_right_camera_frame: + Value: false + zed_right_camera_optical_frame: + Value: false + Marker Scale: 0.300000012 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + map: + odom: + zed_camera_center: + zed_left_camera_frame: + zed_left_camera_optical_frame: + ar_marker_0: + {} + ar_marker_1: + {} + ar_marker_14: + {} + ar_marker_144: + {} + ar_marker_192: + {} + ar_marker_2: + {} + ar_marker_3: + {} + ar_marker_4: + {} + ar_marker_48: + {} + ar_marker_5: + {} + ar_marker_6: + {} + ar_marker_64: + {} + ar_marker_7: + {} + ar_marker_8: + {} + ar_marker_80: + {} + ar_marker_9: + {} + zed_right_camera_frame: + zed_right_camera_optical_frame: + {} + Update Interval: 0 + Value: true + - Class: rviz/Camera + Enabled: true + Image Rendering: background and overlay + Image Topic: /zed/left/image_rect_color + Name: Left Camera + Overlay Alpha: 0.25 + Queue Size: 1 + Transport Hint: raw + Unreliable: true + Value: true + Visibility: + Camera Model: false + Grid: true + Left Image: true + Pose: false + TF: true + Tags: true + Value: true + Zoom Factor: 1 + - Alpha: 1 + Axes Length: 0.100000001 + Axes Radius: 0.00999999978 + Class: rviz/Pose + Color: 255; 25; 0 + Enabled: true + Head Length: 0.300000012 + Head Radius: 0.100000001 + Name: Pose + Shaft Length: 1 + Shaft Radius: 0.0500000007 + Shape: Axes + Topic: /zed/pose + Unreliable: false + Value: true + - Class: rviz/Marker + Enabled: true + Marker Topic: /zed/visualization_marker + Name: Tags + Namespaces: + basic_shapes: true + Queue Size: 1 + Value: true + - Class: rviz/Image + Enabled: true + Image Topic: /zed/left/image_rect_color + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Left Image + Normalize Range: true + Queue Size: 1 + Transport Hint: raw + Unreliable: true + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Default Light: true + Fixed Frame: map + Frame Rate: 30 + Name: root + Tools: + - Class: rviz/Interact + Hide Inactive Objects: true + - Class: rviz/MoveCamera + - Class: rviz/Select + - Class: rviz/FocusCamera + - Class: rviz/Measure + - Class: rviz/SetInitialPose + Topic: /initialpose + - Class: rviz/SetGoal + Topic: /move_base_simple/goal + - Class: rviz/PublishPoint + Single click: true + Topic: /clicked_point + Value: true + Views: + Current: + Class: rviz/Orbit + Distance: 1.46672368 + Enable Stereo Rendering: + Stereo Eye Separation: 0.0599999987 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0.1578127 + Y: 0.186369434 + Z: 0.101506129 + Focal Shape Fixed Size: true + Focal Shape Size: 0.0500000007 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.00999999978 + Pitch: 0.604797184 + Target Frame: + Value: Orbit (rviz) + Yaw: 2.34038639 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1056 + Hide Left Dock: false + Hide Right Dock: false + Left Camera: + collapsed: false + Left Image: + collapsed: false + QMainWindow State: 000000ff00000000fd00000004000000000000018300000396fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000006100fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000002800000396000000d700fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c0000026100000001000002fa00000396fc0200000005fb00000014004c00650066007400200049006d0061006700650100000028000001c60000001600fffffffb00000016004c006500660074002000430061006d00650072006101000001f4000001ca0000001600fffffffb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000002800000396000000ad00fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b20000000000000000000000020000073f000001a3fc0100000001fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000073f0000003efc0100000002fb0000000800540069006d006501000000000000073f0000030000fffffffb0000000800540069006d00650100000000000004500000000000000000000002b60000039600000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1855 + X: 1985 + Y: 24