PX4 Development
Ubuntu Development Environment
On a clean Ubuntu environment (e.g., 18.04 LTS), we need to
Run the script ubuntu.sh to install PX4 related dependencies (both hardware and simulation)
use arg
--no-nuttx
to omit NuttX/Pixhawk toolsuse arg
--no-sim-tools
to omit jMAVSim and Gazebo9 simulator
Install ROS Melodic by following the official ROS Wiki.
Run the script ubuntu_sim_common_deps.sh to install common dependencies for simulation.
Install MAVROS by following the instructions in its official repository.
we use source installation for development
use
sudo
forinstall_geographiclib_datasets.sh
echo "source ~/catkin_ws/devel/setup.bash --extend" >> ~/.bashrc
Notes
ubuntu.sh
is needed for both hardware and simulationubuntu_sim_ros_melodic.sh
is not used/recommendedTo have more flexibility, we install three parts separately: ROS, sim dependencies, and MAVROS
Gazebo SITL Simulation
In order to run PX4 in Gazebo simulation, we have three more steps.
build PX4 source code to generate a Iris quadrotor model in Gazebo (i.e. the target)
set up environment variables
roslaunch Gazebo simulation and run offboard control program
Build Iris quadrotor model in Gazebo
git clone [email protected]:UCR-Robotics/PX4-Autopilot.git --recursive
cd PX4-Autopilot
DONT_RUN=1 make px4_sitl_default gazebo
# iris.sdf will be generated in PX4-Autopilot/Tools/sitl_gazebo/models/iris
Ser up environment variables
# may add the following to ~/.bashrc
PX4_SRC_DIR=~/PX4-Autopilot
export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:${PX4_SRC_DIR}/build/px4_sitl_default/build_gazebo
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${PX4_SRC_DIR}/Tools/sitl_gazebo/models
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${PX4_SRC_DIR}/build/px4_sitl_default/build_gazebo
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:${PX4_SRC_DIR}
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:${PX4_SRC_DIR}/Tools/sitl_gazebo
Run Offboard Control
launch SITL and MAVROS by
mavros_posix_sitl.launch
similar to
px4.launch
orposix_sitl.launch
run offboard control C++ program by
rosrun <package_name> offboard_node
References
PX4 documentation: Ubuntu Development Environment
provides two bash scripts:
ubuntu.sh
andubuntu_sim_ros_melodic.sh
build targets for Gazebo, jMAVSim, or NuttX
ROS/Gazebo and Raspberry Pi (armhf or aarch64)
PX4 documentation: MAVROS installation
PX4 documentation: ROS with Gazebo Simulation
set up environment variables
ROS launch files
PX4 documentation: MAVROS Offboard Control C++ Example
Last updated
Was this helpful?