ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Adding a camera to my urdf

asked 2015-08-25 10:02:34 -0500

Samper-Esc gravatar image

updated 2016-04-21 04:10:07 -0500

gvdhoorn gravatar image

Hello,

I am trying to add a camera to the end of an arm using xacros. The camera link URDF is:

<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
  <xacro:macro name="camera" params="parent">
    <link name="camera">
      <collision>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
            <mesh filename="package://sensors_and_actuators/meshes/camara.stl" scale="0.1 0.1 0.1"/>
        </geometry>
      </collision>

      <visual>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <geometry>
            <mesh filename="package://sensors_and_actuators/meshes/camara.stl" scale="0.1 0.1 0.1"/>
        </geometry>
      </visual>

      <inertial>
        <mass value="1e-5" />
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
      </inertial>
    </link>

    <joint name="sensor_joint" type="fixed">
        <parent link="${parent}"/>
        <child link="camera"/>
        <origin rpy="0 1.5620 0" xyz="0.0475 0.0 0.0"/>
        <axis xyz="1 0 0" />
    </joint>

    <gazebo reference="camera">
      <sensor type="camera" name="camera_sensor">
        <parent link="camera"/>
        <update_rate>30.0</update_rate>
        <camera>
          <horizontal_fov>1.3962634</horizontal_fov>
          <image>
            <format>R8G8B8</format>
            <width>800</width>
            <height>800</height>
          </image>
          <clip>
            <near>0.01</near>
            <far>100</far>
          </clip>
        </camera>

        <plugin name="${name}_camera_controller" filename="libgazebo_ros_camera.so">
          <cameraName>arm_sensors/camera</cameraName>
          <alwaysOn>true</alwaysOn>
          <updateRate>0.0</updateRate>
          <imageTopicName>image_raw</imageTopicName>
          <cameraInfoTopicName>camera_info</cameraInfoTopicName>
          <frameName>camera</frameName>
        </plugin>
      </sensor>
    </gazebo>

  </xacro:macro>
</robot>

When I run the launch file it reports an error saying that the parent param is missing:

samper@samper:~$ roslaunch cern_tim_arm_simulator arm_tim_simulator.launch spawn_arm:=true robotic_arm:=schunk_lwa4p world:=tunnel spawn_collimator:=true camera_on_arm:=true
... logging to /home/samper/.ros/log/2c17a290-4b39-11e5-b79f-605718079cbb/roslaunch-samper-16690.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Traceback (most recent call last):
  File "/opt/ros/indigo/share/xacro/xacro.py", line 60, in <module>
    xacro.main()
  File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 696, in main
    eval_self_contained(doc)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 626, in eval_self_contained
    eval_all(doc.documentElement, macros, symbols)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 552, in eval_all
    (",".join(params), str(node.tagName)))
xacro.XacroException: Parameters [parent] were not set for macro camera
while processing /home/samper/ROS_Workspaces/ROS_Cern/src/ros_cern/tim_gazebo/load_world.launch:
while processing /home/samper/ROS_Workspaces/ROS_Cern/src/ros_cern/robotic_arm/launch/schunk_lwa4p_and_tim.launch:
Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/indigo/share/xacro/xacro.py '/home/samper/ROS_Workspaces/ROS_Cern/src/ros_cern/robotic_arm/arm_description/robots/schunk_lwa4p/schunk_lwa4p_arm_and_tim_camera.urdf.xacro'] returned with code [1]. 

Param xml is <param command="$(find xacro)/xacro.py '$(find robotic_arm)/arm_description/robots/schunk_lwa4p/schunk_lwa4p_arm_and_tim_camera.urdf.xacro'" if="$(arg camera_on_arm)" name="robot_description"/>
The traceback for the exception was written to the log file

I would really appreciate if someone could give me any clue. Thank you in advance.

JLuis Samper

PS: it only works if i delete the <camera> tag and its content

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-08-26 03:49:57 -0500

Samper-Esc gravatar image

updated 2016-04-21 04:09:01 -0500

gvdhoorn gravatar image

In case that someone has this problem, i just solved it changing the inertial values. Gazebo has a problem when has to work with small values in the inertial block. Additionally I just omitted the parent tag, it is taken from the joint.

If you need to orientate the position of the optical focus you can do it by the pose property tag of the gazebo plugin

<?xml version="1.0"?>

<robot xmlns:xacro="http://ros.org/wiki/xacro">

  <xacro:property name="M_PI" value="3.1415926535897931" />

  <xacro:macro name="camera_link" params="parent">


    <link name="camera_link">

      <collision>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://sensors_and_actuators/meshes/camara.stl" scale="0.1 0.1 0.1"/>

        </geometry>
      </collision>

      <visual>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <geometry>
          <mesh filename="package://sensors_and_actuators/meshes/camara.stl" scale="0.1 0.1 0.1"/>
        </geometry>
        <material name="grey">
            <color rgba="0.2 0.2 0.2 1.0"/>
        </material>
      </visual>


      <inertial>
        <mass value="0.001" />
        <origin xyz="0 0 0" rpy="0 0 0" />
        <inertia ixx="0.0001" ixy="0" ixz="0" iyy="0.0001" iyz="0" izz="0.0001" />
      </inertial>

    </link>



    <joint name="camera_joint" type="fixed">
        <parent link="${parent}"/>
        <child link="camera_link"/>
        <origin rpy="0 0 0" xyz="0.047 0.0 0.0"/>
        <axis xyz="1 0 0" />
    </joint>



    <gazebo reference="camera_link">
      <sensor type="camera" name="camera_camera_sensor">
        <update_rate>30.0</update_rate>
        <camera>
          <pose>0.035 0 0.078 0 ${-M_PI/2} 0</pose>
          <horizontal_fov>${85 * M_PI/180.0}</horizontal_fov>
          <image>
            <format>R8G8B8</format>
            <width>1020</width>
            <height>1020</height>
          </image>
          <clip>
            <near>0.01</near>
            <far>100</far>
          </clip>
        </camera>

        <plugin name="camera_camera_controller" filename="libgazebo_ros_camera.so">
          <alwaysOn>true</alwaysOn>
          <updateRate>0.0</updateRate>
          <cameraName>arm_sensor/camera</cameraName>
          <imageTopicName>image_raw</imageTopicName>
          <cameraInfoTopicName>camera_info</cameraInfoTopicName>
          <frameName>camera_link</frameName>
          <hackBaseline>0.07</hackBaseline>
          <distortionK1>0.0</distortionK1>
          <distortionK2>0.0</distortionK2>
          <distortionK3>0.0</distortionK3>
          <distortionT1>0.0</distortionT1>
          <distortionT2>0.0</distortionT2>
        </plugin>
      </sensor>
    </gazebo>
  </xacro:macro>

</robot>
edit flag offensive delete link more

Comments

Can you please accept your own answer? That way it is clear from the question listing that it has been answered.

gvdhoorn gravatar image gvdhoorn  ( 2016-04-21 04:08:43 -0500 )edit

I tried but it says that i need more than 10 points

Samper-Esc gravatar image Samper-Esc  ( 2016-04-21 04:33:46 -0500 )edit

Ah, right. Just accepted it for you.

gvdhoorn gravatar image gvdhoorn  ( 2016-04-21 04:49:39 -0500 )edit

Thank you very much

Samper-Esc gravatar image Samper-Esc  ( 2016-04-21 05:20:05 -0500 )edit
2

answered 2016-04-20 23:20:05 -0500

updated 2016-04-20 23:20:47 -0500

Actually you're using a fairly common name. It is likely that the macro name "camera" is similar to a an already defined xacro macro. Try renaming the xacro:macro to something a little more unique such as "my_camera_link". I had this problem with a xacro macro named "sphere". Changing the macro name solved the issue and xacro confusion.

edit flag offensive delete link more

Comments

UNBELIEVABLE!!! Thank you.

sisko gravatar image sisko  ( 2020-12-12 17:52:41 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-08-25 10:02:34 -0500

Seen: 27,980 times

Last updated: Apr 21 '16