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

Add namespaces #81

Merged
merged 35 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2213a81
added namespaces to ros2_control
delihus Nov 13, 2023
2b479a6
removed action group
delihus Nov 13, 2023
ae14e26
Added namespace to robot description
delihus Nov 13, 2023
2b37af8
added tests for namespaces in rosbot_controller
delihus Nov 13, 2023
72bef34
update worldlist
delihus Nov 13, 2023
0d82f27
fixed ros2_control namespaces | added namespace to ekf
delihus Nov 13, 2023
ad2ef7c
added mecanum
delihus Nov 13, 2023
64952ce
added ros2_controllers to .gitignore
delihus Nov 13, 2023
9a3e90d
ignored ros2_controllers during Industrial CI
delihus Nov 14, 2023
539cd89
fixed tests
delihus Nov 14, 2023
976a6da
added tf_prefix to imu_sensor_broadcaster
delihus Nov 14, 2023
d0274a6
copied only diff_drive and imu_broadcaster
delihus Nov 14, 2023
1df3216
changed comments | changed timeout for controller test
delihus Nov 14, 2023
86c7588
param changed to parameter
delihus Nov 14, 2023
4a783a6
Multi robot diff drive example
delihus Nov 28, 2023
9d850bf
imu also works
delihus Nov 28, 2023
02fe7d2
Added use_multirobot_system | found imu error
delihus Nov 28, 2023
1b8d92f
changed all topics to ns
delihus Nov 28, 2023
5cd3a69
removed tf_prefix from xacro tests
delihus Nov 28, 2023
f5a9597
removed comments | add use_multirobot_system arg
delihus Nov 28, 2023
297ebc1
moved multi robot system controllers config to rosbot_controller
delihus Nov 28, 2023
9cf6c1b
fixed rosbot_gazebo test
delihus Nov 28, 2023
1ad2db6
separated namespaced tests | added multirobot gazebo example with bro…
delihus Nov 29, 2023
1e0f69d
add multicontroller test
delihus Nov 29, 2023
3ea4d16
add multibringup test
delihus Nov 29, 2023
568063b
add multibringup test
delihus Nov 29, 2023
2e5b6cf
Added remove rosbot_macro
delihus Nov 29, 2023
cd3e104
fixed miss spelling
delihus Nov 29, 2023
b831fd5
The change from robot_hardware_interface seems to be unnecessary
delihus Nov 29, 2023
11fcac8
moved multirobot tests to arrays
delihus Nov 29, 2023
5802601
move rosbot_hardware_interfaces to main
delihus Nov 29, 2023
9019ff3
Fixed len
delihus Nov 29, 2023
165085b
Added updated controllers info to readme
delihus Nov 30, 2023
1a2e6d1
Update README.md
delihus Nov 30, 2023
9d6bae4
Update README.md
rafal-gorecki Dec 1, 2023
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
3 changes: 3 additions & 0 deletions .github/workflows/industrial_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
- name: Clone installation requirements
shell: bash
run: python3 -m pip install -U vcstool && vcs import . < ./rosbot/rosbot_hardware.repos && vcs import . < ./rosbot/rosbot_simulation.repos
- name: Copy only diff_drive_controller and imu_sensor_broadcaster, waits for features from ros2-control
shell: bash
run: cp -r ros2_controllers/diff_drive_controller . && cp -r ros2_controllers/imu_sensor_broadcaster . && rm -rf ros2_controllers
delihus marked this conversation as resolved.
Show resolved Hide resolved
- uses: ros-industrial/industrial_ci@master
env:
ROS_DISTRO: ${{matrix.ROS_DISTRO}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ros_components_description/
rosbot_controllers/
husarion/husarion_office_gz
gazebosim/gz_ros2_control
ros2_controllers

# pyspelling
*.dic
5 changes: 5 additions & 0 deletions .wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@ Palacios
env
pids
pgrep
namespace
TODO
delipl
microros
namespaces
11 changes: 9 additions & 2 deletions rosbot/rosbot_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ repositories:
rosbot_hardware_interfaces:
type: git
url: https://github.com/husarion/rosbot_hardware_interfaces.git
version: main
version: add-namespace
ros_components_description:
type: git
url: https://github.com/husarion/ros_components_description.git
version: ros2
rosbot_controllers:
type: git
url: https://github.com/husarion/rosbot_controllers
version: main
version: add-namespace
# Waiting for backporting to the humble version
# https://github.com/ros-controls/ros2_controllers/pull/726 and
# https://github.com/ros-controls/ros2_controllers/pull/831
ros2_controllers:
type: git
url: https://github.com/delihus/ros2_controllers
version: humble-backport
9 changes: 6 additions & 3 deletions rosbot_bringup/config/ekf.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Ref: http://docs.ros.org/en/noetic/api/robot_localization/html/state_estimation_nodes.html

## ekf config file ###
ekf_filter_node:
/**/ekf_filter_node:
ros__parameters:
frequency: 25.0
sensor_timeout: 0.05
Expand All @@ -10,14 +10,16 @@ ekf_filter_node:
transform_time_offset: 0.0
transform_timeout: 0.05

# All transforms are overwritten in launch file due to the namespace argument
map_frame: map
odom_frame: odom
base_link_frame: base_link
world_frame: odom
publish_tf: true
publish_acceleration: false

odom0: /rosbot_base_controller/odom
# The odometry topic name is overwritten in launch file due to the namespace argument
odom0: rosbot_base_controller/odom
odom0_config: [false, false, false, # X , Y , Z
false, false, false, # roll , pitch ,yaw
true, true, false, # dX , dY , dZ
Expand All @@ -29,7 +31,8 @@ ekf_filter_node:
odom0_differential: false
odom0_relative: true

imu0: /imu_broadcaster/imu
# The IMU topic name is overwritten in launch file due to the namespace argument
imu0: imu_broadcaster/imu
imu0_config: [false, false, false, # X , Y , Z
false, false, true, # roll , pitch ,yaw
false, false, false, # dX , dY , dZ
Expand Down
39 changes: 37 additions & 2 deletions rosbot_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@
from ament_index_python.packages import get_package_share_directory
from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution, PythonExpression


def generate_launch_description():
namespace = LaunchConfiguration("namespace")
namespace_tf_prefix = PythonExpression(
["''", " if '", namespace, "' == '' ", "else ", "'", namespace, "_'"]
)
declare_namespace_arg = DeclareLaunchArgument(
"namespace",
default_value="",
description="Namespace for all topics and tfs",
)

use_sim = LaunchConfiguration("use_sim")
declare_use_sim_arg = DeclareLaunchArgument(
"use_sim",
Expand Down Expand Up @@ -70,6 +80,7 @@ def generate_launch_description():
"mecanum": mecanum,
"use_gpu": use_gpu,
"simulation_engine": simulation_engine,
"namespace": namespace,
}.items(),
)

Expand All @@ -80,10 +91,34 @@ def generate_launch_description():
executable="ekf_node",
name="ekf_filter_node",
output="screen",
parameters=[ekf_config],
parameters=[
ekf_config,
{
"map_frame": LaunchConfiguration(
"ekf_map_frame", default=[namespace_tf_prefix, "map"]
)
},
rafal-gorecki marked this conversation as resolved.
Show resolved Hide resolved
{
"odom_frame": LaunchConfiguration(
"ekf_odom_frame", default=[namespace_tf_prefix, "odom"]
)
},
{
"base_link_frame": LaunchConfiguration(
"ekf_base_link_frame", default=[namespace_tf_prefix, "base_link"]
)
},
{
"world_frame": LaunchConfiguration(
"ekf_world_frame", default=[namespace_tf_prefix, "odom"]
)
},
],
namespace=namespace,
)

actions = [
declare_namespace_arg,
declare_mecanum_arg,
declare_use_sim_arg,
declare_use_gpu_arg,
Expand Down
10 changes: 6 additions & 4 deletions rosbot_controller/config/diff_drive_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ simulation_ignition_ros_control:

# Separate controller manager used for simulation - only difference is
# the use_sim_time parameter (it is the easiest way to do it with ign ros2 control)
simulation_controller_manager:
/**/simulation_controller_manager:
ros__parameters:
use_sim_time: true
update_rate: 20 # Hz
Expand All @@ -17,7 +17,7 @@ simulation_controller_manager:
type: imu_sensor_broadcaster/IMUSensorBroadcaster


controller_manager:
/**/controller_manager:
ros__parameters:
use_sim_time: false
update_rate: 20 # Hz
Expand All @@ -29,16 +29,18 @@ controller_manager:
imu_broadcaster:
type: imu_sensor_broadcaster/IMUSensorBroadcaster

imu_broadcaster:
/**/imu_broadcaster:
ros__parameters:
sensor_name: imu
tf_frame_prefix_enable: True
frame_id: imu_link
static_covariance_orientation: [1.9e-3, 0.0, 0.0, 0.0, 1.9e-3, 0.0, 0.0, 0.0, 1.9e-3] # Values taken from datasheet
static_covariance_angular_velocity: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0e-3] # Values measured experimentally
static_covariance_linear_acceleration: [6.4e-2, 0.0, 0.0, 2.2e-2, 0.0, 0.0, 0.0, 0.0, 0.0] # Values measured experimentally

rosbot_base_controller:
/**/rosbot_base_controller:
ros__parameters:
tf_frame_prefix_enable: True
left_wheel_names: ["fl_wheel_joint", "rl_wheel_joint"]
right_wheel_names: ["fr_wheel_joint", "rr_wheel_joint"]

Expand Down
14 changes: 8 additions & 6 deletions rosbot_controller/config/mecanum_drive_controller.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
controller_manager:
/**/controller_manager:
ros__parameters:
use_sim_time: false
update_rate: 20 # Hz
Expand All @@ -12,7 +12,7 @@ controller_manager:

# Separate controller manager used for simulation - only difference is
# the use_sim_time parameter (it is the easiest way to do it with ign ros2 control)
simulation_controller_manager:
/**/simulation_controller_manager:
ros__parameters:
use_sim_time: true
update_rate: 20 # Hz
Expand All @@ -24,16 +24,18 @@ simulation_controller_manager:
imu_broadcaster:
type: imu_sensor_broadcaster/IMUSensorBroadcaster

imu_broadcaster:
/**/imu_broadcaster:
ros__parameters:
sensor_name: "imu"
frame_id: "imu_link"
sensor_name: imu
tf_frame_prefix_enable: True
frame_id: imu_link
static_covariance_orientation: [1.9e-3, 0.0, 0.0, 0.0, 1.9e-3, 0.0, 0.0, 0.0, 1.9e-3] # Values taken from datasheet
static_covariance_angular_velocity: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0e-3] # Values based on diff_drive
static_covariance_linear_acceleration: [6.4e-2, 0.0, 0.0, 2.2e-2, 0.0, 0.0, 0.0, 0.0, 0.0] # Values based on diff_drive

rosbot_base_controller:
/**/rosbot_base_controller:
ros__parameters:
tf_frame_prefix_enable: True
front_left_wheel_name: fl_wheel_joint
front_right_wheel_name: fr_wheel_joint
rear_left_wheel_name: rl_wheel_joint
Expand Down
74 changes: 54 additions & 20 deletions rosbot_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@


def generate_launch_description():
namespace = LaunchConfiguration("namespace")
declare_namespace_arg = DeclareLaunchArgument(
"namespace",
default_value="",
description="Namespace for all topics and tfs",
)

mecanum = LaunchConfiguration("mecanum")
declare_mecanum_arg = DeclareLaunchArgument(
"mecanum",
Expand Down Expand Up @@ -69,14 +76,22 @@ def generate_launch_description():
]
)

controller_manager_name = PythonExpression(
controller_manager_type_name = PythonExpression(
[
"'/simulation_controller_manager' if ",
"'simulation_controller_manager' if ",
use_sim,
" else '/controller_manager'",
" else 'controller_manager'",
]
)

namespace_for_controller_name = PythonExpression(
["''", " if '", namespace, "' == '' ", "else ", "'", namespace, "/'"]
)
controller_manager_name = LaunchConfiguration(
"controller_manager_name",
default=[namespace_for_controller_name, controller_manager_type_name],
)

# Get URDF via xacro
robot_description_content = Command(
[
Expand All @@ -97,6 +112,8 @@ def generate_launch_description():
use_gpu,
" simulation_engine:=",
simulation_engine,
" tf_prefix:=",
namespace,
]
)
robot_description = {"robot_description": robot_description_content}
Expand All @@ -112,20 +129,30 @@ def generate_launch_description():
control_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_description, robot_controllers],
parameters=[
robot_description,
robot_controllers,
{
"tf_frame_prefix": LaunchConfiguration(
"rosbot_base_tf_frame_prefix", default=[namespace]
)
},
],
remappings=[
("/imu_sensor_node/imu", "/_imu/data_raw"),
("imu_sensor_node/imu", "/_imu/data_raw"),
("~/motors_cmd", "/_motors_cmd"),
("~/motors_response", "/_motors_response"),
("/rosbot_base_controller/cmd_vel_unstamped", "/cmd_vel"),
("rosbot_base_controller/cmd_vel_unstamped", "cmd_vel"),
],
condition=UnlessCondition(use_sim),
namespace=namespace,
)

robot_state_pub_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
parameters=[robot_description],
namespace=namespace,
)

joint_state_broadcaster_spawner = Node(
Expand All @@ -137,6 +164,8 @@ def generate_launch_description():
controller_manager_name,
"--controller-manager-timeout",
"120",
"--namespace",
namespace,
],
)

Expand All @@ -149,6 +178,8 @@ def generate_launch_description():
controller_manager_name,
"--controller-manager-timeout",
"120",
"--namespace",
namespace,
],
)

Expand All @@ -169,6 +200,8 @@ def generate_launch_description():
controller_manager_name,
"--controller-manager-timeout",
"120",
"--namespace",
namespace,
],
)

Expand All @@ -181,17 +214,18 @@ def generate_launch_description():
)
)

actions = [
declare_mecanum_arg,
declare_use_sim_arg,
declare_use_gpu_arg,
declare_simulation_engine_arg,
SetParameter(name="use_sim_time", value=use_sim),
control_node,
robot_state_pub_node,
joint_state_broadcaster_spawner,
delay_robot_controller_spawner_after_joint_state_broadcaster_spawner,
delay_imu_broadcaster_spawner_after_robot_controller_spawner,
]

return LaunchDescription(actions)
return LaunchDescription(
[
declare_namespace_arg,
declare_mecanum_arg,
declare_use_sim_arg,
declare_use_gpu_arg,
declare_simulation_engine_arg,
SetParameter("use_sim_time", value=use_sim),
control_node,
robot_state_pub_node,
joint_state_broadcaster_spawner,
delay_robot_controller_spawner_after_joint_state_broadcaster_spawner,
delay_imu_broadcaster_spawner_after_robot_controller_spawner,
]
)
1 change: 1 addition & 0 deletions rosbot_controller/test/test_diff_drive_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def generate_test_description():
"use_sim": "False",
"mecanum": "False",
"use_gpu": "False",
"namespace": "rosbot2r",
}.items(),
)

Expand Down
1 change: 1 addition & 0 deletions rosbot_controller/test/test_mecanum_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def generate_test_description():
"use_sim": "False",
"mecanum": "True",
"use_gpu": "False",
"namespace": "rosbot2r",
}.items(),
)

Expand Down
Loading