Ask Your Question

How to control pitch, roll, yaw with mavros

asked 2015-07-15 08:14:57 -0600

Tirgo gravatar image

updated 2015-07-16 08:24:15 -0600


i am quiet new to the pixhawk, but quite familiar with ROS. I am searching for some informations how to control the pixhawk via mavros. I am using the px4 firmware. My plan is to use the altiude_hold_mode, so that the multicopter hovers at a specific height. Additionaly i want to control pitch, roll and yaw angles of the multicopter via ROS. A bit like a 2D control in 3D space but at a specific height.

I am a bit lost how to setup my pixhawk with the external computer (an odroid fixed to the multicopter).

I found this tutorial [ ] . So i can control the copter with help of standard ROS messages. More specific i can control: position, attitude, velocity and accelration. Here are my questions: In order to control the copter via mavros, it has to be in offboard_mode. Would this conflict with the altitude_hold_mode? And which message should i use to control roll/pitch/yaw? In my little project the copter has to fly with specific "angles".

Thx for your help.

EDIT1: The connection between the odroid and the pixhawk is working. I can handle the streams (baudrate, Hz) aswell. I am a bit confused about the whole mavros-setpoint part. I will try to order a bit ;).

  1. If i use setpoint_position, how is the actual position of the copter calculated? I think it depends on my sensor setup right? For example distance sensor+GPS. Unfourtanetly i can't use a GPS or Optical Flow. Therefore this method will not work or?

  2. The setpoint_attitude seems more like something that would fit, but it can't offer a stabil z position right? So i would have to read out the distance sensor and regulate the throttle by myself correct?

  3. I wonder if it is easier to use the standard altitude_hold mode of the pixhawk. Additionally i would read out the imu data of the pixhawk and regulate pitch, roll, yaw over mavros/rc/override. Would this also be a possibility?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2015-07-16 06:24:33 -0600

vooon gravatar image

PX4 allow controlling attitude only in OFFBOARD, it is impossible to combine modes.

But depending on control type you may hold altitude. Easiest is when you send position setpoints, just send same Z. You want rpy control, it is done via attitude setpoints (in quaternion form), but in that mode you only control throttle, so altitude controller should be implemented by user.

FCU-OBC connection depends on what computer you use. In general you need 3.3V UART from OBC and connect it to TELEM2. Example: Raspberry Pi UART pins may be directly used; Odroid U3 need level converter 1.8<->3.3; Intel NUC need FTDI USB-UART.

Then you should setup SYS_COMPANION FCU parameter to 921600 or 57600 (depends on maximum baud allowed by your computer). Tip for raspberry pi 2 (and 1 too): place in /boot/config.txt (alternate: /boot/firmware/config.txt) this lines:

# Higher UART Speed
edit flag offensive delete link more


Thx for your help. (Too long for a comment i edit my question.)

Tirgo gravatar image Tirgo  ( 2015-07-16 08:05:50 -0600 )edit

rc/override is APM-only feature. PX4 has actuator_control, but for flying vehicle it is harder that do altitude controller. Position sp uses local position, like data published by local_position plugin. Not sure what if there no global position source, better to ask px4-users.

vooon gravatar image vooon  ( 2015-07-17 05:15:58 -0600 )edit

So the way to go is to use the setpoint_attitude feature to control roll, pitch and yaw. Additionally control the altitude manual by sending throttle commands. Do you know if these features are integrated in the stable version? Or do i need the master version for it?

Tirgo gravatar image Tirgo  ( 2015-07-20 08:27:26 -0600 )edit

All setpoint handling exist while ago, so it is in stable. Also Nuno working on tests for setpoints & PX4 SITL. May be useful.

vooon gravatar image vooon  ( 2015-07-20 11:00:05 -0600 )edit

Hi. I had no time to go on with the project till now. Just another short question. Is the setpoint_attitude feature px4 only? Couldn't find much documentation about it in the apm wikis. PX4 offers the Offboard mode, what is the corresponding mode in apm? Thx

Tirgo gravatar image Tirgo  ( 2015-09-11 02:46:32 -0600 )edit

You can check that in ArduCopter/capabilities.cpp. Current master can handle local or global position setpoints. Mavros only supports local ones. I'm not checked current sources, but previously setpoints wants GUIDED mode.

vooon gravatar image vooon  ( 2015-09-11 03:37:46 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2015-07-15 08:14:57 -0600

Seen: 4,280 times

Last updated: Jul 16 '15