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

Revision history [back]

click to hide/show revision 1
initial version

I haven't been able to find a way to rotate the camera plugin on Ubuntu 20, ROS 2 Foxy, but it is worth noting that the plugin faces towards the positive X direction. So you can either design the link acting as your camera accordingly, or you can make a special link with no physics attributes, and create a joint connecting the camera sensor link to your actual link you have to represent the camera.

Example a camera sensor rotated 90 degrees (from yaw/z axis) than that of the link:

<?xml version="1.0" encoding="UTF-8"?>

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

 <!-- Just the sensor, nothing else -->
<link name="camera_sensor_link">

      <sensor type="camera" name="sensor_name">
          <always_on>0</always_on>
          <update_rate>1</update_rate>

          <camera name="camera_name">
            <distortion>
              <k1>0.1</k1>
              <k2>0.2</k2>
              <k3>0.3</k3>
              <p1>0.4</p1>
              <p2>0.5</p2>
              <center>0.5 0.5</center>
            </distortion>
          </camera>

          <plugin name="plugin_name" filename="libgazebo_ros_camera.so">

            <ros>
              <namespace>custom_ns</namespace>
              <argument>image_raw:=custom_img</argument>
              <argument>camera_info:=custom_info</argument>
            </ros>

            <camera_name>custom_camera</camera_name>
            <frame_name>custom_frame</frame_name>
            <hack_baseline>0.07</hack_baseline>
          </plugin>
        </sensor>

</link>

 <!-- This would be your actual link you wanted to attach the camera sensor too -->
<link name="camera_link">

    <!-- Camera Link Inertia -->
    <inertial>
      <mass value="1"/>
      <inertia
        ixx="0.166667" ixy="0" ixz="0"
        iyx="0" iyy="0.166667" iyz="0"
        izx="0" izy="0" izz="0.166667"
        />
    </inertial>

    <!-- Camera Link Visual -->
    <visual name='visual'>
      <geometry>
        <box size="0.1 0.2 0.1" />
      </geometry>
    </visual>

    <!-- Camera Link Collision -->
    <collision name='collision'>
      <geometry>
        <box size="0.1 0.2 0.1" />
      </geometry>
    </collision>
  </link>

<joint name='robot_footprint_joint' type='fixed'>
    <parent link="camera_link" />
    <child link="camera_sensor_link" />
    <origin xyz="0.1 0 0" rpy="0 0 1.570795" />
  </joint>

</robot>