ros_ws for px4_simulator_container
This creates a ros_ws folder inside the px4_simulator_container folder.
cd px4_simulator_containor/
git clone git@github.com:yufanana/ros_ws.git
cd px4_simulator_container
./launch_container.sh
Use tmux to run multiple terminals
tmux
Set environment variable to move ball in empty world.
export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:/ros_ws/gazebo_plugin/build
Set environment variable to load an empty world with a ball.
export PX4_SITL_WORLD=/ros_ws/gazebo_plugin/model_push.world
Start the Gazebo SITL simulation with a drone with video stream
MicroXRCEAgent udp4 -p 8888 &
cd PX4-Autopilot/
make px4_sitl gazebo-classic_typhoon_h480
Set environment variable to load an empty world with a ball.
export PX4_SITL_WORLD=/ros_ws/gazebo_plugin/model_push.world
Start the Gazebo SITL simulation with a drone with video stream
MicroXRCEAgent udp4 -p 8888 &
cd PX4-Autopilot/
make px4_sitl gazebo
In one terminal, start Gazebo.
cd PX4-Autopilot/
make px4_sitl gazebo
In another terminal, change directory to the ros_ws and build it:
cd /ros_ws
colcon build
Alternatively, build only certain packages:
colcon build --packages-select <name-of-pkg>
In all new terminal sessions, source the setup file:
source install/setup.bash
Launch the oc_node and offboard_node using launch.py
ros2 launch visual_servo vservo_video.launch.py
In another terminal, (remember to source):
ros2 run visual_servo offboard
In another terminal, (remember to source):
ros2 run target_offset oc
There will be a warning in the simulation regarding the connection, but you can disregard this.
In a third terminal, run:
ros2 topic echo visual_servo/target_offset
to see the offsets published. The offsets are published as a Vector3Stamped with (x_offset, y_offset, proportion), where the offsets are normalized values in the range [-1, 1] in the x and y directions (from the center) and proportion is the proportion of the frame that the bounding box takes up in decimal.
A launch file that starts the oc and video nodes has been added and can be run using:
ros2 launch target_offset oc_and_video.launch.py