Trajectory following with MAVROS OFFBOARD on Raspberry Pi

2023-05-16

原文链接 Trajectory following with MAVROS OFFBOARD on Raspberry Pi——Jaeyoung Lim / August 10, 2016

<div id="main" class="site-main">

<div id="primary" class="content-area">
    <div id="content" class="site-content" role="main">



Trajectory following with MAVROS OFFBOARD on Raspberry Pi

    <div class="entry-meta">
        <a class="author" rel="author" href="https://404warehouse.net/author/gokoreas/">Jaeyoung Lim</a> / <a class="entry-date" href="https://404warehouse.net/2016/08/10/trajectory-following-with-mavros-on-raspberry-pi/">August 10, 2016</a>       </div><!-- .entry-meta -->
</header><!-- .entry-header -->

<div class="entry-content">
    <blockquote><p>Jaeyoung Lim<br>

This post is written with the work done with Modulabs DCU Lab

Introduction

Implementing a onboard computer on a small UAS can have many benefits such as being able to use ROS onboard the system. This can speed up the development process and enable to use various sensors and actuators that are supported by the ROS community. I have recently written articles on how to use MAVROS to fly a PX4 based quadrotor. However the articles do not cover operating such a system outdoors. Operating outdoors can have many issues as configuring a network or the change of localization performances and the presence of the environment. This article describes my experience on the implementation and operation of a ROS controlled MAV outdoors so that the reader can avoid the mistakes that I have made. Raspberry Pi 2 B+ was used for the onboard computer running ROS.

Results

A simple trajectory generation node was implemented to generate a circular trajectory for the quadrotor to follow. The radius was 6 m at a 15m altitude with the angular rate of 0.4 rad/s.

class="youtube-player" type="text/html" width="840" height="400" src="https://www.youtube.com/embed/9pOydoNeV_U?version=3&rel=1&fs=1&autohide=2&showsearch=0&showinfo=1&iv_load_policy=1&wmode=transparent" allowfullscreen="true">

The video shows the comparison of the real flight with the gazebo SITL simulation. The video shows that the SITL is pretty accurate with the real flight.

Hardware Setup

Quadrotor Hardware

IMG_1039
The quadrotor is a custom built quadrotor based on the PX4 flight stack. The quadrotor has a 8X4.5 inch props with a 1200kv motor running on a 3S Lipo. Pixhawk was used for the flight controller and the quadrotor is capable of flying and basic waypoint based autonomous missions without the existence of the companion computer.

Companion Computer

Raspberry Pi 2 B+ was used for the companion computer with the pixhawk flight controller. It is not specificly a good choice to use the Raspberry Pi as a companion computer. Raspberry Pis are cheap and fun to use but using raspbian may cause build problems in some packages in ROS.

pixhawk_raspberryPi

The companion computer is stacked on top of the flight controller. The TX/RX pins are connected to the TELEM2 port on Pixhawk. From the guide Raspberry Pi is getting power from the TELEM2 port but the Raspberry Pi was keep turning off as the 5V bus on the TELEM2 port was not providing enough current. Thus, the power is provided from the 5V bus on the servo rail which is powered by a UBEC from the ESC. Powering Raspberry Pi through GPIO is not recommended as there are no regulator or backward protection. However, As I am powering the Raspberry Pi through a UBEC, it is safer.

A 5.4 wifi dongle was used for network connections.

Software configuration

softwareOverview

PX4 configuration

As the Raspberry Pi UART port only supports upto 57600 bps, the baudrate of the SYS_COMPANION parameter should be set accordingly. This is different with using the FTDI. This degrades the performance of the OFFBOARD control capabilities, but as the example on this article covers only setpoint position messages, 57600bps is enough to do the job.


SYS_COMPANION 57600
  

ROS configuration

Ubuntu 14.04 was used for the OS as there were some build issues using Raspbian Jessie. Ubuntu officially supports raspberry Pi, so the image was used on the raspberry Pi.
ROS indigo was used in this project. This was a decision made from the fact that ubuntu 14.04 and ROS indigo on raspberry pi was tested in a previous example.

MAVROS configuration

The name of the UART port on Raspberry Pi 2 is ttyAMA0. This should be configured in the launch file.


fcu_ur:=/dev/ttyAMA0:57600  

To test run a mavros node without making a launch file you can use:


ronrun mavros mavros_node _fcu_url:="/dev/ttyAMA0:57600"
  

You can check if the connection with the flight controller is properly done using rostopic tools such as:


rostopic echo /mavros/imu/data
  

This command echos the imu data from the flight controller and prints it on the screen.

Trajectory Publisher node

rqtgraph
The node is a simple publisher publishing position setpoints to the quadrotor.


#include   

#include #include #include #include

include “math.h”

double r;
double theta;
double count=0.0;
double wn;

mavros_msgs::State current_state;
void state_cb(const mavros_msgs::State::ConstPtr& msg){
current_state = *msg;
}

int main(int argc, char **argv)
{
ros::init(argc, argv, “offb_node”);
ros::NodeHandle nh;

ros::Subscriber state_sub = nh.subscribe
        ("mavros/state", 10, state_cb);
ros::Publisher local_pos_pub = nh.advertise
        ("mavros/setpoint_position/local", 10);

//the setpoint publishing rate MUST be faster than 2Hz
ros::Rate rate(20.0);


<span class="skimlinks-unlinked">nh.param("pub_setpoints_traj/wn</span>, 1.0);
<span class="skimlinks-unlinked">nh.param("pub_setpoints_traj/r</span> 1.0);
// wait for FCU connection
while(ros::ok() &amp;&amp; current_state.connected){
    ros::spinOnce();
    <span class="skimlinks-unlinked">rate.sleep</span>();
}

geometry_msgs::PoseStamped pose;
<span class="skimlinks-unlinked">pose.pose.position.x</span> = 0;
<span class="skimlinks-unlinked">pose.pose.position.y</span> = 0;
<span class="skimlinks-unlinked">pose.pose.position.z</span> = 2;

//send a few setpoints before starting
for(int i = 100; ros::ok() &amp;&amp; i &gt; 0; --i){
    local_pos_pub.publish(pose);
    ros::spinOnce();
    <span class="skimlinks-unlinked">rate.sleep</span>();
}

ros::Time last_request = ros::Time::now();

while(ros::ok()){


theta = wn*count*0.05;

    <span class="skimlinks-unlinked">pose.pose.position.x</span> = r*sin(theta);
    <span class="skimlinks-unlinked">pose.pose.position.y</span> = r*cos(theta);
    <span class="skimlinks-unlinked">pose.pose.position.z</span> = 15;

count++;

    local_pos_pub.publish(pose);
    ros::spinOnce();
    <span class="skimlinks-unlinked">rate.sleep</span>();
}

return 0;
}

There are two parameters in the launch file which are the radius and the angular rate of the quadrotor. This can be configured from the launch file.

Operatimg the quadrotor

A field box is essential to take all the necessary equipment without forgetting something. The photo below is my go-to toolbox for field tests.
IMG_20160804_131026

For operating a flight controller and a companion computer outdoors, it is convinient to configure a wifi network on the field. A wifi router is used to build a wifi network around a field which is powered by a 3S battery. A connector was built to connect the battery to the DCIn port to power a Wifi router.

IMG_1034

I used putty for the ssh client for the Raspberry Pi. The basic operation procedures in running ROS is as follows.

IMG_20160810_153257

First, the laptop should be connected to the same network as the raspberry pi is connected. Then, open a ssh session and run roscore:


roscore
  

Start a new session and run the launch file that has been configured. In this case:


rosrun modudculab_ros ctrl_traj_test.launch  

For longer range applications, a more powerful router or antenna should be used. Using an ordinary wifi router outdoors seems to work well and simplify the operation process to make the system work.

        <style type="text/css">
        div.wpmrec2x{max-width:610px;}
        div.wpmrec2x div.u > div{float:left;margin-right:10px;}
        div.wpmrec2x div.u > div:nth-child(3n){margin-right:0px;}
        </style>        <div class="wpcnt">
        <div class="wpa wpmrec wpmrec2x" style="display: inline-block !important;">
            <span class="wpa-about">Advertisements</span>
            <div class="u">
                                    <script type="text/javascript" id="s26942">
                    (function(g,$){if("undefined"!=typeof g.__ATA){
                        g.__ATA.initAd({collapseEmpty:'after', sectionId:26942, width:300, height:250});
                        g.__ATA.initAd({collapseEmpty:'after', sectionId:114160, width:300, height:250});
                    }})(window,jQuery);
                </script><div id="adtags-1" 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Trajectory following with MAVROS OFFBOARD on Raspberry Pi 的相关文章

随机推荐

  • 新款 2018款macbook Pro 装双系统教程

    首个阅读量将破万的文章 xff0c 感谢支持 防止无良爬虫 xff0c 开头附上原文链接 xff1a http www cnblogs com xueyudlut p 7498115 html 分割线 苹果笔记本的确高大上 xff0c 外观
  • MATLAB对于文本文件(txt)数据读取的技巧总结(经典中的经典)

    振 动论坛原版主eight 的经典贴 http www chinavib com thread 45622 1 1 html MATLAB 对于文本文件 txt 进行数据读取的技巧总结 经典中的经典 由于本帖内容较多 xff0c 部分转自他
  • 一个止传SWF的好网站

    SwfCabin 是一個免費swf空間 xff0c 最初建立的構想在於 如何在網路上將swf檔分享給別人 使用者可以將swf檔上傳到 SwfCabin 然後獲得一個連結 xff0c 其他人便可以在該頁面看到您所上傳的swf檔案 上傳檔案時
  • SqlServer教程:经典SQL语句集锦

    SQL分类 xff1a DDL 数据定义语言 CREATE xff0c ALTER xff0c DROP xff0c DECLARE DML 数据操纵语言 SELECT xff0c DELETE xff0c UPDATE xff0c INS
  • matlab练习程序(获取鼠标坐标)

    还是一个函数的使用ginput clear all close all clc img 61 ones 200 200 imshow img x y 61 ginput 这里鼠标左键点击一次 x y 添加一个值 xff0c 点四次就有四个值
  • 收到了免费的Visual Studio 2005 EE

    昨天 xff0c 收到了Micorsoft寄来的MSDN开发精选 xff08 5 xff09 xff0c 其中就包含了SQL Server 2005 Express Edition和Visual c 2005 EE xff0c xff0c
  • H3C交换机SNMP配置详解

    H3C交换机SNMP配置 1 启动 关闭SNMP Agent服务 在系统视图模式下 xff1a 启用 xff1a snmp agent 关闭 xff1a undo snmp agent 注 xff1a 缺省情况下snmp agent是关闭的
  • ppp的chap认证完全配置

    网络环境 xff1a CHAP认证命令 xff1a cisco config interface s0 0 cisco config if encapsulation ppp cisco config if ppp authenticati
  • MAVLink认识、使用、自定义

    对mavlink的认识 MAVLink是针对小型飞行器 xff08 MAV xff09 的一个lightweight header only message marshalling library 由头文件构成的信息编组库 它被封装成C结构
  • WHY数学图形可视化工具(开源)

    WHY数学图形可视化工具 软件下载地址 http files cnblogs com WhyEngine WhyMathGraph zip 源码下载地址 http pan baidu com s 1jG9QKq6 软件的开发语言是C 43
  • docker学习笔记16:Dockerfile 指令 ADD 和 COPY介绍

    一 ADD指令 ADD指令的功能是将主机构建环境 xff08 上下文 xff09 目录中的文件和目录 以及一个URL标记的文件 拷贝到镜像中 其格式是 xff1a ADD 源路径 目标路径 如 xff1a test FROM ubuntu
  • 无限“递归”的python程序

    如果一个函数直接或者间接调用了自己 xff0c 那么就形成了递归 xff08 recursion xff09 xff0c 比如斐波那契数列的一个实现 def fib n if n lt 61 2 return 1 else return f
  • FreeRTOS 二值信号量,互斥信号量,递归互斥信号量

    以下转载自安富莱电子 xff1a http forum armfly com forum php 本章节讲解 FreeRTOS 任务间的同步和资源共享机制 xff0c 二值信号量 二值信号量是计数信号量的一种特殊形式 xff0c 即共享资源
  • 替代vnc图像远程工具NOMACHINE

    最近再做关于oracle rac集群的实验 难免要在图像界面下进行操作 以前都用的是vnc 但是vnc貌似比较占资源而已图像质量不是很好 今天无意发现了一个替代VNC的好工具NOMACHINE 它的官方网址是 http www nomach
  • antd-design LocaleProvider国际化

    1 LocaleProvider 使用 React 的 context 特性 xff0c 只需在应用外围包裹一次即可全局生效 import LocaleProvider from 39 antd 39 import zh CN from 3
  • python 读取文件、并以十六进制的方式写入到新文件

    usr bin env python infile 61 file 34 in mp3 34 34 rb 34 outfile 61 file 34 out txt 34 34 wb 34 def main while 1 c 61 inf
  • perl的内置函数scalar

    scalar可以求数组的长度 xff0c 但是 xff0c 在scalar的说明里面并没有这一项 Forces EXPR to be interpreted in scalar context and returns the value o
  • sqlalchemy批量删除数据、全量删除

    问题 xff1a sqlalchemy如何批量删除多条数据 解决 xff1a 使用参数synchronize session 61 False xff0c 或for循环 方法 xff1a users 61 self db query Use
  • 经典的同态滤波算法的优化及其应用参数配置。

    同态滤波 xff0c 网络上有很多文章提到过这个算法 xff0c 我们摘取百度的一段文字简要的说明了该算法的核心 xff1a 同态滤波是一种减少低频增加高频 xff0c 从而减少光照变化并锐化边缘或细节的图像滤波方法 关于该算法 xff0c
  • Trajectory following with MAVROS OFFBOARD on Raspberry Pi

    原文链接 Trajectory following with MAVROS OFFBOARD on Raspberry Pi Jaeyoung Lim August 10 2016 404warehouse Small Projects B