These are the steps I currently do:
Step 1: ros2 launch robot_v1 launch_robot.launch.py
[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
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
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.
Thank you for your comments, I did some that you commented but I'm still in trouble