I am trying to make a diff drive robot. I am using esp32 with microros_arduino. I have successfully created cmd_vel subscriber, left_motor_encoder, and right_motor_encoder publisher topics in esp32. And also successfully connected with the PC over wifi network. I am using my PC as a microprocessor instead of Raspberry Pi or Jetson.
The issue is that I am stuck at the diff drive ros2_control interface. I am using this pkg. When i launch this file, rviz2 simulation appears, and when I move the robot via cmd_vel. It moves but the wheels does not rotate. wheel position does not change in /joint_state topic, But the velocity changes.
Furthermore, i am unable to configure how can i interface my actual robot (not just simulation). How can I use encoder information with ros2 diff drive control. Your guidance is needed.
here are some codes related to the ros2_control.
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare
def generate_launch_description():
arg_show_rviz = DeclareLaunchArgument(
"start_rviz",
default_value="false",
description="start RViz automatically with the launch file",
)
# Get URDF via xacro
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[FindPackageShare("diffbot_description"), "urdf", "diffbot_system.urdf.xacro"]
),
]
)
robot_description = {"robot_description": robot_description_content}
diffbot_diff_drive_controller = PathJoinSubstitution(
[
FindPackageShare("ros2_control_demo_bringup"),
"config",
"diffbot_diff_drive_controller.yaml",
]
)
node_robot_state_publisher = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="screen",
parameters=[robot_description],
)
controller_manager_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_description, diffbot_diff_drive_controller],
output={
"stdout": "screen",
"stderr": "screen",
},
)
spawn_dd_controller = Node(
package="controller_manager",
executable="spawner.py",
arguments=["diffbot_base_controller"],
output="screen",
)
spawn_jsb_controller = Node(
package="controller_manager",
executable="spawner.py",
arguments=["joint_state_broadcaster"],
output="screen",
)
rviz_config_file = PathJoinSubstitution(
[FindPackageShare("diffbot_description"), "config", "diffbot.rviz"]
)
rviz_node = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
arguments=["-d", rviz_config_file],
#condition=IfCondition(LaunchConfiguration("start_rviz")), I just commented this
)
return LaunchDescription(
[
arg_show_rviz,
node_robot_state_publisher,
controller_manager_node,
spawn_dd_controller,
spawn_jsb_controller,
rviz_node,
]
)
and other files are same exatly as given in pkg.