-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
400 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
ros2_control_demo_bringup/config/rrbot_chained_controllers.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
controller_manager: | ||
ros__parameters: | ||
update_rate: 10 # Hz | ||
|
||
joint_state_broadcaster: | ||
type: joint_state_broadcaster/JointStateBroadcaster | ||
|
||
joint1_position_controller: | ||
type: forward_command_controller/ChainableForwardCommandController | ||
|
||
joint2_position_controller: | ||
type: forward_command_controller/ChainableForwardCommandController | ||
|
||
position_controller: | ||
type: forward_command_controller/ChainableForwardCommandController | ||
|
||
position_trajectory_controller: | ||
type: joint_trajectory_controller/JointTrajectoryController | ||
|
||
chained_controllers: | ||
parallel_group_1: | ||
- position_trajectory_controller | ||
parallel_group_2: | ||
- position_controller | ||
parallel_group_3: | ||
- joint1_position_controller | ||
- joint2_position_controller | ||
|
||
|
||
# First-level controllers | ||
joint1_position_controller: | ||
ros__parameters: | ||
joints: | ||
- joint1 | ||
interface_name: position | ||
|
||
|
||
joint2_position_controller: | ||
ros__parameters: | ||
joints: | ||
- joint2 | ||
interface_name: position | ||
|
||
|
||
# Second-level controller | ||
position_controller: | ||
ros__parameters: | ||
joints: | ||
- joint1_position_controller/joint1 | ||
- joint2_position_controller/joint2 | ||
interface_name: position | ||
|
||
|
||
# Third-level controller | ||
position_trajectory_controller: | ||
ros__parameters: | ||
joints: | ||
- joint1 | ||
- joint2 | ||
|
||
command_joints: | ||
- position_controller/joint1_position_controller/joint1 | ||
- position_controller/joint2_position_controller/joint2 | ||
|
||
command_interfaces: | ||
- position | ||
|
||
state_interfaces: | ||
- position | ||
|
||
state_publish_rate: 200.0 # Defaults to 50 | ||
action_monitor_rate: 20.0 # Defaults to 20 | ||
|
||
allow_partial_joints_goal: false # Defaults to false | ||
open_loop_control: true | ||
allow_integration_in_goal_trajectories: true | ||
constraints: | ||
stopped_velocity_tolerance: 0.01 # Defaults to 0.01 | ||
goal_time: 0.0 # Defaults to 0.0 (start immediately) |
103 changes: 103 additions & 0 deletions
103
ros2_control_demo_bringup/launch/rrbot_chained_controllers.launch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Copyright 2021 Stogl Robotics Consulting UG (haftungsbeschränkt) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
from launch import LaunchDescription | ||
from launch.actions import RegisterEventHandler | ||
from launch.event_handlers import OnProcessExit | ||
from launch.substitutions import Command, FindExecutable, PathJoinSubstitution | ||
|
||
from launch_ros.actions import Node | ||
from launch_ros.substitutions import FindPackageShare | ||
|
||
|
||
def generate_launch_description(): | ||
# Get URDF via xacro | ||
robot_description_content = Command( | ||
[ | ||
PathJoinSubstitution([FindExecutable(name="xacro")]), | ||
" ", | ||
PathJoinSubstitution( | ||
[ | ||
FindPackageShare("rrbot_description"), | ||
"urdf", | ||
"rrbot.urdf.xacro", | ||
] | ||
), | ||
] | ||
) | ||
robot_description = {"robot_description": robot_description_content} | ||
|
||
robot_controllers = PathJoinSubstitution( | ||
[ | ||
FindPackageShare("ros2_control_demo_bringup"), | ||
"config", | ||
"rrbot_chained_controllers.yaml", | ||
] | ||
) | ||
rviz_config_file = PathJoinSubstitution( | ||
[FindPackageShare("rrbot_description"), "config", "rrbot.rviz"] | ||
) | ||
|
||
control_node = Node( | ||
package="controller_manager", | ||
executable="ros2_control_node", | ||
parameters=[robot_description, robot_controllers], | ||
remappings=[ | ||
( | ||
"/forward_position_controller/commands", | ||
"/position_commands", | ||
), | ||
], | ||
output={ | ||
"stdout": "screen", | ||
"stderr": "screen", | ||
}, | ||
) | ||
robot_state_pub_node = Node( | ||
package="robot_state_publisher", | ||
executable="robot_state_publisher", | ||
output="both", | ||
parameters=[robot_description], | ||
) | ||
rviz_node = Node( | ||
package="rviz2", | ||
executable="rviz2", | ||
name="rviz2", | ||
output="log", | ||
arguments=["-d", rviz_config_file], | ||
) | ||
|
||
joint_state_broadcaster_spawner = Node( | ||
package="controller_manager", | ||
executable="spawner", | ||
arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"], | ||
) | ||
|
||
# Delay rviz start after `joint_state_broadcaster` | ||
delay_rviz_after_joint_state_broadcaster_spawner = RegisterEventHandler( | ||
event_handler=OnProcessExit( | ||
target_action=joint_state_broadcaster_spawner, | ||
on_exit=[rviz_node], | ||
) | ||
) | ||
|
||
nodes = [ | ||
control_node, | ||
robot_state_pub_node, | ||
joint_state_broadcaster_spawner, | ||
delay_rviz_after_joint_state_broadcaster_spawner, | ||
] | ||
|
||
return LaunchDescription(nodes) |
34 changes: 34 additions & 0 deletions
34
...o_description/rrbot_description/ros2_control/rrbot_system_multi_states.ros2_control.xacro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0"?> | ||
<robot xmlns:xacro="http://www.ros.org/wiki/xacro"> | ||
|
||
<xacro:macro name="rrbot_system_position_only" params="name prefix use_sim:=^|false use_fake_hardware:=^|true fake_sensor_commands:=^|false slowdown:=2.0"> | ||
|
||
<ros2_control name="${name}" type="system"> | ||
|
||
<hardware> | ||
<plugin>fake_components/GenericSystem</plugin> | ||
<param name="fake_sensor_commands">${fake_sensor_commands}</param> | ||
<param name="state_following_offset">0.1</param> | ||
</hardware> | ||
|
||
<joint name="joint1"> | ||
<command_interface name="position"> | ||
<param name="min">-1</param> | ||
<param name="max">1</param> | ||
</command_interface> | ||
<state_interface name="position"/> | ||
<state_interface name="actual_position"/> | ||
</joint> | ||
<joint name="joint2"> | ||
<command_interface name="position"> | ||
<param name="min">-1</param> | ||
<param name="max">1</param> | ||
</command_interface> | ||
<state_interface name="position"/> | ||
<state_interface name="actual_position"/> | ||
</joint> | ||
</ros2_control> | ||
|
||
</xacro:macro> | ||
|
||
</robot> |
Oops, something went wrong.