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

Multi robot spawn working #256

Merged
merged 10 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
# mesh files has to be taken into account
Expand All @@ -23,7 +23,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
Expand Down Expand Up @@ -51,23 +51,24 @@ repos:
"--ignore-words-list",
"ned" # north, east, down (NED)
]
exclude_types: [rst]
language: python
types: [text]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.1
rev: 0.2.3
hooks:
- id: yamlfmt
files: ^.github|./\.yaml

- repo: https://github.com/psf/black
rev: 23.10.1
rev: 24.4.0
hooks:
- id: black
args: ["--line-length=99", "--experimental-string-processing"]
args: ["--line-length=99"]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
args:
Expand Down
26 changes: 15 additions & 11 deletions panther/panther_hardware.repos
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
repositories:
behaviortree_ros2:
type: git
url: https://github.com/BehaviorTree/BehaviorTree.ROS2
version: ce923e19c12d28f4734a41b1442c123f2d4a41d2
husarion_controllers:
type: git
url: https://github.com/husarion/husarion_controllers
version: main
panther_msgs:
type: git
url: https://github.com/husarion/panther_msgs.git
version: ros2
robot_localization: # Caused by this error https://github.com/cra-ros-pkg/robot_localization/pull/876, it can be removed after the next synchronization of apt packages.
type: git
url: https://github.com/cra-ros-pkg/robot_localization.git
version: humble-devel
ros_components_description:
type: git
url: https://github.com/husarion/ros_components_description.git
version: ros2
husarion_controllers:
type: git
url: https://github.com/husarion/husarion_controllers
version: main
behaviortree_ros2:
type: git
url: https://github.com/BehaviorTree/BehaviorTree.ROS2
version: ce923e19c12d28f4734a41b1442c123f2d4a41d2
ros2_controllers:
ros2_controllers: # Caused by two error: 1. https://github.com/ros-controls/ros2_controllers/pull/1104 2. There is no nice way to change `sensor_name` imu_bradcaster param when spawning multiple robots -> ros2_control refer only to single imu entity
type: git
url: https://github.com/delihus/ros2_controllers
version: 60919d60fb02eb920b0bf42e4d86853db23233cc
url: https://github.com/rafal-gorecki/ros2_controllers.git
version: humble
2 changes: 1 addition & 1 deletion panther_battery/launch/battery.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def generate_launch_description():
declare_namespace_arg = DeclareLaunchArgument(
"namespace",
default_value=EnvironmentVariable("ROBOT_NAMESPACE", default_value=""),
description="Add namespace to all launched nodes",
description="Add namespace to all launched nodes.",
)

battery_node = Node(
Expand Down
26 changes: 5 additions & 21 deletions panther_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def generate_launch_description():
declare_namespace_arg = DeclareLaunchArgument(
"namespace",
default_value=EnvironmentVariable("ROBOT_NAMESPACE", default_value=""),
description="Add namespace to all launched nodes",
description="Add namespace to all launched nodes.",
)

use_sim = LaunchConfiguration("use_sim")
Expand Down Expand Up @@ -145,11 +145,7 @@ def generate_launch_description():
declare_led_config_file_arg = DeclareLaunchArgument(
"led_config_file",
default_value=PathJoinSubstitution(
[
FindPackageShare("panther_lights"),
"config",
PythonExpression(["'led_config.yaml'"]),
]
[FindPackageShare("panther_lights"), "config", "led_config.yaml"]
),
description="Path to a YAML file with a description of led configuration",
)
Expand Down Expand Up @@ -287,9 +283,10 @@ def generate_launch_description():
executable="ekf_node",
name="ekf_node",
output="screen",
parameters=[ekf_config_path],
parameters=[ekf_config_path, {"tf_prefix": namespace}],
namespace=namespace,
remappings=[
("/diagnostics", "diagnostics"),
("enable", "ekf_node/enable"),
("set_pose", "ekf_node/set_pose"),
("toggle", "ekf_node/toggle"),
Expand All @@ -316,7 +313,7 @@ def generate_launch_description():
)

other_action_timer = TimerAction(
period=10.0,
period=7.0,
actions=[
battery_launch,
lights_launch,
Expand All @@ -325,18 +322,6 @@ def generate_launch_description():
],
)

waiting_msg = TimerAction(
period=7.0,
actions=[
LogInfo(
msg=(
"We're working on ensuring everything functions properly... Please wait a few"
" seconds more!"
)
)
],
)

actions = [
declare_namespace_arg,
declare_use_sim_arg,
Expand All @@ -356,7 +341,6 @@ def generate_launch_description():
welcome_msg,
controller_launch,
system_status_node,
waiting_msg,
other_action_timer,
]

Expand Down
2 changes: 0 additions & 2 deletions panther_controller/config/WH01_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
imu_broadcaster:
ros__parameters:
use_namespace_as_sensor_name_prefix: true
tf_frame_prefix_enable: false

sensor_name: imu
frame_id: imu_link
Expand All @@ -29,7 +28,6 @@
ros__parameters:
left_wheel_names: ["fl_wheel_joint", "rl_wheel_joint"]
right_wheel_names: ["fr_wheel_joint", "rr_wheel_joint"]
tf_frame_prefix_enable: false

wheel_separation: 0.697
wheel_radius: 0.1825
Expand Down
2 changes: 0 additions & 2 deletions panther_controller/config/WH02_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
imu_broadcaster:
ros__parameters:
use_namespace_as_sensor_name_prefix: true
tf_frame_prefix_enable: false

sensor_name: imu
frame_id: imu_link
Expand All @@ -31,7 +30,6 @@
front_right_wheel_name: fr_wheel_joint
rear_left_wheel_name: rl_wheel_joint
rear_right_wheel_name: rr_wheel_joint
tf_frame_prefix_enable: false

wheel_separation_x: 0.44
wheel_separation_y: 0.6785
Expand Down
2 changes: 0 additions & 2 deletions panther_controller/config/WH04_controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
imu_broadcaster:
ros__parameters:
use_namespace_as_sensor_name_prefix: true
tf_frame_prefix_enable: false

sensor_name: imu
frame_id: imu_link
Expand All @@ -29,7 +28,6 @@
ros__parameters:
left_wheel_names: ["fl_wheel_joint", "rl_wheel_joint"]
right_wheel_names: ["fr_wheel_joint", "rr_wheel_joint"]
tf_frame_prefix_enable: false

wheel_separation: 0.616
wheel_radius: 0.1016
Expand Down
9 changes: 6 additions & 3 deletions panther_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
FindExecutable,
LaunchConfiguration,
PathJoinSubstitution,
PythonExpression,
)
from launch_ros.actions import Node, SetParameter
from launch_ros.substitutions import FindPackageShare
Expand Down Expand Up @@ -87,7 +88,7 @@ def generate_launch_description():
declare_namespace_arg = DeclareLaunchArgument(
"namespace",
default_value=EnvironmentVariable("ROBOT_NAMESPACE", default_value=""),
description="Add namespace to all launched nodes",
description="Add namespace to all launched nodes.",
)

# Get URDF via xacro
Expand Down Expand Up @@ -135,7 +136,7 @@ def generate_launch_description():
control_node = Node(
package="controller_manager",
executable="ros2_control_node",
parameters=[robot_description, controller_config_path],
parameters=[controller_config_path],
namespace=namespace,
remappings=[
(
Expand All @@ -157,11 +158,13 @@ def generate_launch_description():
condition=UnlessCondition(use_sim),
)

namespace_ext = PythonExpression(["'", namespace, "' + '/' if '", namespace, "' else ''"])

robot_state_pub_node = Node(
package="robot_state_publisher",
executable="robot_state_publisher",
output="both",
parameters=[robot_description],
parameters=[robot_description, {"frame_prefix": namespace_ext}],
namespace=namespace,
condition=IfCondition(publish_robot_state),
)
Expand Down
2 changes: 1 addition & 1 deletion panther_description/urdf/panther_macro.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
wheel_separation_x="${wheel_separation_x}"
prefix="rr" />

<ros2_control name="${ns}wheels" type="system">
<ros2_control name="${ns}panther_system" type="system">
<hardware>
<xacro:if value="${use_sim}">
<xacro:if value="${simulation_engine == 'ignition-gazebo'}">
Expand Down
14 changes: 9 additions & 5 deletions panther_gazebo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ A package containing the launch files and dependencies needed to run the simulat

## Usage

The recommended method for launching the simulation is by utilizing the [simulation.launch.py](https://github.com/husarion/panther_ros/panther_gazebo/launch/simulation.launch.py) file. Below, you will find launch arguments that enable simulation configuration.
The recommended method for launching the simulation is by utilizing the [simulation.launch.py](https://github.com/husarion/panther_ros/panther_gazebo/launch/simulation.launch.py) file. Below, you will find launch arguments that enable simulation configuration. You can also launch more robots using `spawn.launch.py` ​​after the system has been started.

### Launch Arguments

- `add_world_transform` [*bool*, default: **False**]: Adds a world frame that connects the tf trees of individual robots (useful when running multiple robots).
- `battery_config_path` [*string*, default: **panther_gazebo/config/battery_plugin_config.yaml**]: Path to the Ignition `LinearBatteryPlugin` configuration file. This configuration is intended for use in simulations only. For more information on how to configure this plugin, please refer to the [Linear Battery Plugin](#linear-battery-plugin) section.
- `controller_config_path` [*string*, default: **panther_controller/config/<wheel_type arg>_controller.yaml**]: Path to the controller configuration file. If you want to use a custom configuration, you can specify the path to your custom controller configuration file here.
- `gz_bridge_config_path` [*string*, default: **panther_gazebo/config/gz_bridge.yaml**]: Path to the `parameter_bridge` configuration file. For detailed information on configuring the `parameter_bridge`, please refer to this [example](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_bridge#example-5-configuring-the-bridge-via-yaml).
- `gz_log_level` [*[0-4]*, default: **1**]: Adjust the level of console output.
- `headless_mode` [*bool*, default: **False**]: Run the simulation in headless mode. Useful when a GUI is not needed or to reduce the amount of calculations.
- `pos_x` [*float*, default: **5.0**]: spawn position **[m]** of the robot in the world in **X** direction.
- `pos_y` [*float*, default: **-5.0**]: spawn position **[m]** of the robot in the world in **Y** direction.
- `pos_z` [*float*, default: **0.2**]: spawn position **[m]** of the robot in the world in **Z** direction.
- `rot_yaw` [*float*, default: **0.0**]: spawn yaw angle **[rad]** of the robot in the world.
- `x` [*float*, default: **5.0**]: spawn position **[m]** of the robot in the world in **X** direction.
- `y` [*float*, default: **-5.0**]: spawn position **[m]** of the robot in the world in **Y** direction.
- `z` [*float*, default: **0.2**]: spawn position **[m]** of the robot in the world in **Z** direction.
- `roll` [*float*, default: **0.0**]: spawn roll angle **[rad]** of the robot in the world.
- `pitch` [*float*, default: **0.0**]: spawn pitch angle **[rad]** of the robot in the world.
- `yaw` [*float*, default: **0.0**]: spawn yaw angle **[rad]** of the robot in the world.
- `publish_robot_state` [*bool*, default: **true**]: Whether to launch the robot_state_publisher node. When set to `false`, users should publish their own robot description.
- `robots` [*yaml style*, default: **""**]: The list of the robots spawned in the simulation e.g. robots:='robot1={x: 0.0, y: -1.0}; robot2={x: 1.0, y: -1.0}'"
- `wheel_config_path` [*string*, default: **panther_description/config/<wheel_type arg>.yaml**]: Path to the wheel configuration file. If you want to use a custom configuration, you can specify the path to your custom wheel configuration file here. Please refer to the `wheel_type` parameter description for more information.
- `wheel_type` [*string*, default: **WH01**]: Specify the type of wheel. If you select a value from the provided options (`WH01`, `WH02`, `WH04`), you can disregard the `wheel_config_path` and `controller_config_path` parameters. If you have custom wheels, set this parameter to `CUSTOM` and provide the necessary configurations.
- `world` [*string*, default: **-r <husarion_gz_worlds share directory>/worlds/husarion_world.sdf**]: path to Gazebo world file used for simulation.
Expand Down
Loading