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

Basic robot_localization example

asked 2017-04-12 06:46:24 -0600

lasersocks gravatar image

I am attempting to get the most basic example of robot_localization working on a raspberry pi. I am new to linux and the ROS ecosystem, so I have fought through an exceptional number of issues to get it working. The information necessary to do this seems to be somewhat fragmented or over complicated for a beginner.

In order to do the localization I am using the BNO055 IMU by bosch that outputs orientation as well as standard IMU data. I am also using two incremental encoders on the wheels of lets say a "cart." This example is as simple as it can get, There are no motors and I just want to know the position of a cart that is pushed externally.

I have the system working, and it looks like filtered odom data seems to be more accurate, but I am having trouble making sure I did everything right.

The most basic question... is this the proper way to use ekf node? In the very simpliest terms do these three codes seem correct? I have simplified them into the important components

The IMU uses:

#create publisher
imu_pub = rospy.Publisher('imu/data', Imu, queue_size=1)
#init node and set rate
rospy.init_node('imu_talker', anonymous=True)
rate = rospy.Rate(10) # 10hz

while not rospy.is_shutdown():

    #create message and header
    imu = Imu()
    imu.header.stamp =
    imu.header.frame_id = 'imu'

    #put data into the message
    imu.orientation = quaternion
    imu.angular_velocity = ang_vel 
    imu.linear_acceleration = lin_acc

    #publish message

    #sleep at known rate

The ODOM uses:

#create publishers
odom_pub = rospy.Publisher("odom", Odometry, queue_size=1)
odom_broadcaster = tf.TransformBroadcaster()

#init node and rate
rospy.init_node('odom_talker', anonymous=True)
rate = rospy.Rate(10) # 10hz

while not rospy.is_shutdown():

    #create message and header
    odom = Odometry()
    odom.header.stamp =
    odom.header.frame_id = "odom"

    #convert euler to quaternion
    odom_quat = tf.transformations.quaternion_from_euler(0, 0, th)
    #broadcast transform
    odom_broadcaster.sendTransform((x, y, 0.), odom_quat,current_time,"base_link", "odom")

    # set the position
    odom.pose.pose = Pose(Point(x, y, 0.), Quaternion(*odom_quat))

    # set the velocity
    odom.child_frame_id = "base_link"
    odom.twist.twist = Twist(Vector3(vx, vy, 0), Vector3(0, 0, vth))

    # publish the message

    #sleep at known rate

The EKF launch file uses:


    <node pkg="robot_localization" type="ekf_localization_node" name="ekf_localization" clear_params="true">
      <param name="frequency" value="10"/>  
      <param name="sensor_timeout" value="0.2"/>  
      <param name="two_d_mode" value="true"/>

      <param name="map_frame" value="map"/>
      <param name="odom_frame" value="odom"/>
      <param name="base_link_frame" value="base_link"/>
      <param name="world_frame" value="odom"/>

      <param name="odom0" value="odom"/>
      <param name="imu0" value="/imu/data"/> 

      <rosparam param="odom0_config">[true,  true,  false, 
                                      false, false, true, 
                                      true, true, false, 
                                      false, false, true,
                                      false, false, false]</rosparam>

      <rosparam param="imu0_config">[false, false, false, 
                                     true,  true,  true, 
                                     false, false, false, 
                                     true,  true,  true,
                                     true, true, true]</rosparam>

      <param name="odom0_differential" value="true"/>
      <param name="imu0_differential" value="true"/>

      <param name="imu0_remove_gravitational_acceleration" value="false"/>

      <rosparam param="process_noise_covariance">[LARGE ...
edit retag flag offensive close merge delete


I have done a little more work with this, and as far as I can tell, the fused data is often less accurate than just plain odometry. I am assuming I did something wrong.

Is this not the right place to ask this question? Can someone recommend somewhere to get help?

lasersocks gravatar image lasersocks  ( 2017-04-17 13:38:27 -0600 )edit

Apologies for not responding to this. Did you ever solve this problem?

Tom Moore gravatar image Tom Moore  ( 2017-07-20 04:25:16 -0600 )edit

I'm also trying to get robot_localization implement and I have to say the lack of a simple full working example of how to implement it is making learning how to use this harder than it should be. Also, consider having standard docs on the ros wiki site. People are used to those docs. Thanks!

psammut gravatar image psammut  ( 2017-10-20 20:45:12 -0600 )edit

EDIT* I feel like a b-hole cause i found a bunch of examples on the git hub repo.

psammut gravatar image psammut  ( 2017-10-20 21:09:08 -0600 )edit

Haha! No worries.

Tom Moore gravatar image Tom Moore  ( 2017-10-24 04:03:29 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-10-27 11:25:23 -0600

psammut gravatar image

For anyone searching to get started with robot_localization, here's some info.

Here's the main docs that you should read through:

Watch this video:

And here is the github repo that contains all the source including some examples:

The simplest example in this repo is called ekf_template, and it comprises two files:

Bing bam boom! It's actually not that hard to get it going, the hardest part is just putting it together cause there's no simple end to end getting started guide, so don't despair!

edit flag offensive delete link more

Question Tools



Asked: 2017-04-12 06:46:24 -0600

Seen: 7,986 times

Last updated: Oct 27 '17