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

what's wrong with my gps_controller and utm_odometry_node

asked 2019-03-01 09:09:42 -0600

ydc gravatar image

updated 2019-03-01 19:52:14 -0600


I'm quite new to ROS and I want to use gps message to calculate an odom topic.

In the beginning, I have a urdf file and I add a gps_controller in it so I can get gps message by gazebo. Below is my code:

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

    <!-- Defining the colors used in this robot -->
    <material name="Black">
        <color rgba="0 0 0 1"/>

    <material name="White">
        <color rgba="1 1 1 1"/>

    <material name="Blue">
        <color rgba="0 0 1 1"/>

    <material name="Red">
        <color rgba="1 0 0 1"/>

    <!-- PROPERTY LIST -->
    <!--All units in m-kg-s-radians unit system -->
    <xacro:property name="M_PI" value="3.1415926535897931" />

    <!-- Main body length, width, height and mass -->
    <xacro:property name="base_mass"        value="0.5" /> 
    <xacro:property name="base_link_radius" value="0.13"/>
    <xacro:property name="base_link_length" value="0.005"/>

    <xacro:property name="motor_x" value="-0.05"/>

    <!-- Caster radius and mass -->
    <xacro:property name="caster_radius"          value="0.016" /> 
    <xacro:property name="caster_mass"            value="0.01" /> 
    <xacro:property name="caster_joint_origin_x"  value="-0.12" />

    <!-- Wheel radius, height and mass -->
    <xacro:property name="wheel_radius" value="0.033" /> 
    <xacro:property name="wheel_height" value="0.017" />
    <xacro:property name="wheel_mass"   value="0.1" />

    <!-- plate height and mass -->
    <xacro:property name="plate_mass"   value="0.05"/>
    <xacro:property name="plate_height" value="0.07"/>
    <xacro:property name="standoff_x"   value="0.12"/>
    <xacro:property name="standoff_y"   value="0.10"/>

    <!-- Macro for inertia matrix -->
    <xacro:macro name="sphere_inertial_matrix" params="m r">
            <mass value="${m}" />
            <inertia ixx="${2*m*r*r/5}" ixy="0" ixz="0"
                iyy="${2*m*r*r/5}" iyz="0" 
                izz="${2*m*r*r/5}" />

    <xacro:macro name="cylinder_inertial_matrix" params="m r h">
            <mass value="${m}" />
            <inertia ixx="${m*(3*r*r+h*h)/12}" ixy = "0" ixz = "0"
                iyy="${m*(3*r*r+h*h)/12}" iyz = "0"
                izz="${m*r*r/2}" /> 

    <xacro:macro name="box_inertial_matrix" params="m w h d">
            <mass value="${m}" />
            <inertia ixx="${m*(h*h+d*d)/12}" ixy = "0" ixz = "0"
                iyy="${m*(w*w+d*d)/12}" iyz = "0"
                izz="${m*(w*w+h*h)/12}" /> 

    <!-- Macro for wheel joint -->
    <xacro:macro name="wheel" params="lr translateY">
        <!-- lr: left, right -->
        <link name="wheel_${lr}_link">
                <origin xyz="0 0 0" rpy="${M_PI/2} 0  0 " /> 
                    <cylinder length="${wheel_height}" radius="${wheel_radius}" />
                <material name="Black" />
                <origin xyz="0 0 0" rpy="${M_PI/2} 0 0 " />
                    <cylinder length="${wheel_height}" radius="${wheel_radius}" />
            <cylinder_inertial_matrix  m="${wheel_mass}" r="${wheel_radius}" h="${wheel_height}" />

        <gazebo reference="wheel_${lr}_link">

        <joint name="base_to_wheel_${lr}_joint" type="continuous">
            <parent link="base_link"/>
            <child link="wheel_${lr}_link"/>
            <origin xyz="${motor_x} ${translateY * base_link_radius} 0" rpy="0 0 0" /> 
            <axis xyz="0 1 0" rpy="0  0" />

        <!-- Transmission is important to link the joints and the controller -->
        <transmission name="wheel_${lr}_joint_trans">
            <type>transmission_interface/SimpleTransmission ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-03-01 21:43:30 -0600

robustify gravatar image

updated 2019-03-01 21:44:02 -0600

The problem is that your /pred_odom topic are actual UTM coordinates corresponding to the latitude and longitude being generated by the Hector Gazebo GPS plugin, whereas the /odom topic just has the position relative to the Gazebo world frame.

One thing to try would be to have multiple Hector Gazebo ROS plugins mapped to different output topics, but with different noise parameters. That way, you could see the difference in UTM odometry data as a result of inputting ground-truth versus noisy latitude/longitude data.

edit flag offensive delete link more


Thanks for your reply, so did you mean I should use "tf" tool to build a relationship between "/base_link" and "/world"?

ydc gravatar image ydc  ( 2019-03-01 23:32:36 -0600 )edit

No, I mean you could run two instances of the Gazebo GPS plugin, each outputting a different NavSatFix message. One of these is ideal with no noise, and the other one is non-ideal with noise.

robustify gravatar image robustify  ( 2019-03-01 23:41:35 -0600 )edit

Using tf to publish a transform from world to base_link would not contain the UTM coordinates. Instead, you could run two instances of utm_odometry_node to convert the ideal and noisy NavSatFix messages into UTM..

robustify gravatar image robustify  ( 2019-03-01 23:43:41 -0600 )edit

Thank you, but what should I do if I just want to get an approximation of "/odom"? In fact, I'm working on a project which asks me to use GPS data and imu data to do SLAM. In the beginning, I use the gazebo to simulate and use "gmapping" package to do SLAM.

ydc gravatar image ydc  ( 2019-03-02 20:02:35 -0600 )edit

But "gmapping" package requires lidar data and odometry data. I'm already know how to use lidar data, and after referring some tutorials, I have implemented a demo with gazebo(use its "/odom" topic) in the simulation environment. Now I want to convert GPS data to an approximation of "/odom" topic.

ydc gravatar image ydc  ( 2019-03-02 20:06:47 -0600 )edit

Using pure UTM coordinates is inconvenient for Cartesian localization because of the very large numbers. Therefore, you could compute the UTM coordinates corresponding to the reference latitude and longitude in Gazebo, then offset that from all other UTM coordinates to get nicer numbers.

robustify gravatar image robustify  ( 2019-03-03 11:36:47 -0600 )edit

The SLAM map you get after doing this would be centered at the reference coordinates, so you'd have to store the reference coordinates with the map so you can use it for localization later

robustify gravatar image robustify  ( 2019-03-03 11:38:48 -0600 )edit

Question Tools

1 follower


Asked: 2019-03-01 09:09:42 -0600

Seen: 209 times

Last updated: Mar 01 '19