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

Launch for spawning Actors in Gazebo #60

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9c171d3
`hubero_bringup_gazebo_ros` & `gazebo` - prepared `actor.xacro` and `…
rayvburn Sep 25, 2023
49be184
`hubero_bringup_gazebo_ros` - README updated
rayvburn Sep 25, 2023
d9d326c
`hubero_bringup_gazebo_ros` - deleted duplicated animations in the `p…
rayvburn Oct 2, 2023
b327393
`hubero_bringup_gazebo_ros` - version bumped
rayvburn Sep 25, 2023
998f67e
`hubero_ros` - improved formatting in the `TaskRequestRosApi` initial…
rayvburn Oct 2, 2023
28be1c8
`hubero_ros` - created a thread for processing of the ROS callbacks […
rayvburn Oct 2, 2023
b0a8ef1
`hubero_ros` - added a `mutex` for data updated in `ActionClient` cal…
rayvburn Oct 2, 2023
bdb8a0a
`hubero_ros` - `NavigationRos`: overriding the action result status b…
rayvburn Oct 3, 2023
0ba67b1
`hubero_ros` - added event logging in the `ActionClient`'s callbacks
rayvburn Oct 3, 2023
c33653c
`hubero_ros` - `TaskRequestRosApi`: added `wait` static functions for…
rayvburn Oct 3, 2023
d71d35e
`hubero_ros_scenarios` - manual spinning of ROS callbacks deleted fro…
rayvburn Oct 3, 2023
d7f71f8
`hubero_ros` - `TaskRequestRosApi` extended with an approach of task …
rayvburn Oct 3, 2023
5b09c5d
`hubero_ros_scenarios` - parking scenario reimplemented using the thr…
rayvburn Oct 3, 2023
a5e04fe
`hubero_ros` - `NavigationRos`: goal's orientation also logged in the…
rayvburn Oct 3, 2023
3c58f76
`hubero_interfaces` - `NavigationBase`: velocity transformations supp…
rayvburn Oct 3, 2023
011dfff
`hubero_ros` - `NavigationRos`: updated global->local velocity transf…
rayvburn Oct 3, 2023
d9325df
`hubero_ros` - `TaskRequestRosApi` extended with `getPose` method
rayvburn Oct 17, 2023
ad8e0f2
`hubero_ros_scenarios` - version bumped
rayvburn Oct 3, 2023
eced728
`hubero_ros` - version bumped
rayvburn Oct 3, 2023
e4e7cce
`hubero_interfaces` - version bumped
rayvburn Oct 3, 2023
ad92ea3
`hubero_ros` - `NavigationRos`: added velocity command timeout
rayvburn Oct 20, 2023
fd1f450
`hubero_ros` - `TaskRequestRosApi` extended with `moveThroughWaypoint…
rayvburn Nov 19, 2023
dadc28c
`hubero_ros` - added a `TaskHelpers` library with a `DistanceTracker`…
rayvburn Nov 20, 2023
182f289
`hubero_ros` - version bumped
rayvburn Nov 20, 2023
ddfab18
`hubero_ros` - reduce planners patience to trigger the recovery behav…
rayvburn Nov 22, 2023
f8a118f
`hubero_ros` - reworked recovery behaviours config for navigation
rayvburn Nov 22, 2023
f5207c5
`hubero_ros` - version bumped
rayvburn Nov 22, 2023
ab045d4
`hubero_ros` & `bringup` - fixed the usage of `gui` argument in the `…
rayvburn Jan 26, 2024
9bbcdd8
`hubero_bringup_gazebo_ros` - added an executable for spawning non-`H…
rayvburn Aug 17, 2024
459d2a9
`hubero_bringup_gazebo_ros` & gazebo - skin file in the `spawn_actor.…
rayvburn Aug 17, 2024
c45e6ff
`hubero_bringup_gazebo_ros` - exposed the `Gazebo` parameters for con…
rayvburn Aug 19, 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
7 changes: 7 additions & 0 deletions hubero_bringup_gazebo_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ find_package(catkin REQUIRED COMPONENTS
catkin_package()

## Install
install(
PROGRAMS
scripts/trajectory_spawner.sh
scripts/xacro_spawner.sh
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

# ref: https://github.com/pal-robotics/tiago_robot/blob/kinetic-devel/tiago_bringup/CMakeLists.txt
foreach(dir launch maps rviz worlds)
install(DIRECTORY ${dir}/
Expand Down
43 changes: 29 additions & 14 deletions hubero_bringup_gazebo_ros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ Package contains `.launch` files, `.pgm` maps and `.world` files for evaluation

## Prerequisites

Before you try to run exemplary worlds, you need to setup Gazebo simulator with a required set of models (used in provided worlds). Visit [Gazebo setup wiki page](https://github.com/rayvburn/hubero/wiki/Gazebo-setup) and start with setup of `3DGems` model pack (this is required, rest may be optional depending on your system configuration).
Before you try to run exemplary worlds, you need to set up the Gazebo simulator with a required set of models (used in provided worlds). Visit the [Gazebo setup wiki page](https://github.com/rayvburn/hubero/wiki/Gazebo-setup) and start setting up the `3DGems` model pack (this one is required, others may be optional depending on your system configuration).

## Run

Before a launch of an exemplary world one must apply both ROS workspace and Gazebo configurations:
Before the launch of an exemplary world, one must apply both ROS workspace and Gazebo configurations:

```bash
source <ROS_WS_DIRECTORY>/devel/setup.bash
Expand All @@ -21,26 +21,34 @@ Then, `parking` world, defined for Gazebo, with all necessary Actor interfaces (
roslaunch hubero_bringup_gazebo_ros example.launch world:=parking rviz:=true
```

If all went OK, after few seconds after start you should see `move_base` log:
If all went OK, after few seconds after the start you should see `move_base` log:

```console
[ INFO] [1643660811.668211218, 8.331000000]: odom received!
```

**NOTE**: actor names defined in Gazebo `.world` must match names given to `.launch` file.

## Spawn
## Spawning an actor

The crucial question is: how to spawn an `Actor` with a `ActorPlugin` controller in a custom Gazebo world?

Since Gazebo entities are defined in `.world` file, one must add Actor definition to the Gazebo world. Actor definition consists of:
### Spawn with a `spawn_model` service

A handy `spawn_actor.launch` was prepared to spawn an actor controlled with the `HuBeRo` plugin in the Gazebo. Once the simulation is running, type:

```sh
roslaunch hubero_bringup_gazebo_ros spawn_actor.launch actor_name:=<ACTOR_UNIQUE_NAME>
```

### Spawn directly in the `.world` file

Typically, Gazebo entities are defined in a `.world` file, so one can also add the `Actor` definition directly to the Gazebo world. Actor definition consists of:

- starting pose definition,
- animation definitions,
- attached sensor relative pose and definition,
- plugin used to control Actor.
- plugin used to control the `Actor`.

Generally, one should use the exemplary worlds definitions as a reference to use actors in their custom worlds. Simply open `living_room.world` or `parking.world` and copy section that is related to a given actor:
Generally, one should use the exemplary worlds definitions as a reference to add actors to their custom worlds. To accomplish that, simply open `living_room.world` or `parking.world` and copy a section that is related to a given actor:

```xml
<actor name="actor1">
Expand All @@ -53,13 +61,20 @@ Generally, one should use the exemplary worlds definitions as a reference to use
</actor>
```

**NOTE**: actor names defined in Gazebo `.world` must match names given to the `.launch` file.

## ROS interface

Actors will not have mobility skills without connection with ROS Navigation stack. Also, Actors will not be able to receive task requests without connection to ROS topics. Use `example.launch` parameter definitions to properly define new Actor interfaces.
Actors will not have mobility skills without the connection with ROS Navigation stack. Also, Actors will not be able to receive task requests without connection to ROS topics. Use `example.launch` parameter definitions to properly define new Actor interfaces.

## Gazebo world map

To create an ideal map of the Gazebo world one may use [`pgm_map_creator`](https://github.com/hyfan1116/pgm_map_creator) package. Examples of use are provided in `maps/*.yaml` files.
To create an ideal map of the Gazebo world one may use `pgm_map_creator`:

- [`hyfan1116/pgm_map_creator`](https://github.com/hyfan1116/pgm_map_creator) with ROS Kinetic and Ubuntu 16.04
- [`rayvburn/pgm_map_creator`](https://github.com/rayvburn/pgm_map_creator.git) with ROS Melodic and Ubuntu 18.04

Examples of use are provided in `maps/*.yaml` files.

One must remember to place/uncomment `collision_map_creator` plugin definition in the `.world` file:

Expand All @@ -69,13 +84,13 @@ One must remember to place/uncomment `collision_map_creator` plugin definition i

## Debugging

`example.launch` provides a possibility to debug Actor controller plugin. First, user should extend `GAZEBO_PLUGIN_PATH`:
`example.launch` provides a possibility to debug the `Actor` controller plugin. First, the user should extend `GAZEBO_PLUGIN_PATH`:

```bash
export GAZEBO_PLUGIN_PATH=<PATH_TO_hubero_gazebo_PACKAGE>/lib:$GAZEBO_PLUGIN_PATH
export GAZEBO_PLUGIN_PATH=<PATH_TO_THE_ROS_WORKSPACE>/devel/.private/hubero_gazebo/lib:$GAZEBO_PLUGIN_PATH
```

Then, run Gazebo world with the required plugins. ROS1 distro should be adjusted by user:
Then, run the Gazebo world with the required plugins. ROS1 distro should be adjusted by the user:

```bash
gazebo -s /opt/ros/kinetic/lib/libgazebo_ros_paths_plugin.so -s /opt/ros/kinetic/lib/libgazebo_ros_api_plugin.so <PATH_TO_WORLD_FILE_DIR>/parking.world
Expand Down
9 changes: 7 additions & 2 deletions hubero_bringup_gazebo_ros/launch/example.launch
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<arg name="gui" default="true"/>
<arg name="rviz" default="true"/>
<arg name="gdb" default="false"/>
<arg name="extra_gazebo_args" default=""/>
<arg name="recording" default="false"/>
<arg name="paused" default="false"/>

<!-- Namespace where communication channels (nodes) of simulated actors will be available -->
<arg name="main_ns" default="hubero"/>
Expand All @@ -25,9 +28,11 @@
<group unless="$(arg gdb)">
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(arg world_file)"/>
<arg name="paused" value="false"/>
<arg name="extra_gazebo_args" value="$(arg extra_gazebo_args)"/>
<arg name="recording" value="$(arg recording)"/>
<arg name="paused" value="$(arg paused)"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="true"/>
<arg name="gui" value="$(arg gui)"/>
<arg name="headless" value="false"/>
<arg name="debug" value="false"/>
<arg name="verbose" value="true"/>
Expand Down
53 changes: 53 additions & 0 deletions hubero_bringup_gazebo_ros/launch/spawn_actor.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0"?>

<launch>
<!-- Parameters related to the spawned model -->
<arg name="actor_name" default="actor1"/>
<arg name="pose_x" default="0.0"/>
<arg name="pose_y" default="0.0"/>
<arg name="pose_z" default="1.03"/>
<arg name="pose_roll" default="1.5707"/>
<arg name="pose_pitch" default="0.0"/>
<arg name="pose_yaw" default="1.5707"/>
<arg name="visualize_laser" default="false"/>
<arg name="skin_file" default="walk.dae"/>

<!-- Contents below are partially shared with the `example.launch` -->
<!-- Actor's map center pose relative to the world center pose -->
<arg name="tf_world_map" default="+0.00 +0.00 +0.00 +0.00 +0.00 +0.00"/>
<arg name="shared_map" default="true"/>
<arg name="map_frame" default="map"/>
<!-- Name of the frame used as a reference in simulator poses etc. usually, frame at the top of the ROS TF tree -->
<arg name="simulator_global_frame" default="world"/>

<!-- Namespace where communication channels (nodes) of simulated actors will be available -->
<arg name="main_ns" default="hubero"/>

<!-- Arbitrary map selected here -->
<arg name="map_file" default="$(find hubero_bringup_gazebo_ros)/maps/parking.yaml"/>
<arg name="map_bounds" default="[-10, 20, -10, 20]"/>

<!-- Motion planning configuration -->
<arg name="global_planner" default="navfn"/>
<arg name="local_planner" default="teb"/>

<!-- Run ROS interface for the HuBeRo actor operating in Gazebo simulation -->
<!-- NOTE: Loading a map & publishing a static TF performed inside the `actor.launch` -->
<include file="$(find hubero_ros)/launch/actor.launch">
<arg name="actor_name" value="$(arg actor_name)"/>
<arg name="main_ns" value="$(arg main_ns)"/>
<arg name="map_file" value="$(arg map_file)"/>
<arg name="use_shared_map" value="$(arg shared_map)"/>
<arg name="map_frame" value="$(arg map_frame)"/>
<arg name="simulator_global_frame" value="$(arg simulator_global_frame)"/>
<arg name="tf_world_map" value="$(arg tf_world_map)"/>
<arg name="map_bounds" value="$(arg map_bounds)"/>
<arg name="local_planner" value="$(arg local_planner)"/>
<arg name="global_planner" value="$(arg global_planner)"/>
</include>

<!-- Spawn actor in the simulation -->
<node type="xacro_spawner.sh" pkg="hubero_bringup_gazebo_ros" name="actor_xacro_spawner" ns="$(arg actor_name)" output="screen"
args="$(arg actor_name) $(arg pose_x) $(arg pose_y) $(arg pose_z) $(arg pose_roll) $(arg pose_pitch) $(arg pose_yaw) $(arg visualize_laser) $(arg skin_file)"
/>
</launch>
2 changes: 1 addition & 1 deletion hubero_bringup_gazebo_ros/package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package>
<name>hubero_bringup_gazebo_ros</name>
<version>0.6.0</version>
<version>0.7.0</version>
<description>The hubero_bringup_gazebo_ros package</description>

<author email="[email protected]">Jarosław Karwowski</author>
Expand Down
59 changes: 59 additions & 0 deletions hubero_bringup_gazebo_ros/scripts/trajectory_spawner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
#
# This is a script for spawning a non-HuBeRo actor (generic Gazebo actor) with a predefined trajectory to be executed
#
# NOTE: the contents of the input_file (2nd argument) should be in the following form:
#
# <?xml version="1.0"?>
# <sdf version="1.6">
# <!-- NOTE: SCRIPTDELETE is placed here as it must be deleted from the resultant .xml to be properly loaded by the Gazebo -->
# <SCRIPTDELETE xmlns:xacro="http://www.ros.org/wiki/xacro">
# <!-- Ref: http://classic.gazebosim.org/tutorials?tut=actor&cat=build_robot -->
# <!-- Also, namespace for ROS topics related to the actor -->
# <xacro:arg name="actor_name" default="actor" />
# <!-- Arg->Property hack -->
# <xacro:property name="actor_name" value="$(arg actor_name)" />
#
# <actor name="${actor_name}">
# <skin>
# <filename>walk.dae</filename>
# </skin>
# <animation name="walking">
# <filename>walk.dae</filename>
# <interpolate_x>true</interpolate_x>
# </animation>
# <script>
# <trajectory id="0" type="walking">
# <waypoint>
# <time>0</time>
# <pose>0 2 0 0 0 -1.57</pose>
# </waypoint>
# <waypoint>
# <!--
# ...
# -->
# </waypoint>
# </trajectory>
# </script>
# </actor>
# </SCRIPTDELETE>
# </sdf>
#

# Pass arguments
actor_name="$1"
# xacro/URDF file location
input_file="$2"

# compose arguments to be passed to the xacro
XACRO_ARGS="actor_name:=${actor_name}"

# deletes lines containing SCRIPTDELETE phrase
SDF=$(xacro "$input_file" $XACRO_ARGS | sed "/SCRIPTDELETE/d")

# save sdf to file
SDF_FILE="/tmp/trajectory_spawner_${actor_name}"
echo $SDF > $SDF_FILE

# spawn coords are defined in the xacro
rosrun gazebo_ros spawn_model -sdf -file $SDF_FILE -model $actor_name
25 changes: 25 additions & 0 deletions hubero_bringup_gazebo_ros/scripts/xacro_spawner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
#
# Pass xacro arguments one by one, beware of the order
actor_name="$1"
pose_x="$2"
pose_y="$3"
pose_z="$4"
pose_roll="$5"
pose_pitch="$6"
pose_yaw="$7"
visualize_laser="$8"
skin_file="$9"

# compose arguments to be passed to the xacro
XACRO_ARGS="actor_name:=${actor_name} pose_x:=${pose_x} pose_y:=${pose_y} pose_z:=${pose_z} pose_roll:=${pose_roll} pose_pitch:=${pose_pitch} pose_yaw:=${pose_yaw} visualize_laser:=${visualize_laser} skin_file:=${skin_file}"

# deletes lines containing SCRIPTDELETE phrase
SDF=$(xacro "$(rospack find hubero_gazebo)/urdf/actor.xacro" $XACRO_ARGS | sed "/SCRIPTDELETE/d")

# save sdf to file
SDF_FILE="/tmp/xacro_spawner_${actor_name}"
echo $SDF > $SDF_FILE

# spawn coords are defined in the xacro
rosrun gazebo_ros spawn_model -sdf -file $SDF_FILE -model $actor_name
12 changes: 0 additions & 12 deletions hubero_bringup_gazebo_ros/worlds/parking.world
Original file line number Diff line number Diff line change
Expand Up @@ -3910,12 +3910,6 @@
<interpolate_x>true</interpolate_x>
</animation>

<animation name="stand_up">
<filename>stand_up.dae</filename>
<scale>1.000000</scale>
<interpolate_x>true</interpolate_x>
</animation>

<animation name="run">
<filename>run.dae</filename>
<scale>1.000000</scale>
Expand Down Expand Up @@ -4019,12 +4013,6 @@
<interpolate_x>true</interpolate_x>
</animation>

<animation name="stand_up">
<filename>stand_up.dae</filename>
<scale>1.000000</scale>
<interpolate_x>true</interpolate_x>
</animation>

<animation name="run">
<filename>run.dae</filename>
<scale>1.000000</scale>
Expand Down
Loading