Skip to content

Commit f784bff

Browse files
committed
run with standard twist_mux, diff_drive, use TwistStamped everywhere
1 parent ce02787 commit f784bff

File tree

8 files changed

+55
-139
lines changed

8 files changed

+55
-139
lines changed

curt_mini/bringup/joystick.launch.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def launch_joystick(context, *args, **kwargs):
1313
filepath_config_joy = os.path.join(
1414
get_package_share_directory(robot), "config", "joystick.yaml"
1515
)
16-
print(filepath_config_joy)
16+
1717
node_joy = Node(
1818
namespace="joy_teleop",
1919
package="joy_linux",
@@ -29,9 +29,6 @@ def launch_joystick(context, *args, **kwargs):
2929
executable="teleop_node",
3030
output="screen",
3131
name="teleop_twist_joy_node",
32-
# remappings=[
33-
# ('/joy_teleop/cmd_vel', '/diff_drive_controller/cmd_vel_unstamped')
34-
# ],
3532
parameters=[filepath_config_joy],
3633
)
3734

curt_mini/bringup/robot_base.launch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ def launch_robot():
101101
"topic",
102102
"pub",
103103
"--rate",
104-
"50",
104+
"20",
105105
"--print",
106106
"0",
107107
"/zero_twist/cmd_vel",
108-
"geometry_msgs/msg/Twist",
108+
"geometry_msgs/msg/TwistStamped",
109+
"{header: {stamp: now, frame_id: 'base_link'}}",
109110
],
110111
)
111112

curt_mini/bringup/start_controller.launch.py

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,42 @@
11
from launch import LaunchDescription
2-
from launch.actions import DeclareLaunchArgument
3-
import launch.substitution
42
from launch_ros.actions import Node
53
from launch_ros.substitutions import FindPackageShare
64
from launch.substitutions import PathJoinSubstitution
7-
from launch_ros.parameter_descriptions import ParameterFile
8-
import typing
9-
10-
11-
class ResultingParameterFilePath(launch.substitution.Substitution):
12-
"""
13-
Substitution which resolves to the path of the temporary file created by ParameterFile
14-
"""
15-
16-
def __init__(self, parameter_file: ParameterFile) -> None:
17-
super().__init__()
18-
self.__parameter_file = parameter_file
19-
20-
def perform(self, context: launch.launch_context.LaunchContext) -> typing.Text:
21-
return self.__parameter_file.evaluate(context).absolute().as_posix()
225

236

247
def generate_launch_description():
258

26-
param_file = ResultingParameterFilePath(
27-
ParameterFile(
28-
PathJoinSubstitution(
29-
[FindPackageShare("curt_mini"), "config", "ros2_control.yaml"]
30-
),
31-
allow_substs=True,
32-
)
9+
param_file = PathJoinSubstitution(
10+
[FindPackageShare("curt_mini"), "config", "ros2_control.yaml"]
3311
)
3412

3513
robot_controller_spawner = Node(
3614
package="controller_manager",
3715
executable="spawner",
38-
arguments=["--param-file", param_file, "skid_steer_controller"],
16+
arguments=[
17+
"--param-file",
18+
param_file,
19+
"--controller-ros-args",
20+
"-r diff_drive_controller/odom:=/odometry/wheel",
21+
"diff_drive_controller",
22+
],
3923
output="screen",
4024
remappings=[("odom", "odometry/wheel")],
4125
)
4226

4327
joint_state_broadcaster_spawner = Node(
4428
package="controller_manager",
4529
executable="spawner",
46-
arguments=["--param-file", param_file, "joint_state_broadcaster"],
30+
arguments=[
31+
"--param-file",
32+
param_file,
33+
"joint_state_broadcaster",
34+
],
4735
output="screen",
48-
remappings=[("odom", "odometry/wheel")],
49-
)
50-
51-
odom_topic_argument = DeclareLaunchArgument(
52-
"odom_topic",
53-
default_value="/odometry/imu",
54-
description="Odometry topic used as feedback for closed loop angular twist base controller",
5536
)
5637

5738
return LaunchDescription(
5839
[
59-
odom_topic_argument,
6040
joint_state_broadcaster_spawner,
6141
robot_controller_spawner,
6242
]

curt_mini/config/joystick.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ joy_teleop/teleop_twist_joy_node:
5757
yaw: 3.6
5858
enable_button: 4
5959
enable_turbo_button: 5
60+
publish_stamped_twist: true
6061
joy_teleop/joy_node:
6162
ros__parameters:
6263
deadzone: 0.1

curt_mini/config/ros2_control.yaml

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ controller_manager:
33
update_rate: 100
44
use_sim_time: false
55

6-
skid_steer_controller:
7-
type: skid_steer_controller/SkidSteerController
6+
diff_drive_controller:
7+
type: diff_drive_controller/DiffDriveController
88

99
joint_state_broadcaster:
1010
type: joint_state_broadcaster/JointStateBroadcaster
@@ -13,69 +13,45 @@ joint_state_broadcaster:
1313
ros__parameters:
1414
use_sim_time: false
1515

16-
skid_steer_controller:
16+
diff_drive_controller:
1717
ros__parameters:
18-
use_sim_time: false
19-
2018
left_wheel_names: ["front_left_motor", "back_left_motor"]
2119
right_wheel_names: ["front_right_motor", "back_right_motor"]
2220

2321
wheel_separation: 0.44
24-
wheels_per_side: 1 # actually 2, but both are controlled by 1 signal
2522
wheel_radius: 0.13
2623

2724
wheel_separation_multiplier: 1.0
28-
right_wheel_radius_multiplier: 1.0
2925
left_wheel_radius_multiplier: 1.0
26+
right_wheel_radius_multiplier: 1.0
3027

31-
publish_rate: 50.0
3228
odom_frame_id: odom
3329
base_frame_id: base_link
30+
pose_covariance_diagonal: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
31+
twist_covariance_diagonal: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
3432

33+
position_feedback: true
3534
open_loop: false
3635
enable_odom_tf: false
3736

38-
cmd_vel_timeout: 0.25
39-
#publish_limited_velocity: true
40-
use_stamped_vel: false
41-
#velocity_rolling_window_size: 10
42-
43-
# Preserve turning radius when limiting speed/acceleration/jerk
44-
preserve_turning_radius: true
45-
46-
# Publish limited velocity
47-
publish_cmd: true
37+
cmd_vel_timeout: 0.25 # seconds
38+
publish_limited_velocity: true
39+
velocity_rolling_window_size: 10
4840

49-
# Publish wheel data
50-
publish_wheel_data: true
51-
52-
linear.x.has_velocity_limits: true
53-
linear.x.min_velocity: -1.5
5441
linear.x.max_velocity: 1.5
55-
linear.x.has_acceleration_limits: true
56-
linear.x.min_acceleration: -2.5
42+
linear.x.min_velocity: -1.5
5743
linear.x.max_acceleration: 2.5
44+
linear.x.max_deceleration: -2.5
45+
linear.x.max_acceleration_reverse: 2.5
46+
linear.x.max_deceleration_reverse: -2.5
47+
linear.x.max_jerk: .NAN
48+
linear.x.min_jerk: .NAN
5849

59-
angular.z.has_velocity_limits: true
60-
angular.z.min_velocity: -12.0
6150
angular.z.max_velocity: 12.0
62-
angular.z.has_acceleration_limits: true
63-
angular.z.min_acceleration: -15.0
51+
angular.z.min_velocity: -12.0
6452
angular.z.max_acceleration: 15.0
65-
66-
angular_vel_pid.p: 0.0
67-
angular_vel_pid.i: 1.0
68-
angular_vel_pid.d: 0.0
69-
angular_vel_pid.i_clamp_max: 0.7
70-
angular_vel_pid.i_clamp_min: -0.7
71-
angular_vel_pid.antiwindup: true
72-
angular_vel_pid.max_time_diff: 1.0
73-
control_loop_odometry_topic: "$(var odom_topic)"
74-
filter_odometry: true
75-
cut_off_frequency: 0.5
76-
linear_vel_pid.p: 0.0
77-
linear_vel_pid.i: 0.5
78-
linear_vel_pid.d: 0.0
79-
linear_vel_pid.i_clamp_max: 0.5
80-
linear_vel_pid.i_clamp_min: -0.5
81-
linear_vel_pid.antiwindup: true
53+
angular.z.max_deceleration: -15.0
54+
angular.z.max_acceleration_reverse: 15.0
55+
angular.z.max_deceleration_reverse: -15.0
56+
angular.z.max_jerk: .NAN
57+
angular.z.min_jerk: .NAN

curt_mini/config/twist_mux.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
twist_mux:
22
ros__parameters:
3-
output_stamped: false
3+
use_stamped: true
44
topics:
55
navigation:
66
topic: cmd_vel
77
priority: 20
88
timeout: 0.1
9-
stamped : false
109
joystick:
1110
topic: joy_teleop/cmd_vel
1211
priority: 50
1312
timeout: 0.1
14-
stamped : false
1513
zero_twist:
1614
topic: zero_twist/cmd_vel
1715
priority: 10
1816
timeout: 0.1
19-
stamped : false

curt_mini/package.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@
1515
<depend>robot_state_publisher</depend>
1616
<depend>rclcpp</depend>
1717
<depend>rclpy</depend>
18-
<depend>velodyne_description</depend>
19-
<depend>velodyne</depend>
2018
<depend>xacro</depend>
21-
<depend>ouster_ros</depend>
22-
<depend>realsense2_camera</depend>
23-
<depend>livox_ros2_driver</depend>
24-
<depend>rslidar_sdk</depend>
19+
<exec_depend>twist_mux</exec_depend>
2520

2621
<test_depend>ament_lint_auto</test_depend>
2722
<test_depend>ament_lint_common</test_depend>

ipa_ros2_control/launch/ros2_control.launch.py

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@
88
from launch_ros.actions import Node
99
from launch.actions import OpaqueFunction
1010

11+
1112
def launch_ros2_control(context, *args, **kwargs):
1213
# initialize arguments
13-
robot = LaunchConfiguration('robot')
14-
gear_ratio = LaunchConfiguration('gear_ratio')
15-
interface = LaunchConfiguration('interface')
14+
robot = "curt_mini"
1615

17-
robot_dir = get_package_share_directory(robot.perform(context))
18-
19-
ros2_control_yaml_path = os.path.join(robot_dir, 'config', 'ros2_control.yaml')
16+
robot_dir = get_package_share_directory(robot)
2017

21-
urdf_path = os.path.join(robot_dir, 'models', robot.perform(context), 'robot.urdf.xacro')
18+
ros2_control_yaml_path = os.path.join(robot_dir, "config", "ros2_control.yaml")
2219

23-
robot_description = Command(['xacro ', urdf_path, ' gear_ratio:=', gear_ratio, ' interface:=', interface])
24-
2520
controller_manager_node = Node(
26-
package='controller_manager',
27-
executable='ros2_control_node',
21+
package="controller_manager",
22+
executable="ros2_control_node",
2823
parameters=[
2924
ros2_control_yaml_path,
3025
],
@@ -35,47 +30,21 @@ def launch_ros2_control(context, *args, **kwargs):
3530
)
3631

3732
md80_manager_node = Node(
38-
package='candle_ros2',
39-
executable='candle_ros2_node',
33+
package="candle_ros2",
34+
executable="candle_ros2_node",
4035
output={
4136
"stdout": "screen",
4237
"stderr": "screen",
4338
},
4439
arguments=["USB", "1M"],
4540
)
46-
return [controller_manager_node,
47-
md80_manager_node]
41+
return [controller_manager_node, md80_manager_node]
42+
4843

4944
def generate_launch_description():
5045

5146
declared_arguments = []
5247

53-
# robot argument
54-
declared_arguments.append(
55-
DeclareLaunchArgument(
56-
'robot',
57-
default_value='curt_mini',
58-
description="Set the robot.",
59-
choices=['curt_mvp', 'curt_mini'],
60-
)
61-
)
62-
63-
# set the interface for the ethercat communication
64-
declared_arguments.append(
65-
DeclareLaunchArgument(
66-
'interface',
67-
default_value='enp0s31f6',
68-
description='Ethercat interface to the motor controllers',
69-
)
48+
return LaunchDescription(
49+
declared_arguments + [OpaqueFunction(function=launch_ros2_control)]
7050
)
71-
72-
# set the gear_ratio
73-
declared_arguments.append(
74-
DeclareLaunchArgument(
75-
'gear_ratio',
76-
default_value='1',
77-
description='Set the gear ratio of the motors',
78-
)
79-
)
80-
81-
return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_ros2_control)])

0 commit comments

Comments
 (0)