PX4: dynamic control need for a drone

#1

Hi, dear colleges.

My name is Robin and I am doing my PhD on UAVs in France. I build my drones with raspberry Pi and pixhawks.

In terms of control a drone in the perspective of dynamics, the control inputs should be thrust force and torques, or angular velocity velocity of each motor (as there is a constant linear matrix between those two).

I found there are some discussion on this like
Thrust to throttle in /mavros/setpoint_raw/attitude
Control multicopter via thrust F and moments M

We are still trying to find a solution. If you are interested in this, let us work on that together.

1 Like
#2

@Quadrotor-Developer

1 Like
#3

@robin-ecn Have you tried using the actuator_control setpoints in mavros?

#4

@Jaeyoung-Lim Yes, this is what I am trying to do by sending commands directly to the /actuator_control through mavros.

There is not any mixer that for this purpose, this is why we discussed in the Thrust to throttle in /mavros/setpoint_raw/attitude .

I think I just need a simple mixer, identity transform, for this.

#5

@Jaeyoung-Lim I don’t understand why you need a mixer, you simply command thrust and body torques and you define the geometry of the vehicle. Is this not enough?

#6

@Jaeyoung-Lim, but we can not control the body torque, right? In the /mavros/setpoint_attitude, we can not control the body torque, but only the pose of the drone.

If you mean the /actuator_control, I am not sure what the attitude control set to that by the default mixer are body torques. As I read some of the attitude control.cpp, I do not think the output of the attitude control is the body torque.

This is why I calculate the angular velocity by myself and want to send it to the drone directly.

#7

You can control the torque by /actuator_control topic. /mavros/setpoint_attitude and /actuator_control are two different topics. If you use the actuator_control you are not using the attitude controller

You just need to set the control group accordingly : http://docs.ros.org/api/mavros_msgs/html/msg/ActuatorControl.html

I am not up to date on the current status of mavros on this, but I have used this a few years ago and I could hover with it at least in SITL. As you have communication delay, it won’t fly as nicely as modifying the controller inside the flight controller.

#8

Yes, I agree that /mavros/setpoint_attitude and /actuator_control are two different topic. Let me clarify my question to help our discussion.

For /actuator_control, there is a term float32[8] controls, you mean control[0] for roll, control[1] for ptich, control[2] for yaw and control[3] for thrust?

#9

@robin-ecn Yes. I think that is how the control group 0 is defined

#10

Yes, I agree with this as the fight control group 0. As the mixing/actuator says

0: roll (-1…1)
1: pitch (-1…1)
2: yaw (-1…1)
3: throttle (0…1 normal range, -1…1 for variable pitch / thrust reversers)

However I am not sure they are roll, pitch and yaw torques.:sweat_smile: (I am reading the atitude_control.cpp to get some ideas)

Let us say, If they are normalised torques, is there a way to map the real torque into this normalised way?

#11

@robin-ecn So you simply need to scale it to a reasonable amount. Why not just try it in SITL?

I suspect that you are using ordinary ESCs which don’t have feedback. This means that you don’t know how much thrust the motors are going to generate exactly anyway. You can have a feel for example thrust, if the hover thrust is 0.5 your max thrust will be approximately double the weight of the vehicle.

#12

@Jaeyoung-Lim Thanks for your help. I am trying with a certain scale mapping for this.:grin:

#13

Perhaps someone that is more familiar with the PX4 control scheme can correct me, but if you are running your own controller, you can calculate the forces and torques through PID or whatever other controller you may be using and then treat the mapping to the body as a different problem. This is what I do and I have had good success with this. You will have to define the mapping based on the geometry of your vehicle and the thrust curve of your particular motor/propeller combination.

I typically assume a linear thrust curve and just interpolate between 0 and my maximum measured static thrust. I’m guessing since this is your PhD work that you will want to be a little more precise with this. If I remember correctly, the thrust profile is approximately quadratic and you may or may not need to deal with dynamic thrust issues based on airspeed.

The goal of this is to take the forces and torques calculated in your controller and then map them to values between 0 and 1 (or -1 and 1 if you have reversible ESCs) for output to the actuators. Then you can just pass the outputs directly to your motors.

#14

@Jonathan_Wittmer Thanks for your reply. So in your previous work, what you did was just map the required force and torques to the four values between 0 and 1? All the mapping for your force and torques are linear? Then you publish them to the /actuator_control?

Have your tried this in simulation or in experiment?

#15

@robin-ecn Sorry for the delayed response. Yes that it what I did, I know that in reality, the relationship between force/torque and the ESC value is not linear (I think it is quadratic by the lift/drag equation), but a linear approximation worked pretty well. I use this on a real vehicle in practice and saw acceptable response. I’m assuming you will have some kind of PID or other controller? If so, the controller will take care of correcting for any errors from the linearization. If you want to be precise, you could measure the motor output as a function of input signal and use the data to create your output mapping.

I also used UAVCAN for all of my outputs and modified the driver to bypass the mixers, so you might have to do something a little different if you want to use the PWM outputs. I prefer having direct control over my output values, so I don’t bother with mixers or other intermediate steps.

#16

@Jonathan_Wittmer thanks for your information:grinning. May I ask how you did your linear approximation ?

#17

output = thrust/max_thrust.

You can get max thrust by testing your motor/prop/ESC combination.

#18

@Jonathan_Wittmer, But for the torques?

#19

You know the geometry of your vehicle, right?

T = F*d -> F = T/d

If this is a quadcopter, check out this explanation of how to achieve rotation of a quad. If it is a different configuration or vehicle type, there are other mappings available. In principle, you can use any kind of mapping you want to get from torques to forces.

You will need to know what the angular momentum of your propellers is as a function of speed (or just use one value as a simplification) to get the torque on the vehicle when performing a yaw maneuver.

#20

So to go a little bit further, you probably want to find the forces to achieve each element separately. This gives you 4 forces for each motor that you need to sum up using the principle of superposition.

F = F_thrust + F_pitch + F_roll + F_yaw

F_thrust is the force required to keep the vehicle in the air
F_pitch is from the torque required to pitch or correct pitch errors
F_roll is from the torque required to correct for roll errors
F_yaw is from the torque required to correct for yaw errors

1 Like