Ask Your Question
0

How do I rotate a camera plugin in my model?

asked 2020-10-05 08:14:44 -0500

ARMWilkinson gravatar image

updated 2021-04-24 03:01:13 -0500

I have a urdf file for a four wheeled robot that includes a camera and a hokuyo laser scanner that uses the gazebo sensor plugins. However, at the moment the camera points to the rear of the robot. I have tried changing the origin tag of the link for the camera and also tried adding a pose tag to various parts of the urdf file, with no change being present.

This is my urdf file:

<?xml version="1.0"?>
<robot name="Bilkins">


  <link name="chassis">
    <visual>
      <geometry>
        <mesh filename="package://bilkins/meshes/chassis.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin rpy="0.0 0 0" xyz="0 0 0"/>
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://bilkins/meshes/chassis.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin rpy="0.0 0 0" xyz="0 0 0"/>
    </collision>
    <inertial>
      <mass value="0.2" />
      <inertia ixx="0.4" ixy="0.0" ixz="0.0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
  </link>

  <link name="rear_axle">
    <visual>
      <geometry>
        <mesh filename="package://bilkins/meshes/rear_axle.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin xyz="-1.3 0 -0.5" />
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://bilkins/meshes/rear_axle.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin xyz="-1.3 0 -0.5" />
    </collision>
    <inertial>
      <mass value="0.14" />
      <inertia ixx="0.4" ixy="0.0" ixz="0.0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
  </link>

  <link name="front_axle">
    <visual>
      <geometry>
        <mesh filename="package://bilkins/meshes/front_axle.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin xyz="1.3 0 -0.5" />
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://bilkins/meshes/front_axle.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin xyz="1.3 0 -0.5" />
    </collision>
    <inertial>
      <mass value="0.1" />
      <inertia ixx="0.4" ixy="0.0" ixz="0.0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
  </link>

  <link name="front_left_wheel">
    <visual>
      <geometry>
        <mesh filename="package://bilkins/meshes/front_left_wheel.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin xyz="1.3 0.9 -0.5" />
    </visual>
    <collision>
      <geometry>
        <mesh filename="package://bilkins/meshes/front_left_wheel.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin xyz="1.3 0.9 -0.5" />
    </collision>
    <inertial>
      <mass value="0.02" />
      <inertia ixx="0.4" ixy="0.0" ixz="0.0" iyy="0.4" iyz="0.0" izz="0.2"/>
    </inertial>
  </link>

  <link name="front_right_wheel">
    <visual>
      <geometry>
        <mesh filename="package://bilkins/meshes/front_right_wheel.dae" scale="0.1 0.1 0.1" />
      </geometry>
      <origin xyz="1.3 -0.9 -0.5" />
    </visual>
    <collision>
      <geometry>
        <mesh filename="package ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-03-30 22:11:45 -0500

808brick gravatar image

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>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-10-05 08:14:44 -0500

Seen: 199 times

Last updated: Mar 30