Skip to content

mengchaoheng/px4_offboard_control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

px4_offboard_control

Installation

  1. Before that, you need to install Ubuntu 20.04 and the corresponding ROS Noetic version.
  2. mavros:
sudo apt-get install ros-Noetic-mavros ros-Noetic-mavros-extras
  1. 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   
  1. 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

Usage

  1. Run PX4
cd <PX4 directory>
make px4_sitl gazebo

Or run ductedfan simulations:

make px4_sitl gazebo_ductedfan4
  1. Run QGC (Optional).

  2. Run mavros:

cd ~/catkin_ws
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
  1. 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-->
     

=============================

Another way:

Run on different computer:

  1. 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
  1. Run QGC, maybe on computer which ip is 192.168.3.169.

  2. 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

PX4 uer_guide:

Or just like PX4 uer_guide:

  1. 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
  1. mavros
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
  1. Offboard node
roslaunch px4_offboard_control offb_node.launch

About

Publish lissajous trajectory to PX4 sitl and it will auto tracking! yaw control is in the loop.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •