8000 GitHub - norihisayamada/autopilot_manager: An onboard/mission computer service for higher level interactivity with onboard and flight controller components, using MAVSDK and ROS2/DDS.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

An onboard/mission computer service for higher level interactivity with onboard and flight controller components, using MAVSDK and ROS2/DDS.

License

Notifications You must be signed in to change notification settings

norihisayamada/autopilot_manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autopilot Manager

Build in Ubuntu Build/deb packaging for Skynode and other archs

An AuterionOS service for higher level interactivity with onboard and flight controller components, using MAVSDK and ROS 2.

Dependencies

Note: The host system is considered to run Ubuntu 20.04 Focal. Other OS's might be supported, but the provided instructions only cover this OS.

  1. ROS 2 Foxy
  2. MAVSDK (C++ libs)
  3. mavlink-router
  4. Micro XRCE-DDS Agent
  5. Auterion's configuration-manager
  6. DBUS and Glib
  7. MAVSDK-Python (optional, to run the available examples)

ROS packages and workspace library dependencies

  1. Auterion library packages:
    • image_downsampler
    • landing_mapper
    • landing_planner
    • px4_msgs
    • timing_tools
  2. Eigen v3.3.9
  3. If using ROS2 Foxy:
    • Auterion ros2bagger
    • rosbag2 at foxy-future

ROS 2 Foxy

# Set locale
sudo apt update
sudo apt install -y locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8

# Setup ROS 2 sources
sudo apt install -y curl \
        gnupg2 \
        lsb-release \
        python3-pip \
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'

# Install ROS 2 Foxy packages
sudo apt update
sudo apt install -y python3-colcon-common-extensions \
        ros-foxy-ros-base \
        ros-foxy-sensor-msgs \
        ros-foxy-visualization-msgs\
        ros-foxy-image-pipeline

MAVSDK

Note: please request to Auterion the deb files of MAVSDK with the supported features, or request the access to the Auterion/MAVSDK repository

Installation from deb (recommended)

dpkg -i libmavsdk*.deb
sudo ldconfig

Installation from source

git clone --recursive https://github.com/Auterion/MAVSDK.git -b main
cd MAVSDK
cmake -Bbuild/default -DCMAKE_BUILD_TYPE=Release -H.
cmake --build build/default -j$(nproc --all)
# install system-wide
sudo cmake --build build/default --target install
sudo ldconfig

mavlink-router

Please request to Auterion a deb file to install it directly, or follow the instructions in https://github.com/mavlink-router/mavlink-router to build it and install it from source.

Micro XRCE-DDS Agent

Micro XRCE-DDS is used to communicate between PX4 and ROS2. For this, the Micro XRCE-DDS Agent from eProsima is required. Install the agent using the official instructions.

configuration-manager

Please request to Auterion a deb file to install it directly, or follow the instructions in bellow to build it and install it from source.

git clone git@github.com:Auterion/configuration-manager.git
cd configuration-manager
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -H.
cmake --build build -j$(nproc --all)

After that, make sure to copy com.auterion.configuration_manager.conf to /usr/share/dbus-1/system.d/ and edit it in order to add your system user:

<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <policy user="root">
    <allow own="com.auterion.configuration_manager"/>
    <allow send_destination="com.auterion.configuration_manager"
        send_interface="com.auterion.configuration_manager.interface"/>
  </policy>
  <!-- Add your user here -->
  <!-- example user -->
  <policy user="user1"> <!-- replace "user1" with your system username -->
    <allow own="com.auterion.configuration_manager"/>
    <allow send_destination="com.auterion.configuration_manager"
        send_interface="com.auterion.configuration_manager.interface"/>
  </policy>
  <!--**************-->
</busconfig>

DBUS and Glib

sudo apt install -y libdbus-glib-1-dev

MAVSDK-Python and its dependencies

pip3 install --user --upgrade mavsdk

Setup

Build

source /opt/ros/foxy/setup.bash
# Create colcon workspace
mkdir -p colcon_ws/src
cd colcon_ws
# Clone the autopilot-manager package
git clone git@github.com:Auterion/autopilot_manager.git src/autopilot_manager
# Clone the required dependencies
git clone https://gitlab.com/libeigen/eigen.git -b 3.3.9 src/eigen
git clone git@github.com:Auterion/image_downsampler.git src/image_downsampler
git clone git@github.com:Auterion/landing_mapper.git src/landing_mapper
git clone git@github.com:Auterion/landing_planner.git src/landing_planner
git clone git@github.com:Auterion/px4_msgs.git src/px4_msgs
git clone git@github.com:Auterion/timing_tools.git src/timing_tools
# Only on ROS2 Foxy: clone data recording tools
git clone git@github.com:Auterion/ros2bagger.git src/ros2bagger
git clone git@github.com:ros2/rosbag2.git -b foxy-future src/rosbag2
# Build with Release optimizations
colcon build --cmake-force-configure --cmake-args -DCMAKE_BUILD_TYPE=Release

Installing private repos

Some of the repositories listed above are private but they are required components to enable the safe landing feature in the Autopilot Manager. If you are trying to build this repository to use this capability, please contact Auterion either to request access to the necessary repositories or to a deb package to install the libraries system-wide.

mavlink-router config

Warning: if one installs mavlink-router system-wide, one needs to take into account that it is going to route MAVLink data on the system. This might influence the behavior of some of some MAVLink-related applications that the user might have installed on their system. Use it cautiously, making sure that 1. one enables or disables the systemd service, i.e., for testing/using this application locally, enable the service with systemctl enable mavlink-router, and after that, disable it if not using it with systemctl disable mavlink-router, or 2. make sure that the main.conf config file has the correct configuration for all MAVLink endpoints.

To configure the needed endpoints to use with this application, use the following and save it under /etc/mavlink-router/main.conf (or replace/extend the content of the file if it already exists on the system). Note that this one has an endpoint configured for PX4 SITL, which should be replaced with a UART connection in the case one is installing this on a Mission Computer connect to an autopilot through a serial port.

    [General]
    TCPServerPort = 4
    ReportStats = False
    DebugLogLevel= info
    MavlinkDialect = common
    Log = /data/log/flight-stack
    LogMode = while-armed
    MinFreeSpace = 0
    MaxLogFiles=50

    [UdpEndpoint px4-sitl]
    Mode = Eavesdropping
    Address = 0.0.0.0
    Port = 14540

    [UdpEndpoint configuration-manager]
    Mode = Normal
    Address = 127.0.0.1
    Port = 14542

    [UdpEndpoint groundcontrol]
    Mode = Normal
    Address = 127.0.0.1
    Port = 14550

    [UdpEndpoint autopilot-manager]
    Mode = Normal
    Address = 127.0.0.1
    Port = 14590

    # autopilot-manager example scripts
    [UdpEndpoint autopilot-manager-example-scripts]
    Mode = Normal
    Address = 127.0.0.1
    Port = 14591

After saving the file, restart the mavlink-router service with:

systemctl restart mavlink-router

DBUS config

Copy the com.auterion.autopilot_manager.conf on the root of the repo to /usr/share/dbus-1/system.d/:

sudo cp com.auterion.autopilot_manager.conf /usr/share/dbus-1/system.d/

Then, make sure you configure com.auterion.autopilot_manager.conf with your user. For that, you need to edit the file you just copied. Example bellow:

<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
  <policy user="root">
    <allow own="com.auterion.autopilot_manager"/>
    <allow send_destination="com.auterion.autopilot_manager"
        send_interface="com.auterion.autopilot_manager.interface"/>
  </policy>
  <!-- Add your user here -->
  <!-- example user -->
  <policy user="user1"> <!-- replace "user1" with your system username -->
    <allow own="com.auterion.autopilot_manager"/>
    <allow send_destination="com.auterion.autopilot_manager"
        send_interface="com.auterion.autopilot_manager.interface"/>
  </policy>
  <!--**************-->
  <policy context="default">
        <deny own="com.auterion.autopilot_manager"/>

        <deny send_destination="com.auterion.autopilot_manager"/>

        <!-- Basic D-Bus API stuff -->
        <allow send_destination="com.auterion.autopilot_manager"
                send_interface="org.freedesktop.DBus.Introspectable"/>
        <allow send_destination="com.auterion.autopilot_manager"
                send_interface="org.freedesktop.DBus.Properties"/>
        <allow send_destination="com.auterion.autopilot_manager"
                send_interface="org.freedesktop.DBus.ObjectManager"/>
  </policy>
</busconfig>

Install the autopilot-manager

echo "source colcon_ws/install/setup.bash" >> ~/.bashrc

And then source ~/.bashrc or open a new terminal window.

Usage

$ ros2 run autopilot-manager autopilot-manager [OPTIONS...]
  -a --file-custom-action-config	Absolute path to configuration file of the custom actions.
                                        Default: /shared_container_dir/autopilot-manager/data/custom_action/custom_action.json
  -c --file-autopilot-manager-config	Absolute path to configuration file of the overall autopilot manager service.
                                        Default: /shared_container_dir/autopilot-manager/data/config/autopilot_manager.conf
  -m --mavlink-port			MAVLink port to connect the Autopilot Manager MAVSDK instance
                                        through UDP. Default: 14590
  -h --help				Print this message

Or use the provided ROS launch files:

$ ros2 launch autopilot-manager autopilot_manager.launch

The autopilot-manager will be looking for autopilot HEARTBEATs, which will result and timeout and exit if they are not received. So mavlink-router should be running and properly configured with the endpoint where the autopilot is connected.

The configuration-manager should also be running (being it through a systemd service or started manually locally), since it is the service that allows the configuration of the Autopilot Mnager parameters through AMC/QGC. To start it manually, use:

configuration-manager

If built from source and not installed system-wide:

cd configuration-manager/build/src
./configuration-manager

Simulation

A ROS bool parameter named sim can be set when one is using a simulation environment. For that, a ROS param file can be used or rather be passed as an argument on ros2 run.

Note: Before running the autopilot-manager, make sure that the PX4 SITL daemon, mavlink-router and the configuration-manager are running.

Terminal 1

source colcon_ws/install/setup.bash
ros2 launch autopilot-manager static_tf.launch

Terminal 2

source colcon_ws/install/setup.bash
cd colcon_ws
# ROS2 run it
ros2 run autopilot-manager autopilot-manager \
  -a install/autopilot-manager/share/autopilot-manager/data/example/custom_action/custom_action_sitl.json \
  -c install/autopilot-manager/share/autopilot-manager/data/config/autopilot_manager.conf \
  --ros-args -p sim:=true,use_sim_time:=true

Terminal 3

source colcon_ws/install/setup.bash
# Start the Micro XRCE-DDS Agent
MicroXRCEAgent udp4 localhost -p 15555

Using ROS2 launch

Replaces the usage of the commands on terminal 1 and 2 above.

ros2 launch autopilot-manager autopilot_manager_sim.launch

Packaging

Keep in mind that when cross-compiling, the correct toolchain should be installed. Also, MAVSDK should be also installed for that same target.

Dependencies

sudo apt install -y  \
        git \
        qemu-user-static
sudo pip3 install ros_cross_compile

Use ros_cross_compile

ros_cross_compile can be used to compile the package for other architectures, like arm64. For that, it uses qemu to start an emulation in a container of the environment we want to use to build the package. It requires also that MAVSDK gets built for that same architecture or installed during the ros_cross_compile process. The --custom-setup-script --custom-data-dir options can be used. scripts/cross_compile_dependencies.sh gets loaded to the container so to and install the required dependencies to the build process. The following commands can be used to build the package for the arm64 (aarch64) arch and ROS 2 Foxy (we will be building MAVSDK and installing it from source):

# Clone MAVSDK to be built from source
git clone --recursive https://github.com/Auterion/MAVSDK.git -b main /tmp/MAVSDK
# Add COLCON_IGNORE to the MAVSDK dir so colcon doesn't build it
touch /tmp/MAVSDK/COLCON_IGNORE
# Run cross-compilation
ros_cross_compile colcon_ws/src \
  --arch aarch64 \
  --os ubuntu \
  --rosdistro foxy \
  --custom-setup-script colcon_ws/src/autopilot_manager/scripts/cross_compile_dependencies.sh \
  --custom-data-dir /tmp/MAVSDK \
  --skip-rosdep-keys Eigen3 image_downsampler landing_mapper landing_planner px4_msgs timing_tools ros2bagger rosbag2 \
  --colcon-defaults ~/colcon_ws/src/autopilot_manager/scripts/packaging/defaults.yaml

The resulting package installation files can be found in colcon_ws/install_aarch64 and can be copied to the target device, like the Skynode. To use it, just source the setup.bash file inside the install_aarch64 directory:

echo "source <prefix_path>/install_aarch64/setup.bash" >> ~/.bashrc

Contributing

Please follow the contribution guidelines in CONTRIBUTING.

Code format

One requires clang-format-10 to format the code. Use the following command to format it:

sh tools/fix_style.sh .

About

An onboard/mission computer service for higher level interactivity with onboard and flight controller components, using MAVSDK and ROS2/DDS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

0