Depth camera not working in Reiz
Hi everyone,
I created this camera and attached it on the wrist3link of a universal robot. Unfortunately when I launch RViz and try to view the Image I can't select a topic for the image.
What am I doing wrong here?
This is the code for my depth camera:
<?xml version="1.0"?>
<robot name="camera" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!--//////////////////////////////VARIABLEN///////////////////////////////////////////-->
<!--Breiten der einzelnen Quader in m-->
<xacro:property name="c_b1" value="0.08512"/><!--Halter-->
<xacro:property name="c_b2" value="0.03194"/><!--Camera-->
<!--Längen der einzelnen Quader in m-->
<xacro:property name="c_l1" value="0.05"/><!--Halter-->
<xacro:property name="c_l2" value="0.1745"/><!--Camera-->
<!--Hoehen der einzelnen Quader in m-->
<xacro:property name="c_h1" value="0.005"/><!--Halter-->
<xacro:property name="c_h2" value="0.02993"/><!--Camera-->
<!--Massen der einzelnen Quader in kg-->
<xacro:property name="c_m1" value="0.387"/><!--Halter-->
<xacro:property name="c_m2" value="0.2"/><!--Camera-->
<!--///////////////////////////AUFBAU DER KAMERA///////////////////////////////////-->
<!--link name="basis_link"></link-->
<!--Brücke zu UR10-->
<link name="camera_mount_link">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<box size="${c_l1} ${c_b1} ${c_h1}"/>
</geometry>
</visual>
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="${c_m1}"/>
<inertia ixx="${(c_m1/12)*(c_h1*c_h1+c_l1*c_l1)}" ixy="0.0" ixz="0.0" iyy="${(c_m1/12)*(c_b1*c_b1+c_l1*c_l1)}" iyz="0.0" izz="${(c_m1/12)*(c_b1*c_b1+c_h1*c_h1)}"/>
</inertial>
<collision>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<box size="${c_l1} ${c_b1} ${c_h1}"/>
</geometry>
</collision>
</link>
<joint name="camera_mount_joint" type="fixed">
<origin xyz="0 0 0" rpy="0 0 0"/>
<parent link="camera_mount_link"/>
<child link="camera_link"/>
</joint>
<!--Kamera-->
<link name="camera_link">
<visual>
<origin xyz="0 ${-c_l1} ${c_h1} " rpy="0 0 0"/>
<geometry>
<box size="${c_l2} ${c_b2} ${c_h2}"/>
</geometry>
</visual>
<inertial>
<origin xyz="0 ${-c_l1} ${c_h1}" rpy="0 0 0"/>
<mass value="${c_m2}"/>
<inertia ixx="${(c_m2/12)*(c_h2*c_h2+c_l2*c_l2)}" ixy="0.0" ixz="0.0" iyy="${(c_m2/12)*(c_b2*c_b2+c_l2*c_l2)}" iyz="0.0" izz="${(c_m2/12)*(c_b2*c_b2+c_h2*c_h2)}"/>
</inertial>
<collision>
<origin xyz="0 ${-c_l1} ${c_h1}" rpy="0 0 0"/>
<geometry>
<box size="${c_l2} ${c_b2} ${c_h2}"/>
</geometry>
</collision>
</link>
<joint name="camera_optical_mount_joint" type="fixed">
<origin xyz="0 0 0" rpy="${-pi/2} 0 ${-pi/2}"/>
<parent link="camera_link"/>
<child link="camera_optical_link"/>
</joint>
<!--Kamera_optic-->
<link name="camera_optical_link"></link>
<!--////////////////////////////////////////Gazebo-Eigenschaften///////////////////////////////////////////-->
<gazebo reference="camera_mount_link">
<material>Gazebo/Green</material>
</gazebo>
<gazebo reference="camera_link">
<material>Gazebo/DarkGrey</material>
<sensor name="camera" type="depth">
<pose>0 0 0 0 0 0</pose>
<visualize>true</visualize>
<update_rate>10</update_rate>
<camera>
<horizontal_fov>1.089</horizontal_fov>
<image>
<format>B8R8G8</format>
<width>640</width>
<height>480</height>
</image>
<clip>
<near>0.05</near>
<far>8.0</far>
</clip>
</camera>
<plugin name="camera_controller" filename="libgazebo_ros_camera.so">
<frame_name>camera_optical_link</frame_name>
<min_depth>0.1</min_depth>
<max_depth>100.0</max_depth>
</plugin>
</sensor>
</gazebo>
</robot>
Asked by Icon45 on 2023-08-01 10:07:34 UTC
Answers
If you are using ROS2 probably is a QoS issue ( Quality of service)
You must open rviz2
1- ros2 run rviz2 rviz2
2- Go to add plugin button and look for image or camera
3- on topic select or type "/camera/image_raw" or "camera/depth"
4 - Below topic options there are QoS settings. Usually is set to "Reliable" and you need to switch to "Best Effort" or the inverse. Doing this change it should work and image appears.
5- If you don't have success, you need to check if camera data is publishing image data
A) ros2 topic list
B) ros2 topic echo /camera/depth
If data is not flowing then you found the issue, open rqt graph and check if your node is Not publishing data to your camera or subscribing and why:
C) ros2 run rqt_graph rqt_ graph
Asked by Vini71 on 2023-08-01 11:12:41 UTC
Comments
First of all thank you for your answer! So I've done steps 1 to 5 and also ran A to C. The Topics are simply not available or to put it in better words: don't exist. My problem really is that I don't know why they don't exist, because the code I wrote should work (at least as far as my understanding of goes)
Asked by Icon45 on 2023-08-02 03:34:29 UTC
Then it seems a robot state publisher or joint state publisher issue. Do you have these packages installed? Is your TF on rviz2 ok, I mean no transform errors? Just check if your urdf is correct? Go to your urdf folder and do
A) check_urdf robot_name.urdf
I would suggest debug this with ChatGpt, paste your robot model and ask GPT if something is wrong with your plugin definition...
Asked by Vini71 on 2023-08-02 04:51:51 UTC
Yeah i have installed these publishers and I’m using them to control my ur10. TF is ok. urdf is ok and ChatGPT doesn’t find any errors.
Asked by Icon45 on 2023-08-03 01:19:29 UTC
Comments