ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
OK, I have finally been able to find a solution to this problem. The problem here was two-fold.
Solution to problem 1:
In the turtlebot_description package, inside the "urdf" folder, there is a file named "gazebo.urdf.xacro". Modify the "turtlebot_sim_kinect" macro in that file and remove the leading "/" from the imageTopicName element. (I also removed it from other topic names since having absolute topic names here is a bad practice to start with). Now, the final "turtlebot_sim_kinect" xacro should look like:
<xacro:macro name="turtlebot_sim_kinect">
<gazebo reference="camera_link">
<sensor:camera name="camera">
<imageFormat>R8G8B8</imageFormat>
<imageSize>640 480</imageSize>
<hfov>60</hfov>
<nearClip>0.05</nearClip>
<farClip>3</farClip>
<updateRate>20</updateRate>
<baseline>0.1</baseline>
<controller:gazebo_ros_openni_kinect name="kinect_camera_controller" plugin="libgazebo_ros_openni_kinect.so">
<alwaysOn>true</alwaysOn>
<updateRate>20</updateRate>
<imageTopicName>camera/image_raw</imageTopicName>
<pointCloudTopicName>camera/depth/points</pointCloudTopicName>
<cameraInfoTopicName>camera/camera_info</cameraInfoTopicName>
<frameName>camera_depth_optical_frame</frameName>
<distortion_k1>0.0</distortion_k1>
<distortion_k2>0.0</distortion_k2>
<distortion_k3>0.0</distortion_k3>
<distortion_t1>0.0</distortion_t1>
<distortion_t2>0.0</distortion_t2>
</controller:gazebo_ros_openni_kinect>
</sensor:camera>
</gazebo>
</xacro:macro>
...save the file and exit. Now, the /camera/image_raw topic should resolve correctly to the correct robot prefix. Namely... "/robot1/camera/image_raw" and "/robot2/camera/image_raw" in my case. Note: I believe recompilation is unnecessary since we only modified the xacro. Although, I did do a recompile without realizing this at first. Even if you DO do a recompile, it shouldn't do any harm.
Solution to problem 2:
The camera topics don't carry the correct frame ID for the images they publish. Which means that although the camera topics are separate, the frame IDs do not get resolved correctly to the appropriate TF prefix. Hence, someone who wants to use the two independent camera images cannot do so.
This is related to a similar bug in the laser sensor that was fixed here:
code.ros.org/trac/ros-pkg/ticket/5511
Using the same principle that was applied in the laser sensor bug fix, I applied the solution to the camera sensor as follows...
Go to the "gazebo_ros_openni_kinect.cpp" file in /src of the "gazebo_plugins" package. (This is the source for the camera controller specified in "gazebo.urdf.xacro" file earlier)
Add the following to the code:
1.Add this at the top with other includes-
#include "tf/tf.h"
2.Add the following lines inside the "GazeboRosOpenniKinect::LoadChild" function:
std::string prefix;
this->rosnode_->getParam(std::string("tf_prefix"), prefix);
this->frameName = tf::resolve(prefix, this->frameName);
NOTE: add the above lines before any of the topics is advertised! Ideally, just before the line-
this->image_pub_ = this->itnode_->advertise(
(This makes sure the TF prefix is resolved before any topic is advertised)
Finally... save, exit, and recompile the gazebo_plugins package.
Voila!!! The multiple cameras should be up and running!