Skip to content

Commit 430a084

Browse files
committed
add Prof. Cui's chassis
1 parent 1a3dfe5 commit 430a084

File tree

3 files changed

+226
-0
lines changed

3 files changed

+226
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0"?>
2+
<robot name="standard" xmlns:xacro="http://www.ros.org/wiki/xacro">
3+
4+
<xacro:arg name="is_simulation" default="true" />
5+
6+
<link name="base_footprint">
7+
</link>
8+
9+
<!-- raise the robot a bit higher to prevent it from stucking in the ground -->
10+
<joint name="joint_base_to_footprint" type="fixed">
11+
<origin rpy="0 0 0" xyz="0 0 1" />
12+
<parent link="base_footprint" />
13+
<child link="base_link" />
14+
</joint>
15+
<xacro:include filename="$(find metav_description)/urdf/standard/standard.chassis.xacro" />
16+
17+
<xacro:chassis roller_type="none" />
18+
<ros2_control name="dji_motors_chassis" type="system">
19+
<hardware>
20+
<plugin>meta_hardware/MetaRobotDjiMotorNetwork</plugin>
21+
<param name="can_network_name">can0</param>
22+
</hardware>
23+
<xacro:wheel_transmission prefix="front_left" mechanical_reduction="20.0" motor_id="2" />
24+
<xacro:wheel_transmission prefix="front_right" mechanical_reduction="20.0" motor_id="1" />
25+
<xacro:wheel_transmission prefix="back_left" mechanical_reduction="20.0" motor_id="3" />
26+
<xacro:wheel_transmission prefix="back_right" mechanical_reduction="20.0" motor_id="4" />
27+
<xacro:wheel_transmission prefix="dummy_yaw" mechanical_reduction="36.0" motor_id="5" />
28+
</ros2_control>
29+
30+
</robot>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# ported from hero
2+
controller_manager:
3+
ros__parameters:
4+
update_rate: 200 # Hz
5+
6+
omni_chassis_controller:
7+
type: meta_chassis_controller/OmniChassisController
8+
9+
wheels_pid_controller:
10+
type: pid_controller/PidController
11+
12+
joint_state_broadcaster:
13+
type: joint_state_broadcaster/JointStateBroadcaster
14+
15+
omni_chassis_controller:
16+
ros__parameters:
17+
omni_wheel_joints:
18+
- wheels_pid_controller/front_left_wheel_joint
19+
- wheels_pid_controller/front_right_wheel_joint
20+
- wheels_pid_controller/back_left_wheel_joint
21+
- wheels_pid_controller/back_right_wheel_joint
22+
23+
omni_wheel_forward_angles: [0.0, 180.0, 0.0, 180.0]
24+
25+
omni_wheel_center_x: [0.2, 0.2, -0.2, -0.2]
26+
omni_wheel_center_y: [0.2, -0.2, 0.2, -0.2]
27+
28+
omni_wheel_sliding_angles: [-45.0, 45.0, 45.0, -45.0]
29+
30+
omni_wheel_radius: 0.076
31+
32+
control_mode: 0
33+
34+
yaw_gimbal_joint: dummy_yaw_wheel_joint
35+
36+
follow_pid_gains:
37+
{ p: 4.0, i: 2.0e-1, d: 0.0, i_clamp_max: 3.0, i_clamp_min: -3.0, antiwindup: true }
38+
39+
follow_pid_target: 0.0
40+
41+
reference_timeout: 0.2
42+
43+
wheels_pid_controller:
44+
ros__parameters:
45+
dof_names:
46+
- front_left_wheel_joint
47+
- front_right_wheel_joint
48+
- back_left_wheel_joint
49+
- back_right_wheel_joint
50+
51+
command_interface: effort
52+
53+
reference_and_state_interfaces: ["velocity"]
54+
55+
gains:
56+
front_left_wheel_joint:
57+
{ p: 2.0e-2, i: 1.0e-4, d: 0.0, i_clamp_max: 1.0, i_clamp_min: -1.0, antiwindup: true }
58+
front_right_wheel_joint:
59+
{ p: 2.0e-2, i: 1.0e-4, d: 0.0, i_clamp_max: 1.0, i_clamp_min: -1.0, antiwindup: true }
60+
back_left_wheel_joint:
61+
{ p: 2.0e-2, i: 1.0e-4, d: 0.0, i_clamp_max: 1.0, i_clamp_min: -1.0, antiwindup: true }
62+
back_right_wheel_joint:
63+
{ p: 2.0e-2, i: 1.0e-4, d: 0.0, i_clamp_max: 1.0, i_clamp_min: -1.0, antiwindup: true }
64+
65+
dbus_control_node:
66+
ros__parameters:
67+
dbus_port: "ttyUSB0"
68+
69+
hero_vehicle:
70+
ros__parameters:
71+
enable_ros2_control: true
72+
aim_topic: "/gimbal_position_controller/reference"
73+
shoot_topic: "/shoot_controller/reference"
74+
control:
75+
trans_vel: 2.5 # m/s
76+
rot_vel: 3.0 # rad/s
77+
stick_sens: 5.00 # rad/s
78+
mouse_sens: 10.0
79+
deadzone: 0.3 # percentage
80+
video_link_blank_time: 0.05 # second

meta_bringup/launch/cjh_chassis.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Copyright 2021 Open Source Robotics Foundation, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
from launch import LaunchDescription
17+
from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
18+
from launch.launch_description_sources import PythonLaunchDescriptionSource
19+
from launch.substitutions import Command, FindExecutable, LaunchConfiguration, PathJoinSubstitution
20+
from launch.conditions import IfCondition, UnlessCondition
21+
22+
from launch_ros.actions import Node
23+
from launch_ros.substitutions import FindPackageShare
24+
25+
# Necessary dirty work that lets us import modules from the meta_bringup package
26+
import os
27+
import sys
28+
from ament_index_python.packages import get_package_share_directory
29+
sys.path.append(os.path.join(get_package_share_directory('meta_bringup'), 'launch'))
30+
31+
from launch_utils import load_controller, register_loading_order, register_sequential_loading
32+
33+
ARGUMENTS = [
34+
DeclareLaunchArgument(
35+
'enable_simulation',
36+
default_value='false',
37+
description='If true, the simulation will be started'),
38+
]
39+
40+
def generate_launch_description():
41+
# Launch Arguments
42+
enable_simulation = LaunchConfiguration('enable_simulation')
43+
44+
# Get URDF via xacro
45+
robot_description_content = Command([
46+
PathJoinSubstitution([FindExecutable(name='xacro')]),
47+
' ',
48+
PathJoinSubstitution([FindPackageShare('metav_description'), 'urdf', 'playground', 'cjh_chassis.xacro']),
49+
' ',
50+
'is_simulation:=', enable_simulation,
51+
])
52+
53+
node_robot_state_publisher = Node(
54+
package='robot_state_publisher',
55+
executable='robot_state_publisher',
56+
parameters=[
57+
{'use_sim_time': enable_simulation,
58+
'robot_description': robot_description_content,
59+
'publish_frequency': 100.0}
60+
],
61+
output='both',
62+
emulate_tty=True
63+
)
64+
65+
robot_config = PathJoinSubstitution([FindPackageShare('meta_bringup'), 'config', 'cjh_chassis.yaml'])
66+
controller_manager = Node(
67+
package="controller_manager",
68+
executable="ros2_control_node",
69+
parameters=[robot_config],
70+
remappings=[
71+
("~/robot_description", "/robot_description"),
72+
],
73+
output='both',
74+
emulate_tty=True,
75+
condition=UnlessCondition(enable_simulation)
76+
)
77+
78+
load_joint_state_broadcaster = load_controller('joint_state_broadcaster')
79+
80+
# List of controllers to be loaded sequentially
81+
# Order in this list is IMPORTANT
82+
load_controllers = [
83+
load_controller('wheels_pid_controller'),
84+
load_controller('omni_chassis_controller'),
85+
]
86+
87+
hero_vehicle_node = Node(
88+
package='hero_vehicle',
89+
executable='hero_vehicle_node',
90+
name='hero_vehicle',
91+
output='both',
92+
parameters=[robot_config],
93+
emulate_tty=True
94+
)
95+
dbus_control_node = Node(
96+
package='dbus_control',
97+
executable='dbus_control_node',
98+
name='dbus_control_node',
99+
parameters=[robot_config],
100+
output='both',
101+
emulate_tty=True,
102+
)
103+
return LaunchDescription([
104+
# Launch Arguments
105+
*ARGUMENTS,
106+
# Load robot state publisher
107+
node_robot_state_publisher,
108+
# Launch controller manager (if not in simulation)
109+
controller_manager,
110+
# Load joint state broadcaster
111+
load_joint_state_broadcaster,
112+
# Load controllers
113+
*register_sequential_loading(load_joint_state_broadcaster, *load_controllers),
114+
hero_vehicle_node,
115+
dbus_control_node
116+
])

0 commit comments

Comments
 (0)