Ask Your Question

Simulated 3-axis camera gimbal for UAV in gazebo

asked 2017-09-01 08:43:55 -0500

WillAndrew gravatar image

Hi there,

I'm currently trying to simulate a "perfect" (no friction) 3-axis camera gimbal attached on the bottom of a UAV. I'm using the hector quadrotor gazebo/ROS project to try and achieve this.

The ultimate goal is that the simulated image plane is continuously perpendicular with the world plane.

In order to achieve this, I've attached a simulated camera to 3 orthogonal, continuous joints via links with no length (see the URDF/xacro below). However, the image feed produced is still as if the camera were permanently affixed to it.

I'm fairly new to URDF/xacro/etc. so please excuse me if this is just a basic misunderstanding on my part!

Here's the gimbal URDF/xacro file I've created:

<?xml version="1.0"?>

<robot xmlns:xacro="">

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

  <xacro:macro name="gimbal_camera" params="name parent *origin ros_topic cam_info_topic update_rate res_x res_y image_format hfov">

    <!-- Gimbal attached to UAV -->
    <joint name="gimbal_joint" type="fixed">
        <xacro:insert_block name="origin" />
        <parent link="${parent}" />
        <child link="gimbal_r_link" />

    <link name="gimbal_r_link">
        <mass value="0" />
        <inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />

    <joint name="gimbal_r_joint" type="continuous">
        <parent link="gimbal_r_link" />
        <child link="gimbal_p_link" />
        <axis xyz="1 0 0" />
        <dynamics damping="0.0" friction="0.0" />

    <link name="gimbal_p_link">
        <mass value="0" />
        <inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />

    <joint name="gimbal_p_joint" type="continuous">
        <parent link="gimbal_p_link" />
        <child link="gimbal_y_link" />
        <axis xyz="0 1 0" />
        <dynamics damping="0.0" friction="0.0" />

    <link name="gimbal_y_link">
        <mass value="0" />
        <inertia ixx="0" ixy="0" ixz="0" iyy="0" iyz="0" izz="0" />

    <joint name="gimbal_y_joint" type="continuous">
        <parent link="gimbal_y_link" />
        <child link="${name}_link" />
        <axis xyz="0 0 1" />
        <dynamics damping="0.0" friction="0.0" />

    <link name="${name}_link">

    <joint name="${name}_optical_joint" type="fixed">
      <origin xyz="0 0 0" rpy="${-M_PI/2} 0.0 ${-M_PI/2}" />
      <parent link="${name}_link" />
      <child link="${name}_optical_frame"/>

    <link name="${name}_optical_frame">

    <gazebo reference="gimbal_r_link">
      <sensor type="camera" name="${name}_camera_sensor">
          <horizontal_fov>${hfov * M_PI/180.0}</horizontal_fov>

        <plugin name="${name}_camera_controller" filename="">


Which is instantiated in the following file:

<?xml version="1.0"?>

<robot name="quadrotor" xmlns:xacro="">

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

    <!-- Included URDF Files -->
    <xacro:include filename="$(find hector_quadrotor_description)/urdf/quadrotor_base.urdf.xacro" />
    <xacro:include filename="$(find hector_sensors_description)/urdf/gimbal_camera.urdf.xacro" />

    <!-- Instantiate quadrotor_base_macro once (has no parameters atm) -->
    <xacro:quadrotor_base_macro />

    <!-- Downward facing camera attached to gimbal -->
    <xacro:gimbal_camera name="downward_cam" parent="base_link" ros_topic="camera/image" cam_info_topic="camera/camera_info ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-09-01 09:38:06 -0500

lucasw gravatar image

updated 2017-09-01 09:39:57 -0500

You could try adding small masses and inertia values to your links. Once you do that the camera might at least flop around in response to movements of the uav, though it likely won't be stabilized.

For that you would need to set up controllers for each joint that will command them to the proper rotation that will cancel out rotation of the parent uav frame with respect to the world. ( has the basics of setting up controllers )

In order to come up with the proper commands to send to the controllers you would need to look up the transform tf of the parent uav frame with the world and pull out roll pitch and yaw. A simulated imu could be added to your uav for this- I'm not sure if the standard gazebo sim imu outputs a tf directly or just raw angles- in the latter case the raw angles could be used in your camera stabilizing controller directly. Or it only outputs raw angular rates and has to be hooked up to another node that integrates those into angles and deal with build-up of error, or use a tilt sensor instead. Or you can cheat and get the true gazebo attitude of the uav by querying gazebo directly.

It would be interesting to experiment with gyroscopic stabilization (put a motor and a spinning disc with a mass near the camera), but possibly the gazebo physics engine won't handle that properly.

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



Asked: 2017-09-01 08:43:55 -0500

Seen: 1,396 times

Last updated: Sep 01 '17