0
$\begingroup$

Rosanswers logo

Hi, I am new to ros. I'm trying to implement gmapping on my custom robot. I am in the initial stage and using ros_arduino_bridge to publish the odometry and control the motors. I have used teleop_twist_keyboard to manually navigate the real robot. While doing so, if I linearly move the robot, the robot rotates angularly in rviz,i.e when real robot moves forward, robot model in rviz rotates left. Similarly, when real robot moves in reverse, robot model in rviz rotates right.So I assume that the linear and angular motion are inverted in rviz and real motion. Where would be the probable mistake? How to rectify it?

Here is the odom data published:

header: 
  seq: 1110
  stamp: 
    secs: 1521979250
    nsecs: 547859907
  frame_id: "odom"
child_frame_id: "base_link"
pose: 
  pose: 
    position: 
      x: -0.0323011953631
      y: 0.131932086548
      z: 0.0
    orientation: 
      x: 0.0
      y: 0.0
      z: -0.668663666459
      w: -0.743564994575
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
twist: 
  twist: 
    linear: 
      x: 0.0
      y: 0.0
      z: 0.0
    angular: 
      x: 0.0
      y: 0.0
      z: 0.0
  covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
---
header: 
  seq: 1111
  stamp: 
    secs: 1521979250
    nsecs: 663502931
  frame_id: "odom"
child_frame_id: "base_link"
pose: 
  pose: 
    position: 
      x: -0.0323011953631
      y: 0.131932086548

If any other data is needed, please let me know. Thanks in advance. z: 0.0


Originally posted by kilovolt on ROS Answers with karma: 3 on 2018-03-25

Post score: 0


Original comments

Comment by Humpelstilzchen on 2018-03-26:
The tf from odom to base_link is used by rviz, not the odom topic. More information is needed, e.g. where the tf is generated.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hello, I faced the same problem earlier and I could solve the same by manipulating the signs of the encoder and thus getting proper direction reflected. That is for the robot moving forward, both the encoders must have the same positive sign and increment. Similarly for rotation the clockwise rotation will have left encoder positive and right encoder negative and vice versa. If your are using ros_arduino_bridge try changing the signs of the encoder data in the encoder_driver file. It looks something like this

long readEncoder(int i) {
    if (i == LEFT) 0-return left_enc_pos;
    else return right_enc_pos;
  }

For example change the 0-return left_enc_pos to return left_enc_pos and try to match the convention for encoder as stated above.


Originally posted by ashikmh14 with karma: 41 on 2018-03-31

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.