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

hardware interface odometry

asked 2017-06-20 16:37:16 -0600

RandyD gravatar image

updated 2017-06-21 02:06:08 -0600

gvdhoorn gravatar image

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

edit retag flag offensive close merge delete

Comments

@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.

gvdhoorn gravatar image gvdhoorn  ( 2017-06-21 02:07:37 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2017-06-21 02:24:00 -0600 )edit

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?

RandyD gravatar image RandyD  ( 2017-06-21 16:48:47 -0600 )edit

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.

ufr3c_tjc gravatar image ufr3c_tjc  ( 2017-06-21 17:45:21 -0600 )edit

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 :(

RandyD gravatar image RandyD  ( 2017-06-22 02:05:26 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-06-20 17:29:28 -0600

ufr3c_tjc gravatar image

You need to make sure that the enable_odom_tf parameter is set to true for your controller. Then, as long as rviz has the fixed frame as odom, it will move. See appropriate YAML file below:

tracks_diff_drive_controller:
  type: diff_drive_controller/DiffDriveController
  left_wheel: base_to_wheelleft
  right_wheel: base_to_wheelright
  publish_rate: 10
  base_frame_id: base_footprint
  wheel_separation: 1.27
  wheel_radius: 0.22
  enable_odom_tf: true
  pose_covariance_diagonal: [0.001, 0.001, 1000000.0, 1000000.0, 1000000.0, 0.03]
  twist_covariance_diagonal: [0.001, 0.001, 1000000.0, 1000000.0, 1000000.0, 0.03]
  linear:
    x:
      has_velocity_limits    : true
      max_velocity           : 1.28   # m/s
      has_acceleration_limits: true
      max_acceleration       : 3.0   # m/s^2
  angular:
    z:
      has_velocity_limits    : true
      max_velocity           : 0.5   # rad/s
      has_acceleration_limits: true
      max_acceleration       : 1.0   # rad/s^2
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-06-20 16:37:16 -0600

Seen: 1,115 times

Last updated: Jun 21 '17