These instructions are for operating a small, multirotor UAS running a PX4 flight control unit or similar variant. They also include setup for a ROS interface using mavlink and mavros. The companion computer can be a number of embedded devices such as a NUC, Odroid, or RPi while using a ground station PC connected via WiFi and a telemetry radio.
- We recommend first starting with a tethered configuration (power and communications). A Linux computer can connect to the PX4 using the USB port. Follow the PX4 development guide. See your instructor with questions.
- Configure the PX4 using QGroundControl (download latest firmware, set up flight modes, etc).
- The
SERIAL2_BAUD
parameter is set to 921600. This paramater is the Telemetry 2 port on the PX4.
- Once your PX4 is configured and calibrated, it can connect to a companion computer through an FTDI adapter to the Telemetry 2 port on the PX4 as described here.
- These instructions assume the latest stable version of the firmware (v1.10.0 as of March 2020). Note: If the /tag/v*.. page does not have .px4 files, go to the next available stable release. For the Pixhawk v2.1 cube, you need fmu-v3, e.g. px4_fmu-v3_default.px4
- Install the mavros package and dependencies (assuming the stable version of ROS is used).
- Clone usma_mavros
cd ~/catkin_ws/src
git clone https://github.com/westpoint-robotics/usma_mavros
- Build
cd ~/catkin_ws/
catkin_make -DMAVLINK_DIALECT=common
- Configure mavros on computer:
- In
px4.launch
, - The computer is connecting through
ttyUSB0:921600
instead ofttyACM0:57600
. - Chage the
gcs_url
argument default todefault="udp://:[email protected]:14550"
to match the IP of the ground control station (which may be determined usingifconfig
, orip a
). - QGC can connect to the autopilot using the Default UDP link.
- Execute mavros
roslaunch usma_mavros px4.launch
- Check that there is a heartbeat with the PX4.
[INFO] [1573276705.686808500]: CON: Got HEARTBEAT, connected. FCU: ArduPilot
----- Need to update indoor operations and below ------
-
We recommend first starting with a tethered configuration (power and communications). A Linux computer can connect to the PX4 using a USB extension and FTDI adapter to the Telemetry 2 port on the PX4 as described here. For initial testing and configuration, it is possible to connect to the PX4's micro USB port.
-
For general manual control, configure the PX4 using QGroundControl (download latest firmware, set up flight modes, etc).
-
If operating in mocap, follow the usma_optitrack instructions for set up motion capture.
-
Configure the PX4 to operate in mocap using external position estimation.
-
Instructions are included to build from source. The firmware can also be downloaded here.
-
Transmitter settings can be found here. At a minimum, the RC transmitter should have manual, position control, offboard control, and a kill switch.
-
First achieve position control of the vehicle using the transmitter.
-
Here is a summary of firmware parameters:
-- The
sys_companion
field is set 921600. --ATT_EXT_HDG_M
parameter is set to 2.
-
- We recommend first starting with a tethered configuration (power and communications). A Linux computer can connect to the PX4 using a USB extension and FTDI adapter to the Telemetry 2 port on the PX4 as described [here] (http://ardupilot.org/dev/docs/odroid-via-mavlink.html).
- Configure PX4 using QGroundControl (download latest firmware, set up flight modes, etc).
- If operating in mocap, follow the usma_optitrack instructions for set up motion capture.
- Configure the PX4 to operate in mocap using [external position] (http://dev.px4.io/external-position.html).
- The
sys_companion
field is set 921600. ATT_EXT_HDG_M
parameter is set to 1 (when using vision_pose topic).CBRK_NO_VISION
parameter set to 0.- Indoor navigation is only achieved by using the external headings from mocap.
- The offboard control documentation provides a good overview.
- Install the mavros package and dependencies (assuming ROS Indigo used).
sudo apt-get install ros-indigo-mavros ros-indigo-mavlink ros-indigo-diagnostic-updater ros-indigo-tf2-ros ros-indigo-angles ros-indigo-eigen-conversions ros-indigo-image-transport ros-indigo-cv-bridge ros-indigo-urdf ros-indigo-tf ros-indigo-control-toolbox
- Clone usma_mavros
cd ~/catkin_ws/src
git clone https://github.com/westpoint-robotics/usma_mavros
- Build
cd ~/catkin_ws/
catkin_make -DMAVLINK_DIALECT=common
- Configure mavros on computer:
- Note some variations to the mavros configuration:
- Using QGC, the
sys_companion
field is set 921600 so that autopilot is enabled with a higher baud rate to communicate with the computer. - In
px4.launch
, - The computer is connecting through
ttyUSB0:921600
instead ofttyACM0:57600
. - Chage the
gcs_url
argument default todefault="udp://:[email protected]:14550"
to match the IP of the ground control station (which may be determined usingifconfig
, orip a
). - QGC can connect to the autopilot using the Default UDP link.
- If using mocap, ensure that the
vision_pose_estimate
plugin is enabled and NOT blacklisted.
- Execute mavros
roslaunch usma_mavros px4.launch
- Check that there is a heartbeat with the PX4.
- Check the debug messages for a valid vision estimate:
FCU: [inav] VISION estimate valid
- Echo the FCU local position to check for propoer coordinate frame conversions:
rostopic echo /mavros/local_position/local
- [Install Ubuntu 14.04 LTS] (https://wiki.ubuntu.com/ARM/RaspberryPi)
- [These instructions are helpful as well] (https://www.raspberrypi.org/documentation/installation/installing-images/linux.md)
- Connect your RPi2 using wired Ethernet.
- Install linux-firmware drivers to enable wifi.
sudo apt-get install linux-firmware
sudo apt-get install wicd
- [Setup WiFi on your device] (https://help.ubuntu.com/community/NetworkConfigurationCommandLine/Automatic)
- [Another reference] (https://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/setting-up-wifi-with-occidentalis)
$ sudo nano /etc/network/interfaces
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "EECSDS3"
wpa-psk "accessgranted"
- [Install ROS] (http://wiki.ros.org/indigo/Installation/UbuntuARM) 6
- Make these [hardware connections] (http://dev.ardupilot.com/wiki/raspberry-pi-via-mavlink/) between the RPi2 and PX4
- The software instructions in the above link are not followed.
- Assume Ubuntu 14.04 and ROS Indigo installed and a catkin_ws created.
- Setup serial port and baud rate on RPi2:
- Create a temp folder and clone this [package] (https://github.com/vooon/rarog.git)
- Follow the installation [instructions] (https://github.com/vooon/rarog/tree/master/rarog_configs/rpi2)
- Ignore #4 and #5
- Set up embedded computer to match MASTER_URI of base station
cd ~
vim .bashrc
(or your preferred editor)- Add this export to the end of your .bashrc file that matches the IP of your master machine (i.e. the basestation):
- export ROS_MASTER_URI=http://192.169.200.50:11311
- Both the client and server should have this export in their .bashrc
- Edit your /etc/hosts to include the computer name and IP address for the other computer similar to these [instructions] (http://www.faqs.org/docs/securing/chap9sec95.html)
- Other references:
- Run mavros on the embedded computer:
roslaunch usma_mavros px4.launch
- Note some variations to the mavros configuration:
- Using QGC, ensure the
sys_companion
field is set to 921600 so that autopilot is enabled with higher baud rate to communicate with onboard computer - In
px4.launch
, the RPi2 is connecting through ttyAMA0:921600 instead of ttyACM0:57600
- Using QGC, ensure the
- set up ROS_MASTER_URI and IP on all the terminals used in tracking
- Run
roslaunch mavros px4.launch
on onboard computer - on remote host,set up ROS_MASTER_URI and IP and run
roslaunch mocap_optitrack mocap.launch
- on different terminal,set up ROS_MASTER_URI and IP and run
roslaunch mavros_extras teleop_track.launch
- Joystick button map is listed in f710_joy.yaml( for take-off ,land, track button reference)
All tail numbers must be unique
- Mocap rigid body naming - f450_<TAIL_NUM>
- Hostname - odroid-<TAIL_NUM>
- Flash the firmware located in the config folder
- Load the params file in the config folder
- Calibrate all sensors
During OS installation
- Hostname - odroid-<TAIL_NUM>
After OS install
echo "192.168.200.88 ros304" | sudo tee -a /etc/hosts
After ROS install
- clone and make mavros from source
- make sure to compile with one job otherwise it will most likely fail
cd ~/catkin_ws
catkin_make -j1
Generate and share SSH key (no password)
ssh-keygen
cat ~/.ssh/id_rsa.pub
Copy and paste this into the base station's authorized_keys file in a new line
Only once
echo "export ROSLAUNCH_SSH_UNKNOWN=1" >> ~/.bashrc
echo "export ROS_MASTER_URI=http://ros304:11311" >> ~/.bashrc
For each Odroid
echo "<IP_ADDRESS> odroid-<TAIL_NUM" | sudo tee -a /etc/hosts
An ssh key should already be setup. Share with the odroid
cat ~/.ssh/id_rsa.pub
Copy and paste this into the Odroid's authorized_keys file in a new line
Make sure a BATTERY is plugged in
Terminal A
roslaunch usma_mavros base_station.launch
Terminal B
roslaunch usma_mavros lpe_mavros_quad.launch TAIL_NUM:=131
Terminal C
rosrun usma_mavros test_flight __ns:=f450_131
Configure ubuntu 20.04 appropraitely depending on your companion computer. It can be downloaded here
- Raspberry Pi 4 / Odroid: Download the armhf 32 bit version here onto an sd-card and configure it following the directions based on what OS your main laptop is running. Linux Windows (scroll to "On Windows" section).
- Up Core: Follow the instruction on this page.
- Intel NUC: NUC's from the RRC should already be running 18.04, this is okay.
Now that an ubuntu operating system is downloaded we can install ROS and mavros.
- ROS Noetic: Follow the instructions at the page here
- Mavros: Once ROS Noetic is installed use the following command to install Mavros
You will also need GeographicLib which can be installed with these commands;
sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras
You need to be in the same directory aswget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh sudo bash ./install_geographiclib_datasets.sh
install_geographiclib_datasets.sh
to run the second command. You can ensure mavros is installed correctly in your system space with:You should be brought toroscd mavros
/opt/ros/noetic/share/mavros
- IP Address
Run:
Then use the command
sudo apt-get install net tools
and something similar to below should be retruned in theifconfig
wlan0
section:The ip address followswlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.212.146.230 netmask 255.255.0.0 broadcast 10.212.255.255 inet6 fe80::cb1f:1655:4a91:3e58 prefixlen 64 scopeid 0x20<link> ether dc:a6:32:a1:30:8a txqueuelen 1000 (Ethernet) RX packets 1003 bytes 864468 (864.4 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 692 bytes 299630 (299.6 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
inet
in this case it would be10.212.146.230
It is helpful to note this for remoting into your companion computer.
Now we need to configure mavros so you are ready to fly. First navigate to the launch files with
roscd mavros/launch
Use the following command to allow file editing:
chmod 777 px4.launch apm.launch
In your favorite text editor change line 5 to match the following:
<arg name="fcu_url" default="/dev/ttyUSB0:921600" />
For this section you will need to download the following programs onto your laptop (not necessary for companion computer)