# Position trajectory to MC position control

**URL:** <https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376>\
**Category:** PX4 Autopilot\
**Created:** [August 1, 2018, 10:14am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376 "2018-08-01T10:14:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuloski](https://discuss.px4.io/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tuloski](https://discuss.px4.io/u/tuloski)\
**Post date:** [August 1, 2018, 10:14am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/1 "2018-08-01T10:14:23Z")

</div>

Hi,  
I have a few questions about the position control.  
My goal is to send a real-time reference trajectory from the companion computer to the position control. My trajectory consists of position, velocity, acceleration and jerk.

My questions:

- Are velocity,acceleration and jerk used in the position/attitude control for the feedforward?
- Is the SET\_POSITION\_TARGET\_LOCAL\_NED message supported, i.e. if I send that message with a certain frequency, is like a trajectory is passed directly to the position/attitude control? Or is it used more like a waypoint?

---

<div class="post-metadata">

**Author:** ![Jaeyoung-Lim](https://discuss.px4.io/user_avatar/discuss.px4.io/jaeyoung-lim/32/10829_2.png) [@Jaeyoung-Lim](https://discuss.px4.io/u/Jaeyoung-Lim)\
**Post date:** [August 1, 2018, 1:07pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/2 "2018-08-01T13:07:02Z")

</div>

@tuloski You need a seperate controller in order to follow a trajectory. I am doing it by using offboard control setpoints using mavros.

It is still in a work-in-progress, but hope it helps.

> **[Jaeyoung-Lim/mavros\_controllers](https://github.com/Jaeyoung-Lim/mavros_controllers)**
>
> Aggressive trajectory tracking using mavros for PX4 enabled vehicles - Jaeyoung-Lim/mavros\_controllers

---

<div class="post-metadata">

**Author:** ![tuloski](https://discuss.px4.io/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tuloski](https://discuss.px4.io/u/tuloski)\
**Post date:** [August 1, 2018, 1:15pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/3 "2018-08-01T13:15:22Z")

</div>

Ok thanks.  
But if I need to use a different controller I’ll implement mine: [https://ieeexplore.ieee.org/document/7458128/](https://ieeexplore.ieee.org/document/7458128/) 🙂

Even though the works from Lee and Scaramuzza are very good.

But now what would happen if I send the SET\_POSITION\_TARGET\_LOCAL\_NED?

---

<div class="post-metadata">

**Author:** ![Jaeyoung-Lim](https://discuss.px4.io/user_avatar/discuss.px4.io/jaeyoung-lim/32/10829_2.png) [@Jaeyoung-Lim](https://discuss.px4.io/u/Jaeyoung-Lim)\
**Post date:** [August 1, 2018, 1:50pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/4 "2018-08-01T13:50:19Z")

</div>

@tuloski The project is intended to implement different controllers, so contributing to the repo will be also cool.

As long as you don’t have position setpoints dynamically moving, the quad will follow the trajectory.

The video below shows position setpoints sent to a quad at 100Hz using mavros. However, this approach will fail when your trajectory is dynamic.

---

<div class="post-metadata">

**Author:** ![tuloski](https://discuss.px4.io/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tuloski](https://discuss.px4.io/u/tuloski)\
**Post date:** [August 1, 2018, 1:56pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/5 "2018-08-01T13:56:45Z")

</div>

> [@Jaeyoung-Lim](#):
>
> The video below shows position setpoints sent to a quad at 100Hz using mavros. However, this approach will fail when your trajectory is dynamic.

It will fail because the controller is not able to handle it? What do you mean by dynamic? Aggressive?

> [@Jaeyoung-Lim](#):
>
> The project is intended to implement different controllers, so contributing to the repo will be also cool.

I see, but I prefer to implement low level controllers on the micro and in a real-time environment such as the px4, because on ROS there is no timing guarantee, especially for quick attitude control.

---

<div class="post-metadata">

**Author:** ![Jaeyoung-Lim](https://discuss.px4.io/user_avatar/discuss.px4.io/jaeyoung-lim/32/10829_2.png) [@Jaeyoung-Lim](https://discuss.px4.io/u/Jaeyoung-Lim)\
**Post date:** [August 1, 2018, 3:00pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/6 "2018-08-01T15:00:38Z")

</div>

@tuloski I mean by dynamic trajectories of having high velocity / accelrations.

If you send a position setpoint, the position controller assumes that your target position is static. Once your target position starts to have relatively large accelerations, your position controller will not be able to properly track the setpoint.

---

<div class="post-metadata">

**Author:** ![chmi0611](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@chmi0611](https://discuss.px4.io/u/chmi0611)\
**Post date:** [August 7, 2018, 7:20am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/7 "2018-08-07T07:20:59Z")

</div>

@Jaeyoung-Lim Is it possible to implement geometric controller in mc\_att\_control\_main.cpp? If it is impossible, can you tell me why we need seperate controller? Actually, I want to change the control algorithm of firmware from PID to geometric one.

---

<div class="post-metadata">

**Author:** ![Jaeyoung-Lim](https://discuss.px4.io/user_avatar/discuss.px4.io/jaeyoung-lim/32/10829_2.png) [@Jaeyoung-Lim](https://discuss.px4.io/u/Jaeyoung-Lim)\
**Post date:** [August 7, 2018, 7:23am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/8 "2018-08-07T07:23:24Z")

</div>

@chmi0611 It is possible.

However, if you are testing out controllers or in development, it is better to have it running OFFBOARD as you can always shut down the setpoints published from the flight controller and regain control of the vehicle.

---

<div class="post-metadata">

**Author:** ![tuloski](https://discuss.px4.io/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tuloski](https://discuss.px4.io/u/tuloski)\
**Post date:** [August 7, 2018, 7:46am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/9 "2018-08-07T07:46:26Z")

</div>

You probably need to change mc\_pos\_control and mc\_att\_control, the flighttask (where the setpoint is coming) and probably other parts (I didn’t check all the code).

@Jaeyoung-Lim you can test everything in gazebo simulator with SITL.

---

<div class="post-metadata">

**Author:** ![Jaeyoung-Lim](https://discuss.px4.io/user_avatar/discuss.px4.io/jaeyoung-lim/32/10829_2.png) [@Jaeyoung-Lim](https://discuss.px4.io/u/Jaeyoung-Lim)\
**Post date:** [August 7, 2018, 8:43am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/10 "2018-08-07T08:43:06Z")

</div>

@tuloski You are right on that point

---

<div class="post-metadata">

**Author:** ![chmi0611](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@chmi0611](https://discuss.px4.io/u/chmi0611)\
**Post date:** [August 8, 2018, 5:47am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/11 "2018-08-08T05:47:25Z")

</div>

@tuloski @Jaeyoung-Lim

Hi, guys. Thanks for comments.

Currently, I’m trying to modify mc\_att\_control\_main.cpp and mc\_pos\_control\_main.cpp.

> [@Trajectory Following via acceleration setpoints, which controller to use?](http://discuss.px4.io/t/trajectory-following-via-acceleration-setpoints-which-controller-to-use/7106):
>
> Hi, I’m developing a visual-inertial localization and navigation method and using rotors simulator and its integrated position controller, together with mav\_trajectory\_generation ROS package, which allows to build smooth trajectories. In order to follow the trajectory I use rotors position controller, which allows me to set a position/velocity/acceleration setpoint, which then outputs a resulting output acceleration vector to be sent to the vehicle. I’m now attempting experiments using PX4 dron…

> [@How are pwm values set after controllers outputs are calculated for quadrotors?](http://discuss.px4.io/t/how-are-pwm-values-set-after-controllers-outputs-are-calculated-for-quadrotors/3308/3):
>
> Where do we see the transition from \_actuators to outputs?

I read those pages but still not sure about thrust and torque.

As Jaeyoung said, it would be okay to normalize thrust but the problem is torque.

Can you tell me the relationship between \_att\_control and torque?

Or is it okay to use normalized torque as \_att\_control?

---

<div class="post-metadata">

**Author:** ![tuloski](https://discuss.px4.io/letter_avatar_proxy/v4/letter/t/a88e4f/32.png) [@tuloski](https://discuss.px4.io/u/tuloski)\
**Post date:** [August 8, 2018, 7:24am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/12 "2018-08-08T07:24:53Z")

</div>

I still didn’t understand how the output of att\_control is mixed into pwm output.  
I think the normalized wrench is bullsh!t. Every serious controller outputs force (thrust) and torques. IMO the output of the controller should be a not-normalized wrench and then the mixer should be in charge of transforming the desired wrench in actuators output (for example knowing the pwm to thrust curve).

@chmi0611 which controller are you trying to implement? If needed I should have somewhere the Simulink code and the C code generated from simulink about the controller I developed and linked a few posts before.

---

<div class="post-metadata">

**Author:** ![Jaeyoung-Lim](https://discuss.px4.io/user_avatar/discuss.px4.io/jaeyoung-lim/32/10829_2.png) [@Jaeyoung-Lim](https://discuss.px4.io/u/Jaeyoung-Lim)\
**Post date:** [August 8, 2018, 7:36am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/13 "2018-08-08T07:36:13Z")

</div>

@chmi0611 I am not sure what you want to know about the realsionship between attcontrol and torque?

If you want more information on the controller, the [controller diagram](https://dev.px4.io/en/flight_stack/controller_diagrams.html) might help you understand how the controller works.

The scale of the torque may change depending on your airframe. However, this will not (until some extend) change the stability of your controller and can be also tuned by the PID values.

---

<div class="post-metadata">

**Author:** ![chmi0611](https://discuss.px4.io/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@chmi0611](https://discuss.px4.io/u/chmi0611)\
**Post date:** [August 9, 2018, 1:05am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/14 "2018-08-09T01:05:50Z")

</div>

@tuloski I’m trying geometric tracking controller same with Jaeyoung.

@Jaeyoung-Lim I mean, is it okay to use torque as att\_control.

In the diagram, it seems that derivative of body rate vector is att\_control.

But when I read this page ([https://dev.px4.io/en/concept/mixing.html](https://dev.px4.io/en/concept/mixing.html)), it should be attitude, not a derivative of rate vector.

I get confused.

---

<div class="post-metadata">

**Author:** ![Vrinda](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/839c29/32.png) [@Vrinda](https://discuss.px4.io/u/Vrinda)\
**Post date:** [October 22, 2018, 8:37pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/15 "2018-10-22T20:37:01Z")

</div>

Hello @Jaeyoung-Lim ! I wanted to implement trajectory tracking in SITL. I found this tutorial [https://404warehouse.net/2016/08/10/trajectory-following-with-mavros-on-raspberry-pi/](https://404warehouse.net/2016/08/10/trajectory-following-with-mavros-on-raspberry-pi/). I wanted to implement trajectory tracking without geometric controller. I needed your advise regarding this, as in which page should I refer to for trajectory tracking

---

<div class="post-metadata">

**Author:** ![Jaeyoung-Lim](https://discuss.px4.io/user_avatar/discuss.px4.io/jaeyoung-lim/32/10829_2.png) [@Jaeyoung-Lim](https://discuss.px4.io/u/Jaeyoung-Lim)\
**Post date:** [October 22, 2018, 11:36pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/16 "2018-10-22T23:36:07Z")

</div>

@Vrinda If you don’t want to run a external controller, you can use the `setpoint_position/local` using [mavros](https://github.com/mavlink/mavros) as shown in [this tutorial](http://dev.px4.io/en/ros/mavros_offboard.html)

---

<div class="post-metadata">

**Author:** ![Vrinda](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/839c29/32.png) [@Vrinda](https://discuss.px4.io/u/Vrinda)\
**Post date:** [October 22, 2018, 11:37pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/17 "2018-10-22T23:37:13Z")

</div>

Yes @Jaeyoung-Lim, I will do as you suggested. Thanks much !

---

<div class="post-metadata">

**Author:** ![robin-ecn](https://discuss.px4.io/user_avatar/discuss.px4.io/robin-ecn/32/3444_2.png) [@robin-ecn](https://discuss.px4.io/u/robin-ecn)\
**Post date:** [January 10, 2019, 10:00am UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/18 "2019-01-10T10:00:45Z")

</div>

> [@Jaeyoung-Lim](#):
>
> you can always shut down the setpoints published from the flight controller and regain control of the vehicle.

Could you please explain a little how we can use torque as att-control? Actually, i am trying to control a drone with the thrust force and torques directly instead of the normlised thrust value and the body rate.

---

<div class="post-metadata">

**Author:** ![Vrinda](https://discuss.px4.io/letter_avatar_proxy/v4/letter/v/839c29/32.png) [@Vrinda](https://discuss.px4.io/u/Vrinda)\
**Post date:** [January 15, 2019, 5:08pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/19 "2019-01-15T17:08:02Z")

</div>

I have not done this. But just a suggestion. You can compute angular acceleration from torque (I don’t know how you will compute inertia of your drone), and from angular acceleration you can compute the desired body rates. I may be wrong.

---

<div class="post-metadata">

**Author:** ![Jaeyoung-Lim](https://discuss.px4.io/user_avatar/discuss.px4.io/jaeyoung-lim/32/10829_2.png) [@Jaeyoung-Lim](https://discuss.px4.io/u/Jaeyoung-Lim)\
**Post date:** [January 15, 2019, 5:51pm UTC](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376/20 "2019-01-15T17:51:29Z")

</div>

@robin-ecn The question is off-topic of this thread. Please create a new topic

[Next page](https://discuss.px4.io/t/position-trajectory-to-mc-position-control/7376.md?page=2)
