how do i add barometer and gps data to robot localization?

asked 2020-10-04 09:40:48 -0500

MisticFury gravatar image

updated 2020-10-04 11:01:01 -0500

im trying to build out the odometry for a drone and so far i got the imu fed in. but i can't figure out how to feed in the barometer(Altitude) and gps or the format they should be in. i tried reading thru the robot localization documentation but i just couldn't make sense of it. down below is the launch file im working with.


<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="drone_link"/>
  <param name="world_frame" value="odom"/>

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

  <rosparam param="odom0_config">[true,  true,  true, 
                                  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 ARRAY with small values]</rosparam>

  <rosparam param="initial_estimate_covariance">[LARGE ARRAY with 1e-9]</rosparam>

edit retag flag offensive close merge delete


What could you not make sense of? What make barometer different than imu data?

JackB gravatar image JackB  ( 2020-10-04 10:09:56 -0500 )edit

my imu sensor has an accelerometer, gyro, and compass, with that i got the acceleration, angular velocity and orientation. the barometer will only give me altitude

MisticFury gravatar image MisticFury  ( 2020-10-04 11:00:03 -0500 )edit

What is the topic type? Odom/pose/imu or some custom data type from the barometer?

JackB gravatar image JackB  ( 2020-10-04 11:03:41 -0500 )edit

at the moment i just have the raw barometer data converted to meters. i don't know the exact topic type i should publish it as to feed it into the localization node

MisticFury gravatar image MisticFury  ( 2020-10-04 11:25:54 -0500 )edit

Publish your barometer message as one of these types and integrating it should be natural, just like you did your imu or odom.

JackB gravatar image JackB  ( 2020-10-04 11:44:00 -0500 )edit

thats where im stuck at i don't quite follow how the barometer should be publish and what should the param for it be? i can't find any explanation or example of integrating altitude.

MisticFury gravatar image MisticFury  ( 2020-10-04 12:11:10 -0500 )edit

Not knowing how to publish a message with the correct type is more fundamental than robot_localization. Check out c++ pub/sub or the equivalent tutorials in python.

JackB gravatar image JackB  ( 2020-10-04 12:13:55 -0500 )edit

it's not that, i don't now the format the altitude should be publish as. for example, for my imu i used sensor_msg.msg imu to setup the msg and published the imu.

this is where i setup the msg from my imu sensor then i published the msg

def sensor_calc():
msg.orientation.x = quan[0]
msg.orientation.y = quan[1]
msg.orientation.z = quan[2]
msg.orientation.w = quan[3]
msg.angular_velocity.x = angl_speed[0]
msg.angular_velocity.y = angl_speed[1]
msg.angular_velocity.z = angl_speed[2]
msg.linear_acceleration.x = ((accel[0])/acc_cal) * 9.81
msg.linear_acceleration.y = ((accel[1])/acc_cal) * 9.81
msg.linear_acceleration.z = ((accel[2])/acc_cal) * 9.81

def publisher_imu():
pub_imu = rospy.Publisher('/imu/data', Imu, queue_size=0)
imu_rate = rospy.Rate(4)
while not rospy.is_shutdown():
    msg.header.stamp =
MisticFury gravatar image MisticFury  ( 2020-10-04 12:30:12 -0500 )edit