Dereived from https://github.com/nhma20/mmWave_ROS2_PX4_Gazebo
Tested with:
- Ubuntu 20.04.3 LTS
- ROS2 Foxy
- Gazebo 11.9.0
- px4_ros_com 29th Nov
- PX4 Autopilot v1.12.3
https://docs.px4.io/master/en/ros/ros2_offboard_control.html https://github.com/PX4/px4_ros_com/blob/master/src/examples/offboard/offboard_control.cpp
- If offboard_control.cpp or other files have been edited, re-run
install.sh
script (add new files to script and CMakeLists.txt):If same PX4 and px4_ros_com_ros2 roots:cd ~/mmWave_ROS2_PX4_Gazebo/ ( chmod +x ./install.sh ) ./install.sh
./install.sh ~/PX4-Autopilot/ ~/px4_ros_com_ros2/
- Launch PX4 SITL:
Without Gazebo GUI:
cd ~/PX4-Autopilot/ make px4_sitl_rtps gazebo
Without drone following:HEADLESS=1 make px4_sitl_rtps gazebo_iris__hca_full_pylon_setup
After PX4 SITL fully launched, might need to manually start microRTPS client in same terminal:PX4_NO_FOLLOW_MODE=1 make px4_sitl_rtps gazebo_iris__hca_full_pylon_setup
Will fail and return -1 if already running.micrortps_client start -t UDP
- Optional: Open QGroundControl
- In a new terminal, start the fake bounding box publisher:
source ~/px4_ros_com_ros2/install/setup.bash ros2 run px4_ros_com lidar_to_mmwave
- In another terminal, start the velocity vector calculator and publisher:
source ~/px4_ros_com_ros2/install/setup.bash ros2 run px4_ros_com vel_ctrl_vec_pub
- In a new terminal start microRTPS agent and offboard control:
source ~/px4_ros_com_ros2/install/setup.bash micrortps_agent start -t UDP & ros2 run px4_ros_com offboard_control
- Simulated drone in Gazebo should arm and takeoff, hover, do some maneuvers based on bbox in the fake bbox publisher, then land.
-
Trajectory setpoint message: https://github.com/PX4/px4_msgs/blob/ros2/msg/TrajectorySetpoint.msg
-
Disabled param: pxh> param set NAV_RCL_ACT 0
NAV_RCL_ACT: curr: 2 -> new: 0
-
Add any new ROS2 files to ~/px4_ros_com_ros2/src/px4_ros_com/CMakeLists.txt
-
libignition-common3 error (after software update?) - Copy existing file and rename to match missing file
-
If gazebo does not open, try running
gazebo --verbose
to troubleshoot.killall gzserver
should kill any gazebo instances. Else, retry in fresh terminal. Restart PC if all else fails. -
In CMakeLists.txt add new msgs.
-
After running
./build_ros2_workspace
restart all affected executables. -
iris.sdf (or other models) can be edited to include sensors, like 2D lidar.
-
Display simulated camera feed either with rviz2 or
source ~/px4_ros_com_ros2/install/setup.bash
ros2 run image_tools showimage image:=/cable_camera/image_raw
- See local packages, and msgs, with:
ros2 interface packages
and e.g.ros2 interface package px4_msgs
- Drone spawn coordinates set in ~/PX4-Autopilot/Tools/sitl_run.sh ?
*** No rule to make target '/opt/ros/foxy/lib/libfastrtps.so.2.0.2', needed by 'libpx4_msgs__rosidl_typesupport_fastrtps_cpp.so'. Stop.
Fixed by renaming closest libfastrtps.so.x.y.z to libfastrtps.so.2.0.2.- Dependency errors with PX4, like
ninja: error: '/usr/lib/x86_64-linux-gnu/libsdformat9.so.9.6.1', needed by 'libmav_msgs.so', missing and no known rule to make it
may be solved by a PX4 reinstall (remember worlds, models, cmake files etc. must be also be reinstalled into new PX4). - If drone enters failsafe when starting offboard_control,
param set COM_RCL_EXCEPT 4
in the PX4 console may solve this. Else, try manually publish few setpoints to fmu/manual_control_setpoint/in and then start offboard mode. - Showing videos in readme: Just drag and drop your image/video from your local pc to github readme in editable mode.
- If gradle not working, might have to downgrade Java (JDK) to 11: https://askubuntu.com/questions/1133216/downgrading-java-11-to-java-8
- 🟡 Set up with "real" bounding box to tune PI controller
- 🟡 Get working with real flight controller
- 🟡 Build in more safety