Skip to content

Commit

Permalink
ackermann works with reference acceptance
Browse files Browse the repository at this point in the history
  • Loading branch information
ARK3r committed Sep 21, 2023
1 parent 0594c9b commit adcba1e
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 395 deletions.
2 changes: 1 addition & 1 deletion example_11/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ install(
DESTINATION include/ros2_control_demo_example_11
)
install(
DIRECTORY description/launch description/ros2_control description/urdf description/rviz
DIRECTORY description/launch description/ros2_control description/urdf
DESTINATION share/ros2_control_demo_example_11
)
install(
Expand Down
23 changes: 0 additions & 23 deletions example_11/bringup/config/carlikebot_controllers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ controller_manager:
ackermann_steering_controller:
type: ackermann_steering_controller/AckermannSteeringController

bicycle_steering_controller:
type: bicycle_steering_controller/BicycleSteeringController


ackermann_steering_controller:
ros__parameters:
Expand All @@ -33,23 +30,3 @@ ackermann_steering_controller:
front_wheels_radius: 0.05
rear_wheels_radius: 0.05

bicycle_steering_controller:
ros__parameters:

reference_timeout: 2.0
front_steering: true
open_loop: false
velocity_rolling_window_size: 10
position_feedback: false
use_stamped_vel: false
rear_wheels_names: [rear_wheel_joint]
front_wheels_names: [steering_axis_joint]

odom_frame_id: odom
base_frame_id: base_link
enable_odom_tf: true


wheelbase: 0.325
front_wheel_radius: 0.05
rear_wheel_radius: 0.05
48 changes: 14 additions & 34 deletions example_11/bringup/launch/carlikebot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,9 @@ def generate_launch_description():
description="Start RViz2 automatically with this launch file.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"sim",
default_value="true",
description="Whether to start controllers for simulation or real hardware.",
)
)

# Initialize Arguments
gui = LaunchConfiguration("gui")
sim = LaunchConfiguration("sim")

# Get URDF via xacro
robot_description_content = Command(
Expand All @@ -52,8 +44,6 @@ def generate_launch_description():
PathJoinSubstitution(
[FindPackageShare("ros2_control_demo_example_11"), "urdf", "carlikebot.urdf.xacro"]
),
" sim:=",
sim,
]
)
robot_description = {"robot_description": robot_description_content}
Expand All @@ -66,7 +56,7 @@ def generate_launch_description():
]
)
rviz_config_file = PathJoinSubstitution(
[FindPackageShare("ros2_control_demo_example_11"), "rviz", "carlikebot.rviz"]
[FindPackageShare("ros2_control_demo_description"), "carlikebot/rviz", "carlikebot.rviz"]
)

control_node = Node(
Expand All @@ -80,20 +70,9 @@ def generate_launch_description():
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
# remappings=[
# ("/ackermann_steering_controller/reference_unstamped", "/cmd_vel"),
# ],
condition=IfCondition(sim),
)
robot_state_pub_bicycle_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
# remappings=[
# ("/bicycle_steering_controller/reference_unstamped", "/cmd_vel"),
# ],
condition=UnlessCondition(sim),
remappings=[
("/ackermann_steering_controller/reference_unstamped", "/cmd_vel"),
],
)
rviz_node = Node(
package="rviz2",
Expand All @@ -114,13 +93,6 @@ def generate_launch_description():
package="controller_manager",
executable="spawner",
arguments=["ackermann_steering_controller", "--controller-manager", "/controller_manager"],
condition=IfCondition(sim),
)
robot_bicycle_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["bicycle_steering_controller", "--controller-manager", "/controller_manager"],
condition=UnlessCondition(sim),
)

# Delay rviz start after `joint_state_broadcaster`
Expand All @@ -135,17 +107,25 @@ def generate_launch_description():
delay_robot_controller_spawner_after_joint_state_broadcaster_spawner = RegisterEventHandler(
event_handler=OnProcessExit(
target_action=joint_state_broadcaster_spawner,
on_exit=[robot_ackermann_controller_spawner, robot_bicycle_controller_spawner],
on_exit=[robot_ackermann_controller_spawner],
)
)

# the steering controller libraries by default publish odometry on a seperate topic than /tf
relay_topic_to_tf_node = Node(
package='topic_tools',
executable='relay',
arguments=['/ackermann_steering_controller/tf_odometry', '/tf'],
output='screen',
)

nodes = [
control_node,
robot_state_pub_ackermann_node,
robot_state_pub_bicycle_node,
joint_state_broadcaster_spawner,
delay_rviz_after_joint_state_broadcaster_spawner,
delay_robot_controller_spawner_after_joint_state_broadcaster_spawner,
relay_topic_to_tf_node,
]

return LaunchDescription(declared_arguments + nodes)
17 changes: 12 additions & 5 deletions example_11/description/launch/view_robot.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def generate_launch_description():
declared_arguments.append(
DeclareLaunchArgument(
"description_package",
default_value="ros2_control_demo_example_11",
default_value="ros2_control_demo_description",
description="Description package with robot URDF/xacro files. Usually the argument \
is not set, it enables use of a custom description.",
)
Expand All @@ -37,6 +37,14 @@ def generate_launch_description():
default_value="carlikebot.urdf.xacro",
description="URDF/XACRO description file with the robot.",
)
),
declared_arguments.append(
DeclareLaunchArgument(
"gui",
default_value="true",
description="Start Rviz2 and Joint State Publisher gui automatically \
with this launch file.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
Expand All @@ -51,6 +59,7 @@ def generate_launch_description():
# Initialize Arguments
description_package = LaunchConfiguration("description_package")
description_file = LaunchConfiguration("description_file")
gui = LaunchConfiguration("gui")
prefix = LaunchConfiguration("prefix")

# Get URDF via xacro
Expand All @@ -59,19 +68,17 @@ def generate_launch_description():
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[FindPackageShare(description_package), "urdf", description_file]
[FindPackageShare("ros2_control_demo_example_11"), "urdf", description_file]
),
" ",
"prefix:=",
prefix,
" ",
"sim:=true",
]
)
robot_description = {"robot_description": robot_description_content}

rviz_config_file = PathJoinSubstitution(
[FindPackageShare(description_package), "rviz", "carlikebot_view.rviz"]
[FindPackageShare(description_package), "carlikebot/rviz", "carlikebot_view.rviz"]
)

joint_state_publisher_node = Node(
Expand Down

This file was deleted.

16 changes: 4 additions & 12 deletions example_11/description/urdf/carlikebot.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
<!-- 4 Wheel Robot with front steering and rear drive -->
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="carlikebot_robot">
<xacro:arg name="prefix" default="" />
<xacro:arg name="sim" default="true" />

<xacro:include filename="$(find ros2_control_demo_description)/carlikebot/urdf/carlikebot_description.urdf.xacro" />

<!-- Import Rviz colors -->
<xacro:include filename="$(find ros2_control_demo_example_11)/urdf/carlikebot.materials.xacro" />
<xacro:include filename="$(find ros2_control_demo_description)/carlikebot/urdf/carlikebot.materials.xacro" />

<!-- Import carlikebot description and ros2_control based on sim arg -->
<xacro:if value="$(arg sim)">
<xacro:include filename="$(find ros2_control_demo_example_11)/urdf/carlikebot_ackermann_description.urdf.xacro" />
<xacro:include filename="$(find ros2_control_demo_example_11)/ros2_control/carlikebot_ackermann.ros2_control.xacro" />
</xacro:if>

<xacro:unless value="$(arg sim)">
<xacro:include filename="$(find ros2_control_demo_example_11)/urdf/carlikebot_bicycle_description.urdf.xacro" />
<xacro:include filename="$(find ros2_control_demo_example_11)/ros2_control/carlikebot_bicycle.ros2_control.xacro" />
</xacro:unless>
<!-- Import carlikebot ros2_control description -->
<xacro:include filename="$(find ros2_control_demo_example_11)/ros2_control/carlikebot.ros2_control.xacro" />

<xacro:carlikebot prefix="$(arg prefix)" />

Expand Down
Loading

0 comments on commit adcba1e

Please sign in to comment.