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).
@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.
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
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.
@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.
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.
@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?
@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.
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.
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