foxy rviz2 robot inverse
I connect my real robot with rviz but when i drive forward by teleoperation in RVIZ2 it goes backwards. When I load the model everything loads with their respective xyz positions and looks good, I did a test with gazebo and the urdf model and it works fine. What I can be doing wrong?
I'm using ros2 version foxy
To teleoperate use ros2 run teleoptwistkeyboard teleoptwistkeyboard and using ros2 topic echo /diffcont/cmdvel_unstamped to see the speeds
If I press (i) the linear velocity is positive and my real robot's wheels are going in the right direction, if I press (m) the linear velocity is negative and my real robot is going in the right direction
Asked by rcarrasquel on 2023-04-29 20:28:14 UTC
Answers
These are the steps I currently do:
Step 1: ros2 launch robot_v1 launch_robot.launch.py
[INFO] [launch]: All log files can be found below /home/robot/.ros/log/2023-05-02-13-27-44-649625-robot-robotics-3679 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [robot_state_publisher-1]: process started with pid [3682] [robot_state_publisher-1] Parsing robot urdf xml string. [robot_state_publisher-1] Link base_footprint had 0 children [robot_state_publisher-1] Link chassis had 2 children [robot_state_publisher-1] Link caster_wheel had 0 children [robot_state_publisher-1] Link laser_frame had 0 children [robot_state_publisher-1] Link left_wheel had 0 children [robot_state_publisher-1] Link right_wheel had 0 children [robot_state_publisher-1] [INFO] [1683055665.594996677] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-1] [INFO] [1683055665.595316231] [robot_state_publisher]: got segment base_link [robot_state_publisher-1] [INFO] [1683055665.595373434] [robot_state_publisher]: got segment caster_wheel [robot_state_publisher-1] [INFO] [1683055665.595405527] [robot_state_publisher]: got segment chassis [robot_state_publisher-1] [INFO] [1683055665.595433879] [robot_state_publisher]: got segment laser_frame [robot_state_publisher-1] [INFO] [1683055665.595460582] [robot_state_publisher]: got segment left_wheel [robot_state_publisher-1] [INFO] [1683055665.595487638] [robot_state_publisher]: got segment right_wheel [INFO] [ros2_control_node-2]: process started with pid [3741] [INFO] [spawner.py-3]: process started with pid [3743] [INFO] [spawner.py-4]: process started with pid [3745] [ros2_control_node-2] [INFO] [1683055672.649939829] [DiffDriveArduino]: Configuring... [ros2_control_node-2] [INFO] [1683055672.653333161] [DiffDriveArduino]: Finished Configuration [ros2_control_node-2] [INFO] [1683055672.654237730] [DiffDriveArduino]: Starting Controller... [ros2_control_node-2] [INFO] [1683055674.688526246] [controller_manager]: update rate is 30 Hz [ros2_control_node-2] [INFO] [1683055674.742395358] [controller_manager]: Loading controller 'diff_cont' [ros2_control_node-2] [INFO] [1683055674.800070208] [controller_manager]: Loading controller 'joint_broad' [spawner.py-4] [INFO] [1683055674.877850256] [spawner_diff_cont]: Loaded diff_cont [ros2_control_node-2] [INFO] [1683055674.882897541] [controller_manager]: Configuring controller 'diff_cont' [spawner.py-3] [INFO] [1683055674.927954890] [spawner_joint_broad]: Loaded joint_broad [ros2_control_node-2] [INFO] [1683055674.961634361] [controller_manager]: Configuring controller 'joint_broad' [spawner.py-4] [INFO] [1683055674.969831147] [spawner_diff_cont]: Configured and started diff_cont [INFO] [spawner.py-4]: process has finished cleanly [pid 3745] [spawner.py-3] [INFO] [1683055675.127809748] [spawner_joint_broad]: Configured and started joint_broad [INFO] [spawner.py-3]: process has finished cleanly [pid 3743]
Step 2: launch rviz2
Step 3: launch ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=/diff_cont/cmd_vel_unstamped
Step 4: List my topics ros2 topic list
/diff_cont/cmd_vel_unstamped
/dynamic_joint_states /joint_states
/odom /parameter_events
/robot_description /rosout /tf
/tf_static
Step 5: Show velocity used with teleop ros2 topic echo /diff_cont/cmd_vel_unstamped linear: x: 0.5 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.0
Step 6: The big error is here ros2 topic echo /odom
header: stamp: sec: 1683055943 nanosec: 697278387 frame_id: odom child_frame_id: base_link pose: pose: position: x: -1.2107849808063793 y: -0.08094175530158954 z: 0.0 orientation: x: 0.0 y: 0.0 z: 0.06693663980673284 w: 0.9977572281128229 twist: twist: linear: x: -2.0595504468534641e-16 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 2.1163626406917045e-17
Now I don't know how to solve this part. The wheels of my robot go in the correct direction when using the teleoperation from the keyboard and in gazebo it works well. Now, I have noticed that on some occasions the linear velocity in twist appears as positive but the position in pose appears in negative. I have changed the orientation of the axes and I think the problem is worse, because the wheels rotate in the opposite direction but the robot's pose always goes negative on the x axis if I want to move forward
Asked by rcarrasquel on 2023-05-02 14:53:39 UTC
Comments
It sounds like whatever is publishing your odometry is configured incorrectly, but its difficult to say without more information. when you say "it goes backwards" in RViz, what is "it"? Are you visualizing a robot model? are you looking at the tf frames of your wheels?
The first place I would suggest looking is that your wheel frames are spinning the correct direction in RViz when a fwd velocity command is input. If not, you may just need to flip the direction of the axis on your wheel joints. If have a hunch that's not it, since it "works well in Gazebo". If that's not the issue, I'd suggest updating your question with more details on your odometry source, so people can potentially help you identify the issue.
Asked by shonigmann on 2023-05-01 10:29:05 UTC
Thank you for your comments, I did some that you commented but I'm still in trouble
Asked by rcarrasquel on 2023-05-02 14:54:43 UTC