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

Robot rotates angularly in rviz when linealy accelerated using teleop

asked 2018-03-25 07:39:56 -0500

kilovolt gravatar image

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

edit retag flag offensive close merge delete

Comments

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.

Humpelstilzchen gravatar image Humpelstilzchen  ( 2018-03-26 03:10:11 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-03-31 01:56:33 -0500

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.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-03-25 07:39:56 -0500

Seen: 212 times

Last updated: Mar 31 '18