📖
Wiki
Back to my personal website
  • Home
  • Equipment and Devices
    • 3D Printer
    • Laser Cutter
    • Motion Capture System
    • Sensors
      • RGB-D Cameras
      • Velodyne LiDAR
      • Zed Camera
      • RealSense D435i
      • IMU
    • eGPU
    • Nvidia AGX Xavier
    • CPU Benchmark
    • Installation Checklist
  • Development
    • Linux
      • Shell
      • GDB
      • Git
      • Tmux
      • Network
      • Tricks
      • Debug FAQ
    • CMake
      • Catkin Tools
      • CMakeLists
      • CMake Variables
      • CMake Commands
      • CMake: find_package()
    • ROS
      • Gazebo
      • wstool
      • roslaunch
      • rosbag
      • multi-threaded spinner
    • ROS2
      • Convert ROS1 bag to ROS2 bag
    • C++
      • C++ 11
      • C++ Examples
      • C++ Debug
      • Factory Method
      • Timing
    • Google Tools
      • GLog
      • GFlags
      • GTest
      • Style Guide
      • Clang Format
    • PCL
      • Point Type
      • Methods
      • Architecture
      • Code Explained
    • Open3D
      • Python API
      • Registration
      • Visualization
      • Tools
    • OpenCV
      • Documentation
      • Modules
    • Other Libraries
      • Eigen
      • Ceres
      • g2o
      • GTSAM
    • Website
  • Algorithm
    • SLAM
      • K-D Tree
      • Octree
      • Bag of Words
      • Distance Measures
      • Coordinate Systems
      • LOAM
      • Iterative Closest Point
      • Generalized ICP
      • Mahalanobis Distance
    • Computer Science
      • Computational Model
      • Sorting
      • Analysis
      • Complexity Classes (P, NP)
      • Divide and Conquer
      • Greedy Algorithm
      • Dynamic Programming
      • Tree
      • Graph
    • Computer Vision
      • Camera Models
      • Distortion
      • Motion Models
      • Shutter
      • Image Sensors
      • Epipolar Geometry
      • Multiple-View Geometry
    • Datasets
      • RGB-D Datasets
      • Point Cloud Datasets
      • LiDAR SLAM Datasets
  • Math
    • Optimization
      • Convex Optimization
      • Descent Methods
    • Probability
      • Moment
      • Covariance Matrix
      • Stochastic Process
    • Topology
      • References
      • Concepts
      • Topological Spaces
      • Representation of Rotations
      • Representation of 3-sphere
    • Algebra
      • Linear Algebra
      • Matrix Factorization
      • Condition Number
      • Matrix Lie Group
    • Differential Geometry
      • Manifold
      • Submanifold
      • Quotient Manifolds
      • Tangent Space
  • Quadrotor
    • PX4 Development
    • Companion Computer
    • Drone Hardware
    • Propeller Lock
    • Debug
  • Favorites
    • Bookmarks
Powered by GitBook
On this page
  • Ubuntu Development Environment
  • Gazebo SITL Simulation
  • References

Was this helpful?

  1. Quadrotor

PX4 Development

PreviousTangent SpaceNextCompanion Computer

Last updated 3 years ago

Was this helpful?

Ubuntu Development Environment

On a clean Ubuntu environment (e.g., 18.04 LTS), we need to

  • Run the script to install PX4 related dependencies (both hardware and simulation)

    • use arg --no-nuttx to omit NuttX/Pixhawk tools

    • use arg --no-sim-tools to omit jMAVSim and Gazebo9 simulator

  • Install ROS Melodic by following the .

  • Run the script to install common dependencies for simulation.

  • Install MAVROS by following the .

    • we use source installation for development

    • use sudo for install_geographiclib_datasets.sh

    • echo "source ~/catkin_ws/devel/setup.bash --extend" >> ~/.bashrc

Notes

  • ubuntu.sh is needed for both hardware and simulation

  • is not used/recommended

    • To 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 git@github.com: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

    • similar to px4.launch or posix_sitl.launch

  • run offboard control C++ program by rosrun <package_name> offboard_node

References

    • provides two bash scripts: ubuntu.sh and ubuntu_sim_ros_melodic.sh

    • build targets for Gazebo, jMAVSim, or NuttX

    • ROS/Gazebo and Raspberry Pi (armhf or aarch64)

    • set up environment variables

    • ROS launch files

launch SITL and MAVROS by

PX4 documentation:

PX4 documentation:

PX4 documentation:

PX4 documentation:

ubuntu.sh
official ROS Wiki
ubuntu_sim_common_deps.sh
instructions in its official repository
ubuntu_sim_ros_melodic.sh
mavros_posix_sitl.launch
Ubuntu Development Environment
MAVROS installation
ROS with Gazebo Simulation
MAVROS Offboard Control C++ Example