Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Example 11] Carlike Robot using Bicycle Steering Controller #316

Merged
merged 58 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4b43617
first commit; mostly file name changes
ARK3r Jun 20, 2023
1fedade
claiming example 11
ARK3r Jun 20, 2023
92f4ebf
reserving example 11
ARK3r Jun 20, 2023
25351cc
Merge branch 'ros-controls:master' into master
ARK3r Jun 21, 2023
f10126e
Merge branch 'reserve_example11' into master
ARK3r Jun 21, 2023
c364804
double controller setup
ARK3r Jun 27, 2023
6ca0172
Merge branch 'master' of https://github.com/ARK3r/ros2_control_demos
ARK3r Jun 27, 2023
bed63f6
Merge branch 'ros-controls:master' into master
ARK3r Jun 27, 2023
b55b4a6
format
ARK3r Jun 27, 2023
3d60d5f
Merge branch 'master' of https://github.com/ARK3r/ros2_control_demos
ARK3r Jun 27, 2023
a6b0dcf
added controller specific control descriptions
ARK3r Jun 27, 2023
277dc03
Merge branch 'ros-controls:master' into master
ARK3r Jun 28, 2023
61fb68b
Merge branch 'ros-controls:master' into master
ARK3r Jun 28, 2023
648ecd7
Merge pull request #2 from ARK3r/master
ARK3r Jun 28, 2023
b7bdcf2
it runs
ARK3r Jun 28, 2023
255178e
format
ARK3r Jun 28, 2023
66c4f9d
Merge branch 'ros-controls:master' into master
ARK3r Jun 29, 2023
6e37b75
almost
ARK3r Jun 29, 2023
d3c9831
Merge pull request #3 from ARK3r/master
ARK3r Jun 29, 2023
05d9eae
ackermann almost done
ARK3r Jun 29, 2023
25ce02a
format
ARK3r Jun 29, 2023
25a4e97
inactive ackermann; rear joints missing
ARK3r Jun 29, 2023
ff11e76
ackermann working
ARK3r Jun 30, 2023
38f7ff4
format smh
ARK3r Jun 30, 2023
0594c9b
Merge remote-tracking branch 'upstream/master' into example_11_dev
ARK3r Sep 21, 2023
adcba1e
ackermann works with reference acceptance
ARK3r Sep 21, 2023
de2d3c9
bug fixes
ARK3r Sep 21, 2023
5b8f573
formatting
ARK3r Sep 21, 2023
cdaafef
docs and clean up
ARK3r Sep 21, 2023
6acc3c3
docs formatting
ARK3r Sep 21, 2023
4db7277
docs typo; view_robot adhere to example_2
ARK3r Sep 21, 2023
837b7b0
Merge branch 'master' into reserve_example11
ARK3r Sep 26, 2023
d9d3332
Merge branch 'master' into reserve_example11
ARK3r Sep 27, 2023
1e6b9f2
Cleanup example launch file
christophfroehlich Sep 29, 2023
4bc291e
Fix indent of command in doc
christophfroehlich Sep 29, 2023
33a3ddc
Merge branch 'master' into reserve_example11
christophfroehlich Sep 29, 2023
d70e650
Trim whitespace
christophfroehlich Sep 29, 2023
e395140
Remove obsolete xacro file
christophfroehlich Sep 29, 2023
72809ba
Merge branch 'ros-controls:master' into reserve_example11
ARK3r Oct 1, 2023
965afaa
steering pos; traction vel
ARK3r Oct 3, 2023
eb66756
Merge branch 'master' into reserve_example11
ARK3r Oct 3, 2023
9d37c17
formatting
ARK3r Oct 3, 2023
c10642e
Merge branch 'master' into reserve_example11
ARK3r Oct 3, 2023
a893029
added front drive wheels; carlikebot.launch broken
ARK3r Oct 5, 2023
8886d55
Merge branch 'reserve_example11' of https://github.com/ARK3r/ros2_con…
ARK3r Oct 5, 2023
c9c8c3a
Merge branch 'master' into reserve_example11
christophfroehlich Jan 2, 2024
100ab3a
Merge branch 'master' into reserve_example11
ARK3r Jan 26, 2024
642989b
base urdf for bicycle
ARK3r Jan 26, 2024
7c2d627
configured base
ARK3r Jan 26, 2024
0e04086
format
ARK3r Jan 26, 2024
a0f15ef
added relay arg and node
ARK3r Jan 26, 2024
ec2759d
updated docs
ARK3r Jan 29, 2024
f973b38
cleanup
ARK3r Jan 29, 2024
e7a9d69
redundant dependency
ARK3r Jan 29, 2024
50c0593
Remove dependency on topic_tools
christophfroehlich Feb 17, 2024
78e9248
Cleanup
christophfroehlich Feb 17, 2024
7d1c240
Add tests for description
christophfroehlich Feb 17, 2024
25eb1b4
Merge branch 'master' into reserve_example11
christophfroehlich Feb 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-ros-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
ros2_control_demo_example_8
ros2_control_demo_example_9
ros2_control_demo_example_10
ros2_control_demo_example_11
ros2_control_demo_example_12
ros2_control_demo_example_14

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The following examples are part of this demo repository:

*RRBot* with GPIO interfaces.

* Example 11: "Car-like robot using steering controller library (tba.)"
* Example 11: ["Car-like robot using steering controller library"](example_11)

* Example 12: ["Controller chaining"](example_12)

Expand Down
4 changes: 3 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ Example 9: "Gazebo Classic"
Example 10: "GPIO interfaces"
Industrial robot with GPIO interfaces

Example 11: "Car-like robot using steering controller library (tba.)"
Example 11: "CarlikeBot"
*CarlikeBot* with a bicycle steering controller

Example 12: "Controller chaining"
The example shows a simple chainable controller and its integration to form a controller chain to control the joints of *RRBot*.
Expand Down Expand Up @@ -270,5 +271,6 @@ Examples
Example 8: Using transmissions <../example_8/doc/userdoc.rst>
Example 9: Gazebo classic <../example_9/doc/userdoc.rst>
Example 10: Industrial robot with GPIO interfaces <../example_10/doc/userdoc.rst>
Example 11: CarlikeBot <../example_11/doc/userdoc.rst>
Example 12: Controller chaining <../example_12/doc/userdoc.rst>
Example 14: Modular robots with actuators not providing states <../example_14/doc/userdoc.rst>
76 changes: 76 additions & 0 deletions example_11/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.16)
project(ros2_control_demo_example_11 LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra)
endif()

# find dependencies
set(THIS_PACKAGE_INCLUDE_DEPENDS
hardware_interface
pluginlib
rclcpp
rclcpp_lifecycle
)

# find dependencies
find_package(ament_cmake REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()


## COMPILE
add_library(
ros2_control_demo_example_11
SHARED
hardware/carlikebot_system.cpp
)
target_compile_features(ros2_control_demo_example_11 PUBLIC cxx_std_17)
target_include_directories(ros2_control_demo_example_11 PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/hardware/include>
$<INSTALL_INTERFACE:include/ros2_control_demo_example_11>
)
ament_target_dependencies(
ros2_control_demo_example_11 PUBLIC
${THIS_PACKAGE_INCLUDE_DEPENDS}
)

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME} PRIVATE "ROS2_CONTROL_DEMO_EXAMPLE_11_BUILDING_DLL")

# Export hardware plugins
pluginlib_export_plugin_description_file(hardware_interface ros2_control_demo_example_11.xml)

# INSTALL
install(
DIRECTORY hardware/include/
DESTINATION include/ros2_control_demo_example_11
)
install(
DIRECTORY description/launch description/ros2_control description/urdf
DESTINATION share/ros2_control_demo_example_11
)
install(
DIRECTORY bringup/launch bringup/config
DESTINATION share/ros2_control_demo_example_11
)
install(TARGETS ros2_control_demo_example_11
EXPORT export_ros2_control_demo_example_11
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

if(BUILD_TESTING)
find_package(ament_cmake_pytest REQUIRED)

ament_add_pytest_test(example_11_urdf_xacro test/test_urdf_xacro.py)
ament_add_pytest_test(view_example_11_launch test/test_view_robot_launch.py)
endif()

## EXPORTS
ament_export_targets(export_ros2_control_demo_example_11 HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_package()
6 changes: 6 additions & 0 deletions example_11/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ros2_control_demo_example_11

*CarlikeBot*, or ''Carlike Mobile Robot'', is a simple mobile base with bicycle drive.
The robot has two wheels in the front that steer the robot and two wheels in the back that power the robot forward and backwards. However, since each pair of wheels (steering and traction) are controlled by one interface, a bicycle steering model is used.

Find the documentation in [doc/userdoc.rst](doc/userdoc.rst) or on [control.ros.org](https://control.ros.org/master/doc/ros2_control_demos/example_11/doc/userdoc.html).
29 changes: 29 additions & 0 deletions example_11/bringup/config/carlikebot_controllers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
controller_manager:
ros__parameters:
update_rate: 10 # Hz

joint_state_broadcaster:
type: joint_state_broadcaster/JointStateBroadcaster

bicycle_steering_controller:
type: bicycle_steering_controller/BicycleSteeringController


bicycle_steering_controller:
ros__parameters:
wheelbase: 0.325
front_wheel_radius: 0.05
rear_wheel_radius: 0.05
front_steering: true
reference_timeout: 2.0
rear_wheels_names: ['virtual_rear_wheel_joint']
front_wheels_names: ['virtual_front_wheel_joint']
open_loop: false
velocity_rolling_window_size: 10
base_frame_id: base_link
odom_frame_id: odom
enable_odom_tf: true
twist_covariance_diagonal: [0.0, 7.0, 14.0, 21.0, 28.0, 35.0]
pose_covariance_diagonal: [0.0, 7.0, 14.0, 21.0, 28.0, 35.0]
position_feedback: false
use_stamped_vel: true
151 changes: 151 additions & 0 deletions example_11/bringup/launch/carlikebot.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Copyright 2020 ros2_control Development Team
#
# 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 DeclareLaunchArgument, RegisterEventHandler
from launch.conditions import IfCondition, UnlessCondition
from launch.event_handlers import OnProcessExit
from launch.substitutions import Command, FindExecutable, PathJoinSubstitution, LaunchConfiguration

from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
# Declare arguments
declared_arguments = []
declared_arguments.append(
DeclareLaunchArgument(
"gui",
default_value="true",
description="Start RViz2 automatically with this launch file.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"remap_odometry_tf",
default_value="false",
description="Remap odometry TF from the steering controller to the TF tree.",
)
)

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

# Get URDF via xacro
robot_description_content = Command(
[
PathJoinSubstitution([FindExecutable(name="xacro")]),
" ",
PathJoinSubstitution(
[FindPackageShare("ros2_control_demo_example_11"), "urdf", "carlikebot.urdf.xacro"]
),
]
)
robot_description = {"robot_description": robot_description_content}

robot_controllers = PathJoinSubstitution(
[
FindPackageShare("ros2_control_demo_example_11"),
"config",
"carlikebot_controllers.yaml",
]
)
rviz_config_file = PathJoinSubstitution(
[
FindPackageShare("ros2_control_demo_description"),
"carlikebot/rviz",
"carlikebot.rviz",
]
)

# the steering controller libraries by default publish odometry on a separate topic than /tf
control_node_remapped = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_controllers],
output="both",
remappings=[
("~/robot_description", "/robot_description"),
("/bicycle_steering_controller/tf_odometry", "/tf"),
],
condition=IfCondition(remap_odometry_tf),
)
control_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_controllers],
output="both",
remappings=[
("~/robot_description", "/robot_description"),
],
condition=UnlessCondition(remap_odometry_tf),
)
robot_state_pub_bicycle_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
remappings=[
("~/robot_description", "/robot_description"),
],
)
rviz_node = Node(
package="rviz2",
executable="rviz2",
name="rviz2",
output="log",
arguments=["-d", rviz_config_file],
condition=IfCondition(gui),
)

joint_state_broadcaster_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["joint_state_broadcaster", "--controller-manager", "/controller_manager"],
)

robot_bicycle_controller_spawner = Node(
package="controller_manager",
executable="spawner",
arguments=["bicycle_steering_controller", "--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],
)
)

# Delay start of robot_controller after `joint_state_broadcaster`
delay_robot_controller_spawner_after_joint_state_broadcaster_spawner = RegisterEventHandler(
event_handler=OnProcessExit(
target_action=joint_state_broadcaster_spawner,
on_exit=[robot_bicycle_controller_spawner],
)
)

nodes = [
control_node,
control_node_remapped,
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,
]

return LaunchDescription(declared_arguments + nodes)
Loading
Loading