Skip to content

Commit

Permalink
Multi robot spawn working
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Mar 26, 2024
1 parent dbc445a commit ec58ca8
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 96 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ ROS 2 packages for Panther autonomous mobile robot

## Quick start

### Create workspace

```bash
mkdir ~/husarion_ws
cd ~/husarion_ws
git clone https://github.com/husarion/panther_ros.git src/panther_ros
```

### Configure environment

The repository is used to run the code both on the real robot and in the simulation. Specify `HUSARION_ROS_BUILD_TYPE` the variable according to your needs.
Expand All @@ -22,14 +30,6 @@ Simulation:
export HUSARION_ROS_BUILD_TYPE=simulation
```

### Create workspace

```bash
mkdir ~/husarion_ws
cd ~/husarion_ws
git clone https://github.com/husarion/panther_ros.git src/panther_ros
```

### Build

``` bash
Expand Down
9 changes: 9 additions & 0 deletions panther_battery/launch/battery.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@


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

panther_version = LaunchConfiguration("panther_version")
declare_panther_version_arg = DeclareLaunchArgument("panther_version")

Expand All @@ -29,9 +36,11 @@ def generate_launch_description():
executable="battery_node",
name="battery_node",
parameters=[{"panther_version": panther_version}],
namespace=namespace,
)

actions = [
declare_namespace_arg,
declare_panther_version_arg,
battery_node,
]
Expand Down
20 changes: 4 additions & 16 deletions panther_bringup/launch/bringup.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
PathJoinSubstitution,
PythonExpression,
)
from launch_ros.actions import Node, PushRosNamespace, SetParameter
from launch_ros.actions import Node, SetParameter
from launch_ros.substitutions import FindPackageShare


Expand Down Expand Up @@ -294,6 +294,7 @@ def generate_launch_description():
("/tf", "tf"),
("/tf_static", "tf_static"),
],
namespace=namespace,
condition=IfCondition(use_ekf),
)

Expand All @@ -309,13 +310,14 @@ def generate_launch_description():
),
condition=UnlessCondition(use_sim),
launch_arguments={
"namespace": namespace,
"panther_version": panther_version,
"shutdown_hosts_config_path": shutdown_hosts_config_path,
}.items(),
)

other_action_timer = TimerAction(
period=10.0,
period=7.0,
actions=[
battery_launch,
imu_launch,
Expand All @@ -325,18 +327,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 @@ -351,11 +341,9 @@ def generate_launch_description():
declare_use_ekf_arg,
declare_ekf_config_path_arg,
declare_shutdown_hosts_config_path_arg,
PushRosNamespace(namespace),
SetParameter(name="use_sim_time", value=use_sim),
welcome_msg,
controller_launch,
waiting_msg,
other_action_timer,
]

Expand Down
7 changes: 7 additions & 0 deletions panther_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def generate_launch_description():
("/tf", "tf"),
("/tf_static", "tf_static"),
],
namespace=namespace,
condition=UnlessCondition(use_sim),
)

Expand All @@ -161,6 +162,7 @@ def generate_launch_description():
parameters=[robot_description],
remappings=[("/tf", "tf"), ("/tf_static", "tf_static")],
condition=IfCondition(publish_robot_state),
namespace=namespace,
)

robot_controller_spawner = Node(
Expand All @@ -175,6 +177,7 @@ def generate_launch_description():
"--namespace",
namespace,
],
namespace=namespace,
)

joint_state_broadcaster_spawner = Node(
Expand All @@ -189,6 +192,7 @@ def generate_launch_description():
"--namespace",
namespace,
],
namespace=namespace,
)

# Delay start of robot_controller after joint_state_broadcaster
Expand All @@ -208,7 +212,10 @@ def generate_launch_description():
"controller_manager",
"--controller-manager-timeout",
"10",
"--namespace",
namespace,
],
namespace=namespace,
)

# Delay start of imu_broadcaster after robot_controller
Expand Down
Loading

0 comments on commit ec58ca8

Please sign in to comment.