I have a question about the source code of crazyflie 2.0. In the stabilizer_types.h file, what 'modeDisable', 'modeAbs' and 'modeVelocity' mean?
Thanks.
![:-) :)](./images/smilies/icon_e_smile.gif)
Thank you.tobias wrote: ↑Thu Nov 02, 2017 11:04 am Those should clearly be documented better and quite a bit of legacy involved.
The enum describes what stabilization controllers should be activated for what axis.
To get some idea how to use it look in crtp_commander_rpyt.c
Thank you. I want to test a attitude stabilization algorithm that have three reference inputs, three real-time state inputs and three control outputs. The three reference inputs are roll, pitch and yaw angles we want. The three real-time state inputs, which act as feedback inputs, are real-time roll, pitch and yaw angles of aircraft body. The three outputs are three moments controlling the attitude of aircraft. In the control outputs of the algorithm, there is no thrust for the vertical moment of aircraft. And the experiment of testing the algorithm could be operated on a spherical joint. How should I modify the source code? Thank you.tobias wrote: ↑Mon Nov 06, 2017 12:29 pm In attitude control the controller will try to follow the desired set angle for roll, pitch and yaw. In position control it will instead try to go to and keep the desired position. This though requires some kind of position information.
Maybe you can share a bit what you would like to achieve. Then it will be easier for me to help.
Code: Select all
stabilizerTask()
Code: Select all
getExtPosition(&state);
stateEstimator(&state, &sensorData, &control, tick);
commanderGetSetpoint(&setpoint, &state);
Code: Select all
stateController(&control, &setpoint, &sensorData, &state, tick);
Code: Select all
powerDistribution(&control);
Code: Select all
stateController()
Thank you very much. Before adding my own attitude controller, I want to figure out the current algorithm in the source code. I have a question to ask you. In the source code blew:kristoffer wrote: ↑Fri Nov 10, 2017 10:09 am You can find the main control loop inin stablizer.c.Code: Select all
stabilizerTask()
The first part is about getting and understanding the current state of the system (the actual position, pitch, roll, yaw and so on) and the desired state (the wanted position and/or roll, pitch, yaw).Then we try to calculate what to do to get from the current state to the desired state inCode: Select all
getExtPosition(&state); stateEstimator(&state, &sensorData, &control, tick); commanderGetSetpoint(&setpoint, &state);
Finally the output of the controller is used to control the power for the motors inCode: Select all
stateController(&control, &setpoint, &sensorData, &state, tick);
Code: Select all
powerDistribution(&control);
The state variable describes the current state,
the setpoint variable describes the desired state and
the control variable contains data of how to power the motors.
Theis implemented in controller_pid.c and this is probably the area you want to work on. One option is to add your own controller in a new c file to make it easy to switch back and forth.Code: Select all
stateController()
Code: Select all
typedef struct setpoint_s {
uint32_t timestamp;
attitude_t attitude;
attitude_t attitudeRate;
float thrust;
point_t position;
velocity_t velocity;
struct {
mode_t x;
mode_t y;
mode_t z;
mode_t roll;
mode_t pitch;
mode_t yaw;
} mode;
} setpoint_t;
Thank you very much. Then I downloaded the latest version of the firmware source code, and replaced the old one in the 'projects' file in VM desktop with the latest one. When I click the hammer icon to build the project, the console shows the message:kristoffer wrote: ↑Mon Nov 13, 2017 1:47 pm I think that the use of the setpoint_t has been added to over time, and it has become a bit messy. It could probably be improved
The idea is that the setpoint_t describes the desired state of the system, and this include:
* absolute roll/pitch/yaw as used in the standard "manual" flying mode
* roll/pitch/yaw in rate mode as used by some advanced pilots
* a position (x,y,z) to go to, used with absolute positioning systems such as LPS
* a velocity or rate change for x, y, z or roll, pitch, yaw as used with the flow deck
In some cases you want the desired state to be an absolute position or roll angle for instance, while in other cases you are interested in describing a rate of change or velocity. It must also be possible to tell the controller that one parameter of the setpoint is important while another should be ignored.
This is where the mode comes in:
* modeDisable - ignore this paramater
* modeAbs - the desired state is an absolute value
* modeVelocity - the desired state is a rate (or velocity)
Depending on the mode of a parameter, the controller will use different fields in the setpoint_t to get the actual value (setpoint.attitude, setpoint.attitudeRate and so on)
By the way, I can see that you are not on the latest version of the firmware source code. The mode_t struct was renamed to stab_mode_t in June.