Odometry msg from wheel speed for Ackerman steering
We have a real car in our lab for autonomous car research. I used the following equations to get the odometry msg in the gazebo simulation. The twist part of the odometry msg works fine since it is directly extracted from the wheel speed. But the pose part is not working, especially the Y position. When I drive straight to X axis, Y is not supposed to change. But it is changing. So, when I return to the first place, Y value differs significantly.
LenghtBetweenTwoWheels=1.58
vx= (vR + vL)/ 2.0
v_th=(vR - vL)/ LenghtBetweenTwoWheels
vy = 0.0
dt = (current_time - last_time).to_sec()
delta_x = (vx * cos(v_th) - vy * sin(v_th)) * dt
delta_y = (vx * sin(v_th) + vy * cos(v_th)) * dt
delta_th = v_th * dt
x += delta_x
y += delta_y
th += delta_th
odom_quat = tf.transformations.quaternion_from_euler(0, 0, th)
odomMsg.twist.twist.linear.x = vx
odomMsg.twist.twist.linear.y = vy
odomMsg.twist.twist.angular.z = v_th
odomMsg.header.frame_id = 'odom'
odomMsg.child_frame_id = 'base_footprint'
Is there any way I can solve this problem? Or can I just use a geometry twist msg instead of full odometry and fuse that with the IMU msg to get the full odometry msg using the robot localization
pkg? In that case, what should be the "odom"
frame in the config file since there is no current odometry msg? I do not have a map for now. My config file looks like this:
# Complete the frames section
odom_frame: odom
base_link_frame: base_link
world_frame: odom
map_frame: map
# Complete the odom0 configuration
odom0: /odom
odom0_config: [false, false, false,
false, false, false,
true, true, false,v
false, false, false,]
odom0_differential: false
# Complete the imu0 configuration
imu0: /vehicle/imu/data_raw
imu0_config: [false, false, false,
false, false, false,
false, false, false,
false, false, true,
true, false, false,]
imu0_differential: false
Edit 1: Here is the equation I used and got accurate results.
v_th = vx* tan(steering_wheel_angle/ steering_ratio) / distance_between_front_and_rear_axle
These equations you use are for a two-wheel differential drive robot, where the robot's center of rotation is between the two wheels. Your robot violates both assumptions. These are not the correct equations for a four-wheel ackerman configuration.
@Mike Scheutzow Where can I find equations for the Ackerman steering?
You can easily find the equations with a web search.
Hey quick question I saw you edit about the v_th equation, but I'm still having trouble calculating the odometry for an ackermann vehicle, do you still have the complete code by any chance ?