sitl_run: allow to start required ROS2 plugins with Gazebo when ROS_VERSION is set to 2

This commit is contained in:
TSC21 2021-07-06 10:30:04 +02:00 committed by Nuno Marques
parent cb2b09b80f
commit e762d57222
2 changed files with 16 additions and 2 deletions

View File

@ -86,8 +86,15 @@ sleep 1
source ${src_path}/Tools/setup_gazebo.bash ${src_path} ${src_path}/build/${target}
# To use gazebo_ros ROS2 plugins
if [[ -n "$ROS_VERSION" ]] && [ "$ROS_VERSION" == "2" ]; then
ros_args="-s libgazebo_ros_init.so -s libgazebo_ros_factory.so"
else
ros_args=""
fi
echo "Starting gazebo"
gzserver ${src_path}/Tools/sitl_gazebo/worlds/${world}.world --verbose &
gzserver ${src_path}/Tools/sitl_gazebo/worlds/${world}.world --verbose $ros_args &
sleep 5
n=0

View File

@ -56,6 +56,13 @@ else
follow_mode=""
fi
# To use gazebo_ros ROS2 plugins
if [[ -n "$ROS_VERSION" ]] && [ "$ROS_VERSION" == "2" ]; then
ros_args="-s libgazebo_ros_init.so -s libgazebo_ros_factory.so"
else
ros_args=""
fi
if [ "$program" == "jmavsim" ]; then
jmavsim_pid=`ps aux | grep java | grep "\-jar jmavsim_run.jar" | awk '{ print $2 }'`
if [ -n "$jmavsim_pid" ]; then
@ -133,7 +140,7 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
world_path="$PX4_SITL_WORLD"
fi
fi
gzserver $verbose $world_path &
gzserver $verbose $world_path $ros_args &
SIM_PID=$!
# Check all paths in ${GAZEBO_MODEL_PATH} for specified model