11945 Commits

Author SHA1 Message Date
Mathieu Bresciani
220f5cc565
mc_pos_control: Explicitly convert tilt variables to radians during check and assignments 2019-06-27 12:38:00 -04:00
Lorenz Meier
4a1d16a06b
MAVLink module: Add additional IMUs as default outputs
This simplifies setup and verification of systems, as all three sensors can be looked at in a graph view.
2019-06-26 10:25:00 -04:00
Matthias Grob
415b366c54
mc_att_control: Increase default rate integral gain
@bkueang and me realized that on every frame we tune the integral gain for
the roll and pitch rate controller is much too low. Usually it needs to be
increased to 0.3 or even 0.4 to have better "locked in" flight performance
and 0.2 seems like a good compromise for a safe default.
2019-06-24 12:36:34 -04:00
Beat Küng
6956d85e10
mc rate controller: add I term reduction factor
Reduce the I gain for high rate errors to reduce bounce-back effects after
flips. Up to 200 degrees the gain is almost not reduced (<25%), so this
will only take noticeable effects for large errors (setpoint changes),
where we actually want to have an effect.

This allows to increase the MC_*RATE_I parameters w/o negative effects
when doing flips (i.e. bounce-back after flips).

The 400 degrees limit and the x^2 are empirical.

The better the rate tracking in general (high P gain), the less this is
required (because of the lower tracking error). At the same time it also
does not harm, as the i_factor will always be close to 1.
2019-06-24 11:56:57 -04:00
Matthias Grob
0c110a4443
vtol_att_control: apply multicopter takeoff hotfix also for vtol (#12250)
Please see reference:
https://github.com/PX4/Firmware/issues/12171
2019-06-12 14:16:06 -04:00
Matthias Grob
ea48cd4970 Takeoff: address @RomanBapst's review comments 2019-05-22 22:05:38 +02:00
Matthias Grob
1c776f16ec mc_att_control: fix applying not updated thrust setpoint 2019-05-22 22:05:38 +02:00
Matthias Grob
953e5e5019 Revert "mc_att_control: fix having high thrust when disarmed"
This reverts commit 0c81a19decde6ddfe4ce87c34c762ea15fd3ab09.
2019-05-22 22:05:38 +02:00
Matthias Grob
fac3e1c3f9 mc_pos_control: switch back to velocity ramp
But fix the two crucial problems:
- When to begin the ramp?
There's a calculation now for the velocity ramp initial value
such that the resulting thrust is zero at the beginning.
- When to end the ramp?
The ramp is applied to the upwards velocity constraint and it
just ramps from the initial value to the velocity constraint
which is applied during flight. Slower/going down is always possible.
2019-05-22 22:05:38 +02:00
Matthias Grob
90c6fea408 mc_pos_control_params: user friendly default spool/rampup times 2019-05-22 22:05:38 +02:00
Matthias Grob
856d129bf8 mc_pos_control: fix updating takeoff state when no flight task is running
Without always updating the takeoff state it will not get skipped when
the takeoff happened manually and when you switch from manual to position
mode the drone goes to idle and falls.
2019-05-22 22:05:38 +02:00
Matthias Grob
a9f0981aaf mc_pos_control: fix adjusting the wrong setpoint
There are two local_position_setpoint in the position controller.
One describing the setpoint the task gives to the position controller
and a second one with the output of the position controller. I corrected
the wrong one during takeoff because the new takeoff thrust ramp runs after
the controller and not before.
2019-05-22 22:05:38 +02:00
Matthias Grob
ad6eb19f09 Add a Takeoff class to handle multicopter takeoff
In a deterministic way with clear states to go through.
2019-05-22 22:05:38 +02:00
Matthias Grob
da533a7b1d mc_pos_control: replace takeoff velocity ramp with thrust ramp
The velocity ramp had problems with:
- different vehicle tunings resulted in the start value of the resulting
thrust ramp staring either higher and lower than zero thrust.
lower -> delay of beginning
higher -> small jump at beginning
- when a task set position and velocity at the same time during takeoff
(which AutoSmoothVel does) it resulted in a velocity setpoint
jump at the end of the ramp because the additional velocity
setpoint correction from the position controller was not considered.

The thrust ramp should now be very deterministic:
- always start at zero
- always end at the curreant thrust setpoint output
of the complete position controller
2019-05-22 22:05:38 +02:00
Matthias Grob
e73218d665 mc_pos_control/FlightTasks: trigger takeoff based on task
The initial idea of the flight task architecture was that
a task can freely set it's setpoints and doesn't have to
worry about takeoff and landing. It would just takeoff
when it's landed and there's a setpoint to go up and
land when it puts a setpoint that pushes into the ground.
With the takeoff logic there are some significant interface
problems depending on the way a task is implemented:
From the setpoint is not high enough to trigger to
an unexpected takeoff because of some estimator
fluctuation affecting the setpoint. It's easiest to solve this
by allowing the task to determine when a takeoff is triggered.
If no condition is implemented by default a task is not
allowing a takeoff  and cannot be used to get the vehicle
off the ground.
2019-05-22 22:05:38 +02:00
Matthias Grob
9ba748e67e mc_att_control: fix having high thrust when disarmed
After boot the user is in manual mode and if he has an RC
but doesn't switch out the thrust gets set to the throttle stick
position. When he then starts a takeoff from tablet the thrust is still
high while arming and the land detector immediately sees a takeoff
skiping smooth takeoff from the position controller.
2019-05-22 22:05:38 +02:00
Matthias Grob
ae96e16c73 mc_pos_control: initialize takeoff altitude reference
according to @dagar's review comment.
2019-05-22 22:05:38 +02:00
Matthias Grob
8036efd7f2 mc_pos_control: refactor takeoff trigger conditions to be positive 2019-05-22 22:05:38 +02:00
Matthias Grob
5e23883376 mc_pos_control: fix smooth takeoff ramp
- start from a velocity setpoint pushing into the ground
to ramp from idle thrust up.
- start with a bit higher velocity setpoint threshold to make
sure the vehicle has a chance to really get off the ground.
- calculate ramp slope from initialization setpoint to the desired one
instead from zero to the desired. this ramps up quicker when you demand
a very small upwards velocity like the AutoLineSmoothVel and
ManualPositionSmoothVel tasks do at the beginning.
- don't stay in the takeoff ramp depending on the land detector, this
is unnecessary.
2019-05-22 22:05:38 +02:00
Matthias Grob
bc77302fc9 mc_pos_control: refactor smooth takeoff names
The comments and variable names were partly misleading.
I grouped all members, hopefully gave them more
understandable names and adjusted the comments.
2019-05-22 22:05:38 +02:00
Matthias Grob
6d5d09c231 mc_pos_control: refactor smooth takeoff call
There were two rather confusing function calls one to check
if smooth takeoff needs to be ran and one that updates it.
I combined them and documented the interface correctly
making the parameters non-reference const floats.
2019-05-22 22:05:38 +02:00
Mathieu Bresciani
4b2d01dea1 MPC parameters - Update from Matthias' comments
Co-Authored-By: Matthias Grob <maetugr@gmail.com>
2019-05-17 14:15:29 +02:00
bresch
b726d8df0d Add jerk parameter for auto mode MPC_JERK_AUTO. Specify when a parameter is only used in a certain manual or auto mode 2019-05-17 14:15:29 +02:00
Julian Oes
9d8015d029 modules/lib: ignore address-of-packed-member
For now we need to ignore this warning which GCC 9 shows for the MAVLink
headers.
2019-05-16 13:06:25 +02:00
Oleg Kalachev
77097b6adc commander: update commander status when offboard control mode changed 2019-05-11 10:30:57 -04:00
Matthias Grob
868b4e1746 Testing: correct license headers 2019-05-09 09:42:46 +02:00
Matthias Grob
01e9b2cde8 AttitudeControlTest: compare vectors, not every element 2019-05-09 09:42:46 +02:00
Matthias Grob
2cd0344712 AttitudeControlTest: fix style 2019-05-09 09:42:46 +02:00
Matthias Grob
63b967f5df Add unit testing possibility using googletest on POSIX 2019-05-09 09:42:46 +02:00
Roman Bapst
816aa0ffb6 VTOL transitions: use FW attitude loop (#11911)
* VTOL trans: changed that now in transition for both MC and FW the corresponding (correct) attitude controller is running
* attitude setpoint for stabilized mode is generated by tailsitter.cpp
* reset yaw setpoint during transition to avoid big yaw errors after
transition back to hover
* VT_TYPE parameter: added "reboot required" metadata
2019-05-08 10:33:13 -04:00
Matthias Grob
f30f12341f PositionControl: tiny minimal thrust length
To be able to still infer the direction of the thrust vector we
limit it to a minimal length even if MPC_THR_MIN is set to zero.

Note: This is a hotfix for certain specific applications.
The direction of the thrust vector in this corner case is very
likely to get into the tilt limit which is generally undesired.
2019-05-08 03:08:45 -05:00
bresch
02f0533ee9 Commander - Remove old code that overrides state_machine_helper logic 2019-05-07 17:45:28 +02:00
bresch
6d8d8e3c88 MC gyro cutoffs - Reduce IMU_GYRO_CUTOFF to 30Hz and disable MC_DTERM_CUTOFF.
A low gyro cutoff is needed for most medium/large size drones as the structural natural and blade-pass frequencies are low.
A higher value is still desirable for small platforms surch as racers
or well isolated autopilots and should be tuned by the user.
Specific values for config files are untouched.
The cutoff filter for the D term is disabled here as the required
cutoff frequency for the default D term of the rate controller is higher
than the gyro cutoff. In that case, enabling the D term cutoff would
just add some undesired phase lag to the derivative.
2019-05-07 12:15:51 +02:00
Daniel Agar
3d22da9cbe
wind_estimator fix true airspeed usage 2019-05-06 15:25:33 -04:00
Oleg Kalachev
7ec6f0dca6 lpe: use minimum flow altitude from uORB instead of hardcoding 2019-05-05 02:57:58 -05:00
Beat Küng
74990cadc8 uorb: avoid printf while DeviceMaster is locked
This fixes a potential dead-lock when 'uorb status' was used via MAVLink
shell.
The dead-lock chain is: DeviceMaster::lock() -> printf -> output to a pipe,
which blocks until a reader reads the data. In that case it's mavlink.
If mavlink makes a call that requires DeviceMaster::lock() (such as
orb_exists), it dead-locks.

This patch moves all printf's out of the locked state.
2019-05-02 10:26:41 +02:00
Matthias Grob
29719894f7 AttitudeControl: remove unused setter 2019-04-30 23:18:44 -05:00
Matthias Grob
269d077fae ekf2: only check ground effect if it's configured 2019-04-30 12:34:28 +02:00
Roman
f034d2da19 ekf2: fixed bug in baro ground effect triggering logic
- when either terrain data was temporarily not valid (flying at high
distance to the ground) or the vehicle was not close to the ground
(_param_ekf2_gnd_max_hgt) the ekf switched to using the land detector
ground effect flag.

Signed-off-by: Roman <bapstroman@gmail.com>
2019-04-30 12:34:28 +02:00
Daniel Agar
9bad61b86b
Improve robustness to bad and lost airspeed data (#11846) 2019-04-30 03:08:23 -04:00
Roman
2bd8b517c5 FwPositionControl: don't do takeoff help for vtol
- takeoff help is used for fixed wings, it increases the altitude setpoint
after a launch. A vtol does not need this as it's already sufficiently
high up in the air.

Signed-off-by: Roman <bapstroman@gmail.com>
2019-04-30 02:45:49 -04:00
Matthias Grob
56591954ad Commander: reevaluate RC mode on altitude lock 2019-04-29 13:24:29 -04:00
Daniel Agar
f032d0d9fc
SYS_MC_EST_GROUP mark LPE unsupported and update airframes (#11925) 2019-04-29 11:50:36 -04:00
Daniel Agar
2142459027 Revert "simulator: remove hack for diff_pressure noise"
This reverts commit 4a71984f77249230787b7d263d866d6cfa78a7ac.
2019-04-29 10:46:38 -04:00
Julian Oes
4a71984f77 simulator: remove hack for diff_pressure noise
The noise for airspeed is now applied on the Gazebo side and we can
remove this hack.
2019-04-28 18:22:21 -04:00
Matthias Grob
3bf5d6af12 commander: fix RC mode switch not getting applied after boot
the condition to enter the rc mode switch evaluation was neglecting
the first connection of an RC when "no RC switch changed". this means
depending on the actual initialization values of _last_sp_man and the
desired mode preselected on the RC while connecting it would not get
evaluated.
2019-04-26 21:04:10 +02:00
Matthias Grob
f177a68da9 commander: negate main_state_rc entering condition
pure refactor using De Morgan's law to make the condition more intuitive
since you think about when should I enter and not when should I skip
2019-04-26 21:04:10 +02:00
Matthias Grob
1f3ebd98b1 commander: split up set_main_state_rc entering condition
pure refactor of the huge condition into smaller const bool junks
2019-04-26 21:04:10 +02:00
bresch
89bc68e12b Auto - Rename MC_YAWRAUTO_MAX -> MPC_YAWRAUTO_MAX 2019-04-26 12:43:26 +02:00
bresch
581d25f77f Auto mode traj - limit yaw setpoint rate of change when generated in the flight task instead of clamping the yaw rate in the controller
Move yaw setpoint slew rate from AutoLineSmoothVel to Auto. The slew rate is now applied consistently to all the auto FlightTasks
2019-04-26 12:43:26 +02:00