mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-29 19:57:12 +08:00
sitl_run: allow to start required ROS2 plugins with Gazebo when ROS_VERSION is set to 2
This commit is contained in:
@@ -86,8 +86,15 @@ sleep 1
|
|||||||
|
|
||||||
source ${src_path}/Tools/setup_gazebo.bash ${src_path} ${src_path}/build/${target}
|
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"
|
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
|
sleep 5
|
||||||
|
|
||||||
n=0
|
n=0
|
||||||
|
|||||||
+8
-1
@@ -56,6 +56,13 @@ else
|
|||||||
follow_mode=""
|
follow_mode=""
|
||||||
fi
|
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
|
if [ "$program" == "jmavsim" ]; then
|
||||||
jmavsim_pid=`ps aux | grep java | grep "\-jar jmavsim_run.jar" | awk '{ print $2 }'`
|
jmavsim_pid=`ps aux | grep java | grep "\-jar jmavsim_run.jar" | awk '{ print $2 }'`
|
||||||
if [ -n "$jmavsim_pid" ]; then
|
if [ -n "$jmavsim_pid" ]; then
|
||||||
@@ -133,7 +140,7 @@ elif [ "$program" == "gazebo" ] && [ ! -n "$no_sim" ]; then
|
|||||||
world_path="$PX4_SITL_WORLD"
|
world_path="$PX4_SITL_WORLD"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
gzserver $verbose $world_path &
|
gzserver $verbose $world_path $ros_args &
|
||||||
SIM_PID=$!
|
SIM_PID=$!
|
||||||
|
|
||||||
# Check all paths in ${GAZEBO_MODEL_PATH} for specified model
|
# Check all paths in ${GAZEBO_MODEL_PATH} for specified model
|
||||||
|
|||||||
Reference in New Issue
Block a user