From 153a6a2c453d4ce4e9fed9d1b9bba5e8f5b983b1 Mon Sep 17 00:00:00 2001 From: Jarek Karwowski Date: Mon, 25 Sep 2023 20:36:44 +0200 Subject: [PATCH] `hubero_bringup_gazebo_ros` & `gazebo` - prepared `actor.xacro` and `spawn_actor.launch` for spawning Actors without modifying the existing world files [#59] --- hubero_bringup_gazebo_ros/CMakeLists.txt | 6 + hubero_bringup_gazebo_ros/README.md | 22 +++- .../launch/spawn_actor.launch | 55 +++++++++ .../scripts/xacro_spawner.sh | 23 ++++ hubero_gazebo/urdf/actor.xacro | 114 ++++++++++++++++++ 5 files changed, 214 insertions(+), 6 deletions(-) create mode 100644 hubero_bringup_gazebo_ros/launch/spawn_actor.launch create mode 100755 hubero_bringup_gazebo_ros/scripts/xacro_spawner.sh create mode 100644 hubero_gazebo/urdf/actor.xacro diff --git a/hubero_bringup_gazebo_ros/CMakeLists.txt b/hubero_bringup_gazebo_ros/CMakeLists.txt index bb5e61c9..5bbaea18 100644 --- a/hubero_bringup_gazebo_ros/CMakeLists.txt +++ b/hubero_bringup_gazebo_ros/CMakeLists.txt @@ -16,6 +16,12 @@ find_package(catkin REQUIRED COMPONENTS catkin_package() ## Install +install( + PROGRAMS + 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}/ diff --git a/hubero_bringup_gazebo_ros/README.md b/hubero_bringup_gazebo_ros/README.md index 7fd04c77..3068a360 100644 --- a/hubero_bringup_gazebo_ros/README.md +++ b/hubero_bringup_gazebo_ros/README.md @@ -27,20 +27,28 @@ If all went OK, after few seconds after start you should see `move_base` log: [ 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:= +``` + +### 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 @@ -53,6 +61,8 @@ Generally, one should use the exemplary worlds definitions as a reference to use ``` +**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. diff --git a/hubero_bringup_gazebo_ros/launch/spawn_actor.launch b/hubero_bringup_gazebo_ros/launch/spawn_actor.launch new file mode 100644 index 00000000..5e4f777a --- /dev/null +++ b/hubero_bringup_gazebo_ros/launch/spawn_actor.launch @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hubero_bringup_gazebo_ros/scripts/xacro_spawner.sh b/hubero_bringup_gazebo_ros/scripts/xacro_spawner.sh new file mode 100755 index 00000000..ab483dc6 --- /dev/null +++ b/hubero_bringup_gazebo_ros/scripts/xacro_spawner.sh @@ -0,0 +1,23 @@ +#!/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" + +# 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}" + +# 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 diff --git a/hubero_gazebo/urdf/actor.xacro b/hubero_gazebo/urdf/actor.xacro new file mode 100644 index 00000000..326dc0f4 --- /dev/null +++ b/hubero_gazebo/urdf/actor.xacro @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + ${pose_x} ${pose_y} ${pose_z} ${pose_roll} ${pose_pitch} ${pose_yaw} + + walk.dae + 1.0 + + + + + + 0 -0.8 0.55 0 -1.57 -1.57 + false + 10 + + + + 720 + 1 + -2.170796 + 2.170796 + + + + 0.10 + 10.0 + 0.01 + + + gaussian + + 0.0 + 0.01 + + + + /hubero/${actor_name}/receptor/laser_scan + ${actor_name}/base_laser_link + + + + + + walk.dae + 1.000000 + true + + + stand.dae + 1.000000 + true + + + sit_down.dae + 1.000000 + true + + + sitting.dae + 1.000000 + true + + + stand_up.dae + 1.000000 + true + + + run.dae + 1.000000 + true + + + talk_a.dae + 1.000000 + true + + + talk_b.dae + 1.000000 + true + + + + + + +