RoverRobotics-archive / roverrobotics_ros2

Packages for running an OpenRover robot on ROS2
30 stars 11 forks source link

Odometry using periods instead of encoder positions #17

Open laszloturanyi opened 3 years ago

laszloturanyi commented 3 years ago

Hi, I am experiencing with the odometry, however the poses calculated from the raw odometry are not so accurate. (much worse than the ROS1 stack filtered /rr_openrover_stack/odometry_encoder)

in rove.cpp (foxy branch) I found the following:

  // Determine encoder frequency.
  // earlier versions of the firmware don't return the encoder position so we
  // have to make do with the period estimate
  Eigen::Vector2d encoder_frequency_lr;
  if (left_encoder_position->state == 0 && right_encoder_position->state == 0) {
    encoder_frequency_lr = {((left_period->state == 0) ? 0 : 1.0 / (left_period->state)),
                            ((right_period->state == 0) ? 0 : 1.0 / (right_period->state))};
    if (!left_wheel_fwd) {
      encoder_frequency_lr[0] *= -1;
    }
    if (!right_wheel_fwd) {
      encoder_frequency_lr[1] *= -1;
    }
    // ^ the encoder doesn't actually have the wheel direction. So we fake it by
    // assuming the same direction as the last commanded direction we gave to
    // the wheel
  } else {
    encoder_frequency_lr = {
      int16_t(left_encoder_position->state - odom_last_encoder_position_left) / dt,
      int16_t(right_encoder_position->state - odom_last_encoder_position_right) / dt};
    // ^ remember these values are signed. But taking the difference a-b as
    // signed ints will give either a-b or 1<<16 - a-b, whichever has the lower
    // absolute value. This is exactly what we want.
  }

It seems that I do not have encoder positions. How can I update to a newer firmware? I have installed the roverpro-python tool with pip, however it raises an erro when starting with

pitstop--help
    class Outcome(ABC):
  File "/home/rover/.local/lib/python3.6/site-packages/outcome/_sync.py", line 43, in Outcome
    _unwrapped = attr.ib(default=False, eq=False, init=False)
TypeError: attrib() got an unexpected keyword argument 'eq'

Regards,
Laszlo