Skip to content

Commit

Permalink
Separate spawn.launch.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Apr 23, 2024
1 parent f656e07 commit 9d8ef94
Show file tree
Hide file tree
Showing 14 changed files with 448 additions and 208 deletions.
12 changes: 6 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 @@ -56,19 +56,19 @@ repos:
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export HUSARION_ROS_BUILD_TYPE=simulation
### Build

``` bash
vcs import src < src/panther_ros/panther/panther_$HUSARION_ROS_BUILD_TYPE.repos
vcs import src < src/panther_ros/panther/panther_hardware.repos
if [ "$HUSARION_ROS_BUILD_TYPE" == "simulation" ]; then
vcs import src < src/panther_ros/panther/panther_simulation.repos
fi

cp -r src/ros2_controllers/imu_sensor_broadcaster src && rm -rf src/ros2_controllers

Expand Down
6 changes: 3 additions & 3 deletions panther/panther_hardware.repos
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories:
type: git
url: https://github.com/husarion/ros_components_description.git
version: ros2
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
20 changes: 0 additions & 20 deletions panther/panther_simulation.repos
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
repositories:
husarion_controllers:
type: git
url: https://github.com/husarion/husarion_controllers
version: main
husarion_office_gz:
type: git
url: https://github.com/husarion/husarion_office_gz.git
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
ros2_controllers:
type: git
url: https://github.com/delihus/ros2_controllers
version: 60919d60fb02eb920b0bf42e4d86853db23233cc
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
6 changes: 1 addition & 5 deletions panther_controller/launch/controller.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
FindExecutable,
LaunchConfiguration,
PathJoinSubstitution,
PythonExpression,
)
from launch_ros.actions import Node, SetParameter
from launch_ros.substitutions import FindPackageShare
Expand Down Expand Up @@ -157,13 +156,11 @@ 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, {"frame_prefix": namespace_ext}],
parameters=[robot_description],
namespace=namespace,
condition=IfCondition(publish_robot_state),
)
Expand Down Expand Up @@ -228,7 +225,6 @@ def generate_launch_description():
target_action=robot_controller_spawner,
on_exit=[imu_broadcaster_spawner],
),
condition=IfCondition(use_sim),
)

actions = [
Expand Down
53 changes: 30 additions & 23 deletions panther_description/urdf/body.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@
<!-- body defining macro -->
<xacro:macro
name="body"
params="wheel_radius
params="namespace wheel_radius
imu_pos_x imu_pos_y imu_pos_z
imu_rot_r imu_rot_p imu_rot_y">

<link name="base_link" />
<xacro:if value="${namespace == ''}">
<xacro:property name="ns" value="" />
</xacro:if>
<xacro:unless value="${namespace == ''}">
<xacro:property name="ns" value="${namespace}/" />
</xacro:unless>

<link name="${ns}base_link" />

<joint name="base_to_body_joint" type="fixed">
<origin xyz="0.0 0.0 ${wheel_radius}" rpy="0.0 0.0 0.0" />
<parent link="base_link" />
<child link="body_link" />
<parent link="${ns}base_link" />
<child link="${ns}body_link" />
</joint>

<link name="body_link">
<link name="${ns}body_link">
<visual>
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0" />
<geometry>
Expand All @@ -43,51 +50,51 @@
<joint name="body_to_imu_joint" type="fixed">
<origin xyz="${imu_pos_x} ${imu_pos_y} ${imu_pos_z}"
rpy="${imu_rot_r} ${imu_rot_p} ${imu_rot_y}" />
<parent link="body_link" />
<child link="imu_link" />
<parent link="${ns}body_link" />
<child link="${ns}imu_link" />
</joint>

<link name="imu_link" />
<link name="${ns}imu_link" />

<joint name="body_to_front_bumper_joint" type="fixed">
<origin xyz="0.362 0.0 0.0" rpy="0.0 0.0 0.0" />
<parent link="body_link" />
<child link="front_bumper_link" />
<parent link="${ns}body_link" />
<child link="${ns}front_bumper_link" />
</joint>

<link name="front_bumper_link" />
<link name="${ns}front_bumper_link" />

<joint name="front_bumper_to_front_light_joint" type="fixed">
<origin xyz="0.0 0.0 0.0185" rpy="${pi/2} 0.0 ${pi/2}" />
<parent link="front_bumper_link" />
<child link="front_light_link" />
<parent link="${ns}front_bumper_link" />
<child link="${ns}front_light_link" />
</joint>

<link name="front_light_link" />
<link name="${ns}front_light_link" />

<joint name="body_to_rear_bumper_joint" type="fixed">
<origin xyz="-0.362 0.0 0.0" rpy="0.0 0.0 ${pi}" />
<parent link="body_link" />
<child link="rear_bumper_link" />
<parent link="${ns}body_link" />
<child link="${ns}rear_bumper_link" />
</joint>

<link name="rear_bumper_link" />
<link name="${ns}rear_bumper_link" />

<joint name="rear_bumper_to_rear_light_joint" type="fixed">
<origin xyz="0.0 0.0 0.0185" rpy="${pi/2} 0.0 ${pi/2}" />
<parent link="rear_bumper_link" />
<child link="rear_light_link" />
<parent link="${ns}rear_bumper_link" />
<child link="${ns}rear_light_link" />
</joint>

<link name="rear_light_link" />
<link name="${ns}rear_light_link" />

<joint name="body_to_cover_joint" type="fixed">
<origin xyz="0.0 0.0 0.1715" rpy="0.0 0.0 0.0" />
<parent link="body_link" />
<child link="cover_link" />
<parent link="${ns}body_link" />
<child link="${ns}cover_link" />
</joint>

<link name="cover_link" />
<link name="${ns}cover_link" />

</xacro:macro>
</robot>
7 changes: 6 additions & 1 deletion panther_description/urdf/panther_macro.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<!-- BODY DECLARATION -->
<xacro:body.body
namespace="${namespace}"
wheel_radius="${wheel_config['wheel_radius']}"
imu_pos_x="${imu_pos_x}"
imu_pos_y="${imu_pos_y}"
Expand All @@ -44,21 +45,25 @@

<!-- WHEEL DECLARATION -->
<xacro:wheel.wheel
namespace="${namespace}"
wheel_config="${wheel_config}"
wheel_separation_x="${wheel_separation_x}"
prefix="fl" />

<xacro:wheel.wheel
namespace="${namespace}"
wheel_config="${wheel_config}"
wheel_separation_x="${wheel_separation_x}"
prefix="fr" />

<xacro:wheel.wheel
namespace="${namespace}"
wheel_config="${wheel_config}"
wheel_separation_x="${wheel_separation_x}"
prefix="rl" />

<xacro:wheel.wheel
namespace="${namespace}"
wheel_config="${wheel_config}"
wheel_separation_x="${wheel_separation_x}"
prefix="rr" />
Expand Down Expand Up @@ -192,7 +197,7 @@
<xacro:if value="${use_sim}">
<xacro:gazebo.battery config_file="${battery_config_file}" namespace="${namespace}" />
<xacro:gazebo.controller config_file="${controller_config_file}" namespace="${namespace}" />
<xacro:gazebo.imu reference_frame="imu_link" namespace="${namespace}" />
<xacro:gazebo.imu reference_frame="${ns}imu_link" namespace="${namespace}" />
</xacro:if>
</xacro:macro>

Expand Down
19 changes: 13 additions & 6 deletions panther_description/urdf/wheel.urdf.xacro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
<robot xmlns:xacro="http://wiki.ros.org/xacro">

<!-- wheel defining macro -->
<xacro:macro name="wheel" params="wheel_config wheel_separation_x prefix">
<xacro:macro name="wheel" params="namespace wheel_config wheel_separation_x prefix">

<xacro:if value="${namespace == ''}">
<xacro:property name="ns" value="" />
</xacro:if>
<xacro:unless value="${namespace == ''}">
<xacro:property name="ns" value="${namespace}/" />
</xacro:unless>

<xacro:if value="${prefix == 'fl'}">
<xacro:property name="x" value="${wheel_separation_x/2.0}" />
Expand Down Expand Up @@ -31,15 +38,15 @@

<joint name="${prefix}_wheel_joint" type="continuous">
<origin xyz="${x} ${y} 0.0" rpy="0.0 0.0 0.0" />
<parent link="body_link" />
<child link="${prefix}_wheel_link" />
<parent link="${ns}body_link" />
<child link="${ns}${prefix}_wheel_link" />
<axis xyz="0.0 1.0 0.0" />

<limit effort="64.5" velocity="10.958" />
<dynamics damping="0.01" friction="0.1" />
</joint>

<link name="${prefix}_wheel_link">
<link name="${ns}${prefix}_wheel_link">
<visual>
<origin xyz="0.0 0.0 0.0" rpy="0.0 0.0 0.0" />
<geometry>
Expand Down Expand Up @@ -69,14 +76,14 @@
</link>

<xacro:if value="${use_sim}">
<gazebo reference="${prefix}_wheel_link" xmlns:ignition="http://ignitionrobotics.org/schema">
<gazebo reference="${ns}${prefix}_wheel_link" xmlns:ignition="http://ignitionrobotics.org/schema">
<collision>
<surface>
<friction>
<ode>
<mu>1.0</mu>
<mu2>0.0</mu2>
<fdir1 ignition:expressed_in="base_link">${fdir}</fdir1>
<fdir1 ignition:expressed_in="${ns}base_link">${fdir}</fdir1>
</ode>
</friction>
</surface>
Expand Down
15 changes: 10 additions & 5 deletions panther_gazebo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ 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_map_transform` [*bool*, default: **False**]: Adds a frame map 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).
- `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` [*custom*, 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_office_gz share directory>/worlds/husarion_world.sdf**]: path to Gazebo world file used for simulation.
Expand Down
Loading

0 comments on commit 9d8ef94

Please sign in to comment.