hardware interface odometry
I'm getting a bit confused about the odometry when using a hardware_interface with diff_drive_controller
In the hardware interface i'm reading the wheel encoder data and update the joint position & velocity of the wheels. When i'm looking at the published topics i have ampru_velocity_controller/odom which seem to publish some data when driving the robot.
But when i look in rviz, the odom always remains at the start position. I already tried to remap the ampru_vecolicity_controller/odom to odom, but this does not make any difference.
So how can i get correct odometry data being publisher to see the odom tf move in rviz?
Edit:
I have tried this, but seems to make no difference.
ampru_joint_publisher:
type : "joint_state_controller/JointStateController"
publish_rate : 50
ampru_velocity_controller:
type : "diff_drive_controller/DiffDriveController"
publish_rate : 50
left_wheel : 'front_left_wheel_joint'
right_wheel : 'front_right_wheel_joint'
pose_covariance_diagonal : [0.001, 0.001, 1000000.0, 1000000.0, 1000000.0, 1000.0]
twist_covariance_diagonal : [0.001, 0.001, 1000000.0, 1000000.0, 1000000.0, 1000.0]
# Velocity commands timeout
cmd_vel_timeout: 0.25
# Base frame_id
base_frame_id: base_link
# Odometry fused with IMU is published by robot_localization, so
# no need to publish a TF based on encoders alone.
enable_odom_tf: true
# Velocity and acceleration limits
linear:
x:
has_velocity_limits : true
max_velocity : 2.0 # m/s
has_acceleration_limits : true
max_acceleration : 20.0 # m/s^2
angular:
z:
has_velocity_limits : true
max_velocity : 4.0 # rad/s
has_acceleration_limits : true
max_acceleration : 25.0 # rad/s^2
So maybe there is something wrong with setting the joint state?
auto wheelEncoderData = (WheelEncoderData*)_serialPort.waitMessage(WheelEncoderData::MESSAGE_TYPE, 1.0);
if (wheelEncoderData != NULL)
{
double distance_left = (wheelEncoderData->getLeftPulses() * ((_wheel_diameter * M_PI) / _wheel_encoder_pulses));
double distance_right = (wheelEncoderData->getRightPulses() * ((_wheel_diameter * M_PI) / _wheel_encoder_pulses));
_pos[0] += linearToAngular(distance_left);
_vel[0] += linearToAngular(distance_left / period.toSec());
_pos[1] += linearToAngular(distance_right);
_vel[1] += linearToAngular(distance_right / period.toSec());
}
Full code: https://github.com/DeborggraeveR/ampru
@RandyD: please don't post answers unless you are answering your own questions. For interacting with other posters, please use comments. For updates -- ie things you tried, new info -- please edit your original questions. Use the
edit
button/link for that.Thanks.
If the indentation you have in your updated answer is the one in your yaml file / launch file then it could be that some parameters aren't getting loaded in the correct namespace. Compare the formatting with @ufr3c_tjc's answer.
made some changes to the robot today, and due to a minor error, i got global errors in rviz saying i had no odom frame, so i fixed the issue (enable_odom_tf = false, added robot_localization)
if u check the odom frame in the tf tree, should it move with the robot or should it just stay in place?
Odom is a world fixed frame, meaning it stays still w.r.t the world and the robot moves within it. However, if running a second instance of robot_localization with GPS, and using the map frame (as they suggest) then the odom frame will have a non-zero transform to map, but it is still world fixed.
Great tnx :) So i was trying to make something work that was already working, tought the odom frame had to move with the robot, so it was a misunderstanding from me :(