- Before that, you need to install Ubuntu 20.04 and the corresponding ROS Noetic version.
- mavros:
sudo apt-get install ros-Noetic-mavros ros-Noetic-mavros-extras
- GeographicLib (opens new window)datasets
wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
sudo bash ./install_geographiclib_datasets.sh
- offboard ros pkg.
mkdir -p catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/mengchaoheng/px4_offboard_control.git
cd ~/catkin_ws
catkin_make
- Run PX4
cd <PX4 directory>
make px4_sitl gazebo
Or run ductedfan simulations:
make px4_sitl gazebo_ductedfan4
-
Run QGC (Optional).
-
Run mavros:
cd ~/catkin_ws
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
- Run offboard node:
cd ~/catkin_ws
roslaunch px4_offboard_control offb_node.launch
You can select different startup methods on the first line of the offb_node.launch
file:
<!-- <node name="offb_dataset_node" pkg="px4_offboard_control" type="offb_dataset_node" output="screen"> --> <!-- trajectory from data-->
<!-- <node name="offboard_node" pkg="px4_offboard_control" type="offboard_node" output="screen"> --> <!-- to a setpoint-->
<node name="offb_node" pkg="px4_offboard_control" type="offb_node" output="screen"> <!-- Lissajous-->
=============================
- On computer which ip is 192.168.3.146, run:
cd <PX4 directory>
make px4_sitl gazebo
(Optional) If run QGC on another computer, you can setup ip in PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink
:
# GCS link
mavlink start -x -u $udp_gcs_port_local -r 4000000 -f -t 192.168.3.169 # IP of QGC, in the same LAN
-
Run QGC, maybe on computer which ip is 192.168.3.169.
-
Run mavros:
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
(Optional) Or on computer different from the one running px4_sitl, run mavros by:
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
in which 192.168.3.146 is the ip of running make px4_sitl gazebo
, and on that computer, you can setup ip in PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/px4-rc.mavlink
:
# API/Offboard link
mavlink start -x -u $udp_offboard_port_local -r 4000000 -f -m onboard -o $udp_offboard_port_remote -t 192.168.3.184 # IP of mavros and offboard node
in which 192.168.3.184 is the ip of running mavros and offboard node.
If all running in the same computer, delete -t 192.168.3.184
in mavlink start of API/Offboard link, and then run offboard node.
4.run offboard node in the same computer which running mavros, run offboard node:
roslaunch px4_offboard_control offb_node.launch
Or just like PX4 uer_guide:
- PX4 v1.14
cd <PX4-Autopilot_clone>
DONT_RUN=1 make px4_sitl_default gazebo-classic
source ~/catkin_ws/devel/setup.bash # (optional)
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic
roslaunch px4 posix_sitl.launch
- mavros
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
- Offboard node
roslaunch px4_offboard_control offb_node.launch