Ask Your Question
0

what's wrong with my gps_controller and utm_odometry_node

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

ydc gravatar image

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

Hello,

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:

n="1.0"?>
<robot name="mrobot" xmlns:xacro="http://www.ros.org/wiki/xacro">

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

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

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

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

    <!-- 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">
        <inertial>
            <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}" />
        </inertial>
    </xacro:macro>

    <xacro:macro name="cylinder_inertial_matrix" params="m r h">
        <inertial>
            <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}" /> 
        </inertial>
    </xacro:macro>

    <xacro:macro name="box_inertial_matrix" params="m w h d">
        <inertial>
            <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}" /> 
        </inertial>
    </xacro:macro>

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

        <gazebo reference="wheel_${lr}_link">
            <material>Gazebo/Black</material>
        </gazebo>

        <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" />
        </joint>

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

1 Answer

Sort by ยป oldest newest most voted
0

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

robustify gravatar image

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

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

Comments

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

ydc gravatar imageydc ( 2019-03-01 23:32:36 -0500 )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 imagerobustify ( 2019-03-01 23:41:35 -0500 )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 imagerobustify ( 2019-03-01 23:43:41 -0500 )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 imageydc ( 2019-03-02 20:02:35 -0500 )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 imageydc ( 2019-03-02 20:06:47 -0500 )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 imagerobustify ( 2019-03-03 11:36:47 -0500 )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 imagerobustify ( 2019-03-03 11:38:48 -0500 )edit

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: 2019-03-01 09:09:42 -0500

Seen: 45 times

Last updated: Mar 01