mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 18:06:39 +08:00
docs: overhaul rover documentation
This commit is contained in:
committed by
Hamish Willee
parent
ee3708ca82
commit
22f4222795
@@ -1,433 +0,0 @@
|
||||
# Configuration/Tuning (Ackermann Rover)
|
||||
|
||||
This topic provides a step-by-step guide for setting up your [Ackermann rover](../frames_rover/ackermann.md).
|
||||
|
||||
Successive steps enable [drive modes](../flight_modes_rover/ackermann.md) with more autopilot support and features.
|
||||
|
||||
::: warning
|
||||
Each step is dependent on the previous steps having been completed.
|
||||
Modes will only work properly if the preceding modes have been configured.
|
||||
:::
|
||||
|
||||
## Basic Setup
|
||||
|
||||
To configure the Ackermann rover frame and outputs:
|
||||
|
||||
1. Enable Rover support by flashing the [PX4 rover build](../frames_rover/index.md#flashing-the-rover-build) onto your flight controller.
|
||||
Note that this is a special build that contains rover-specific modules.
|
||||
|
||||
2. In the [Airframe](../config/airframe.md) configuration select the _Generic Rover Ackermann_:
|
||||
|
||||

|
||||
|
||||
Select the **Apply and Restart** button.
|
||||
|
||||
::: info
|
||||
If this airframe is not displayed and you have checked that you are using rover firmware (not the default), you can alternatively enable this frame by setting the [SYS_AUTOSTART](../advanced_config/parameter_reference.md#SYS_AUTOSTART) parameter to `51000`.
|
||||
:::
|
||||
|
||||
3. Open the [Actuators Configuration & Testing](../config/actuators.md) to map the steering and throttle functions to flight controller outputs.
|
||||
|
||||
## Manual Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly the [Basic Setup](#basic-setup) must've already been completed!
|
||||
:::
|
||||
|
||||
The basic setup already covers the minimum setup required to use the rover in [Manual mode](../flight_modes_rover/ackermann.md#manual-mode).
|
||||
|
||||
This mode is also affected by (optional) acceleration/deceleration limits.
|
||||
As configuration of these limits becomes mandatory for subsequent modes, we do this setup here.
|
||||
|
||||
Navigate to [Parameters](../advanced_config/parameters.md) in QGroundControl and set the following parameters:
|
||||
|
||||
1. [RA_WHEEL_BASE](#RA_WHEEL_BASE) [m]: Measure the distance from the back to the front wheels.
|
||||
2. [RA_MAX_STR_ANG](#RA_MAX_STR_ANG) [deg]: Measure the maximum steering angle.
|
||||
|
||||

|
||||
|
||||
3. [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) [m/s]: Drive the rover at full throttle and set this parameter to the observed value of the ground speed.
|
||||
|
||||
:::info
|
||||
This parameter is also used for the feed-forward term of the speed control.
|
||||
It will be further tuned in the configuration of [Position mode](#position-mode).
|
||||
:::
|
||||
|
||||
4. (Optional) [RO_ACCEL_LIM](#RO_ACCEL_LIM) [m/s^2]: Maximum acceleration you want to allow for your rover.
|
||||
|
||||
<a id="RO_ACCEL_LIM_CONSIDERATIONS"></a>
|
||||
|
||||
:::tip
|
||||
Your rover has a maximum possible acceleration which is determined by the maximum torque the motor can supply.
|
||||
This may or may not be appropriate for your vehicle and use case.
|
||||
|
||||
One approach to determine an appropriate value is:
|
||||
|
||||
1. From a standstill, give the rover full throttle until it reaches the maximum speed.
|
||||
1. Disarm the rover and plot the `measured_speed_body_x` from [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md).
|
||||
1. Divide the maximum speed by the time it took to reach it and set this as the value for [RO_ACCEL_LIM](#RO_ACCEL_LIM).
|
||||
|
||||
Some RC rovers have enough torque to lift up if the maximum acceleration is not limited.
|
||||
If that is the case:
|
||||
|
||||
1. Set [RO_ACCEL_LIM](#RO_ACCEL_LIM) to a low value, give the rover full throttle from a standstill and observe its behaviour.
|
||||
1. Increase [RO_ACCEL_LIM](#RO_ACCEL_LIM) until the rover starts to lift up during the acceleration.
|
||||
1. Set [RO_ACCEL_LIM](#RO_ACCEL_LIM) to the highest value that does not cause the rover to lift up.
|
||||
:::
|
||||
|
||||
5. (Optional) [RO_DECEL_LIM](#RO_DECEL_LIM) [m/s^2]: Maximum deceleration you want to allow for your rover.
|
||||
|
||||
:::tip
|
||||
The same [considerations](#RO_ACCEL_LIM_CONSIDERATIONS) as in the configuration of [RO_ACCEL_LIM](#RO_ACCEL_LIM) apply.
|
||||
:::
|
||||
|
||||
:::info
|
||||
This parameter is also used for the calculation of the speed setpoint during [Auto modes](#auto-modes).
|
||||
:::
|
||||
|
||||
6. (Optional) [RA_STR_RATE_LIM](#RA_STR_RATE_LIM) [deg/s]: Maximum steering rate you want to allow for your rover.
|
||||
|
||||
:::tip
|
||||
This value depends on your rover and use case.
|
||||
For bigger rovers there might be a mechanical limit that is easy to identify by steering the rover at a standstill and increasing
|
||||
[RA_STR_RATE_LIM](#RA_STR_RATE_LIM) until you observe the steering rate to no longer be limited by the parameter.
|
||||
For smaller rovers you might observe the steering to be too aggressive. Set [RA_STR_RATE_LIM](#RA_STR_RATE_LIM) to a low value and steer the rover at a standstill.
|
||||
Increase the parameter until you reach the maximum steering rate you are comfortable with.
|
||||
:::
|
||||
|
||||
:::warning
|
||||
A low maximum steering rate makes the rover worse at tracking steering setpoints, which can lead to a poor performance in the subsequent modes.
|
||||
:::
|
||||
|
||||
## Acro Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly [Manual mode](#acro-mode) must've already been configured!
|
||||
:::
|
||||
|
||||
To set up [Acro mode](../flight_modes_rover/ackermann.md#acro-mode) configure the following [parameters](../advanced_config/parameters.md) in QGroundControl:
|
||||
|
||||
1. [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM): Maximum yaw rate you want to allow for your rover.
|
||||
|
||||
:::tip
|
||||
Limiting the yaw rate is necessary if the rover is prone rolling over, loosing traction at high speeds or if passenger comfort is important.
|
||||
Small rovers especially can be prone to rolling over when steering aggressively at high speeds.
|
||||
|
||||
If this is the case:
|
||||
|
||||
1. In [Acro mode](../flight_modes_rover/ackermann.md#acro-mode), set [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM) to a small value and drive the rover at full throttle and with the right stick all the way to the left or right.
|
||||
1. Increase [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM) until the wheels of the rover start to lift up.
|
||||
1. Set [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM) to the highest value that does not cause the rover to lift up.
|
||||
|
||||
If you see no need to limit the yaw rate, set this parameter to the maximum yaw rate the rover can achieve:
|
||||
|
||||
1. In [Manual mode](#manual-mode) drive the rover at full throttle and with the maximum steering angle.
|
||||
2. Plot the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) and enter the highest observed value for [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM).
|
||||
|
||||
:::
|
||||
|
||||
2. [RO_YAW_RATE_P](#RO_YAW_RATE_P) [-]: Proportional gain of the closed loop yaw rate controller.
|
||||
The closed loop acceleration control will compare the yaw rate setpoint with the measured yaw rate and adapt the motor commands based on the error between them.
|
||||
The proportional gain is multiplied with this error and that value is added to the motor command.
|
||||
This compensates for disturbances such as uneven ground and external forces.
|
||||
|
||||
:::tip
|
||||
To tune this parameter:
|
||||
|
||||
1. Put the rover in [Acro mode](../flight_modes_rover/ackermann.md#acro-mode) and hold the throttle stick and the right stick at a few different levels for a couple of seconds each.
|
||||
2. Disarm the rover and from the flight log plot the `adjusted_yaw_rate_setpoint` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) and the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) over each other.
|
||||
3. Increase [RO_YAW_RATE_P](#RO_YAW_RATE_P) if the measured value does not track the setpoint fast enough or decrease it if the measurement overshoots the setpoint by too much.
|
||||
4. Repeat until you are satisfied with the behaviour.
|
||||
:::
|
||||
|
||||
3. [RO_YAW_RATE_I](#RO_YAW_RATE_I) [-]: Integral gain of the closed loop yaw rate controller.
|
||||
The integral gain accumulates the error between the desired and actual yaw rate scaled by the integral gain over time and that value is added to the motor command.
|
||||
|
||||
::: tip
|
||||
An integrator might not be necessary at this stage, but it will become important for subsequent modes.
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Acro mode](../flight_modes_rover/ackermann.md#acro-mode).
|
||||
|
||||
## Stabilized Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly [Acro mode](#acro-mode) must've already been configured!
|
||||
:::
|
||||
|
||||
For [Stabilized mode](../flight_modes_rover/differential.md#stabilized-mode) the controller utilizes a closed loop yaw controller, which creates a yaw rate setpoint to control the yaw when it is active:
|
||||
|
||||

|
||||
|
||||
Unlike the closed loop yaw rate, this controller has no feed-forward term.
|
||||
Therefore you only need to tune the closed loop gains:
|
||||
|
||||
1. [RO_YAW_P](#RO_YAW_P) [-]: Proportional gain for the closed loop yaw controller.
|
||||
|
||||
::: tip
|
||||
In stabilized mode the closed loop yaw control is only active when driving a straight line (no yaw rate input).
|
||||
To tune it start with a value of 1 for [RO_YAW_P](#RO_YAW_P).
|
||||
Put the rover into stabilized mode and move the left stick of your controller up to drive forwards.
|
||||
Disarm the rover and from the flight log plot the `measured_yaw` and the `adjusted_yaw_setpoint` from the [RoverAttitudeStatus](../msg_docs/RoverAttitudeStatus.md) message over each other.
|
||||
Increase/Decrease the parameter until you are satisfied with the setpoint tracking.
|
||||
:::
|
||||
|
||||
::: info
|
||||
For the closed loop yaw control an integrator gain is useful because this setpoint is often constant for a while and an integrator eliminates steady state errors that can cause the rover to never reach the setpoint.
|
||||
Since the yaw and yaw rate controllers are cascaded, there only needs to be one integrator which is in the yaw rate controller. If you observe a steady state error in the yaw setpoint increase the [RO_YAW_RATE_I](#RO_YAW_RATE_I) parameter.
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Stabilized mode](../flight_modes_rover/ackermann.md#stabilized-mode).
|
||||
|
||||
## Position Mode
|
||||
|
||||
:::warning
|
||||
For this mode to work properly [Stabilized mode](#stabilized-mode) must already be configured!
|
||||
:::
|
||||
|
||||
[Position mode](../flight_modes_rover/ackermann.md#position-mode) is the most advanced manual mode, utilizing closed loop yaw rate and speed control and leveraging position estimates.
|
||||
|
||||
To configure set the following parameters:
|
||||
|
||||
1. [RO_SPEED_LIM](#RO_SPEED_LIM) [m/s]: This is the maximum speed you want to allow for your rover.
|
||||
This will define the stick-to-speed mapping for position mode and set an upper limit for the speed setpoint for all [auto modes](#auto-modes).
|
||||
2. [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) [m/s]: This parameter is used to calculate the feed-forward term of the closed loop speed control which linearly maps desired speeds to normalized motor commands.
|
||||
As mentioned in the [Manual mode](../flight_modes_rover/ackermann.md#manual-mode) configuration , a good starting point is the observed ground speed when the rover drives at maximum throttle in [Manual mode](../flight_modes_rover/ackermann.md#manual-mode).
|
||||
|
||||
<a id="RA_SPEED_TUNING"></a>
|
||||
|
||||
::: tip
|
||||
To further tune this parameter:
|
||||
|
||||
1. Set [RO_SPEED_P](#RO_SPEED_P) and [RO_SPEED_I](#RO_SPEED_I) to zero.
|
||||
This way the speed is only controlled by the feed-forward term, which makes it easier to tune.
|
||||
1. Put the rover in [Position mode](../flight_modes_rover/ackermann.md#position-mode) and then move the left stick of your controller up and/or down and hold it at a few different levels for a couple of seconds each.
|
||||
1. Disarm the rover and from the flight log plot the `adjusted_speed_body_x_setpoint` and the `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other.
|
||||
1. If the actual speed of the rover is higher than the speed setpoint, increase [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED).
|
||||
If it is the other way around decrease the parameter and repeat until you are satisfied with the setpoint tracking.
|
||||
|
||||
:::
|
||||
|
||||
::: info
|
||||
If your rover oscillates when driving a straight line in [Position mode](../flight_modes_rover/ackermann.md#position-mode), set this parameter to the observed ground speed at maximum throttle in [Manual mode](../flight_modes_rover/ackermann.md#manual-mode) and complete steps 5-7 first before continuing the tuning of the closed loop speed control (Steps 2-4).
|
||||
:::
|
||||
|
||||
3. [RO_SPEED_P](#RO_SPEED_P) [-]: Proportional gain of the closed loop speed controller.
|
||||
|
||||
::: tip
|
||||
This parameter can be tuned the same way as [RO_MAX_THR_SPEED](#RA_SPEED_TUNING).
|
||||
If you tuned [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) well, you might only need a very small value.
|
||||
:::
|
||||
|
||||
4. [RO_SPEED_I](#RO_SPEED_I) [-]: Integral gain for the closed loop speed controller.
|
||||
|
||||
::: tip
|
||||
For the closed loop speed control an integrator gain is useful because this setpoint is often constant for a while and an integrator eliminates steady state errors that can cause the rover to never reach the setpoint.
|
||||
:::
|
||||
|
||||
5. [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN): When driving in a straight line (right stick centered) position mode leverages the same path following algorithm used in [auto modes](#auto-modes) called [pure pursuit](#pure-pursuit-guidance-logic) to achieve the best possible straight line driving behaviour ([Illustration of control architecture](#pure_pursuit_controller)).
|
||||
This parameter determines how aggressive the controller will steer towards the path.
|
||||
|
||||
::: tip
|
||||
Decreasing the parameter makes it more aggressive but can lead to oscillations.
|
||||
|
||||
To tune this:
|
||||
|
||||
1. Start with a value of 1 for [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN)
|
||||
2. Put the rover in [Position mode](../flight_modes_rover/ackermann.md#position-mode) and while driving a straight line at approximately half the maximum speed observe its behaviour.
|
||||
3. If the rover does not drive in a straight line, reduce the value of the parameter, if it oscillates around the path increase the value.
|
||||
4. Repeat until you are satisfied with the behaviour.
|
||||
|
||||
:::
|
||||
|
||||
6. [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN): Minimum threshold for the lookahead distance used by the [pure pursuit algorithm](#pure-pursuit-guidance-logic).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/ackermann.md#position-mode) and drive at very low speeds, if the rover starts to oscillate even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then increase the value of [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
:::
|
||||
|
||||
7. [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX): Maximum threshold for the lookahead distance used by [pure pursuit](#pure-pursuit-guidance-logic).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/ackermann.md#position-mode) and drive at very high speeds, if the rover does not drive in a straight line even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then decrease the value of [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX).
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Position mode](../flight_modes_rover/ackermann.md#position-mode).
|
||||
|
||||
## Auto Modes
|
||||
|
||||
::: warning
|
||||
For auto modes to work properly [Manual Mode](#manual-mode), [Acro mode](#acro-mode)and [Position mode](#position-mode) must already be configured!
|
||||
:::
|
||||
|
||||
<a id="pure_pursuit_controller"></a>
|
||||
|
||||
In [auto modes](../flight_modes_rover/ackermann.md#auto-modes) the autopilot takes over navigation tasks using the following control architecture:
|
||||
|
||||

|
||||
|
||||
The required parameter configuration is discussed in the following sections.
|
||||
|
||||
### Speed
|
||||
|
||||
1. [RO_DECEL_LIM](#RO_DECEL_LIM) [m/s^2] and [RO_JERK_LIM](#RO_JERK_LIM) [m/s^3] are used to calculate a speed trajectory such that the rover reaches the next waypoint with the correct [cornering speed](#cornering-speed).
|
||||
|
||||
::: tip
|
||||
Plan a mission for the rover to drive a square and observe how it slows down when approaching a waypoint:
|
||||
|
||||
- If the rover decelerates too quickly decrease the [RO_DECEL_LIM](#RO_DECEL_LIM) parameter, if it starts slowing down too early increase the parameter.
|
||||
- If you observe a jerking motion as the rover slows down, decrease the [RO_JERK_LIM](#RO_JERK_LIM) parameter otherwise increase it as much as possible as it can interfere with the tuning of [RO_DECEL_LIM](#RO_DECEL_LIM).
|
||||
|
||||
These two parameters have to be tuned as a pair, repeat until you are satisfied with the behaviour.
|
||||
:::
|
||||
|
||||
2. Plot the `adjusted_speed_body_x_setpoint` and `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other.
|
||||
If the tracking of these setpoints is not satisfactory adjust the values for [RO_SPEED_P](#RO_SPEED_P) and [RO_SPEED_I](#RO_SPEED_I).
|
||||
|
||||
### Corner Cutting
|
||||
|
||||
The module employs a special cornering logic causing the rover to "cut corners" to achieve a smooth trajectory.
|
||||
This is done by scaling the acceptance radius based on the corner the rover has to drive (for geometric explanation see [Cornering logic](#mission-cornering-logic-info-only)).
|
||||
|
||||

|
||||
|
||||
The degree to which corner cutting is allowed can be tuned, or disabled, with the following parameters:
|
||||
|
||||
::: info
|
||||
The corner cutting effect is a tradeoff between how close you get to the waypoint and the smoothness of the trajectory.
|
||||
:::
|
||||
|
||||
1. [NAV_ACC_RAD](#NAV_ACC_RAD) [m]: Default acceptance radius
|
||||
This is also used as a lower bound for the acceptance radius scaling.
|
||||
2. [RA_ACC_RAD_MAX](#RA_ACC_RAD_MAX) [m]: The maximum the acceptance radius can be scaled to.
|
||||
Set equal to [NAV_ACC_RAD](#NAV_ACC_RAD) to disable the corner cutting effect.
|
||||
3. [RA_ACC_RAD_GAIN](#RA_ACC_RAD_GAIN) [-]: This tuning parameter is a multiplicand on the [calculated ideal acceptance radius](#corner-cutting-logic) to account for dynamic effects.
|
||||
|
||||
:::tip
|
||||
Initially set this parameter to `1`.
|
||||
If you observe the rover overshooting the corner, increase this parameter until you are satisfied with the behaviour.
|
||||
Note that the scaling of the acceptance radius is limited by [RA_ACC_RAD_MAX](#RA_ACC_RAD_MAX).
|
||||
:::
|
||||
|
||||
### Path Following
|
||||
|
||||
The [pure pursuit](#pure-pursuit-guidance-logic) algorithm is used to calculate a yaw rate setpoint for the vehicle that is then close loop controlled.
|
||||
The close loop yaw rate was tuned in the configuration of the [Acro mode](#acro-mode), and the pure pursuit was tuned when setting up the [Position mode](#position-mode).
|
||||
During any auto navigation task observe the behaviour of the rover.
|
||||
|
||||
If you are unsatisfied with the path following, there are 2 steps to take:
|
||||
|
||||
1. Plot the `adjusted_yaw_rate_setpoint` and the `measured_yaw_rate` from the [RoverRateStatus](../msg_docs/RoverRateStatus.md) over each other.
|
||||
If the tracking of these setpoints is not satisfactory adjust the values for [RO_YAW_RATE_P](#RO_YAW_RATE_P) and [RO_YAW_RATE_I](#RO_YAW_RATE_I).
|
||||
2. Plot the `adjusted_yaw_setpoint` and the `measured_yaw` from the [RoverAttitudeStatus](../msg_docs/RoverAttitudeStatus.md) over each other.
|
||||
If the tracking of these setpoints is not satisfactory adjust the value for [RO_YAW_P](#RO_YAW_RATE_P) and potentially further tune [RO_YAW_RATE_I](#RO_YAW_RATE_I).
|
||||
3. Steps 1 and 2 ensures accurate setpoint tracking, if the path following is still unsatisfactory you need to further tune the [pure pursuit](#pure-pursuit-guidance-logic) parameters.
|
||||
|
||||
## Pure Pursuit Guidance Logic
|
||||
|
||||
The desired yaw setpoints are generated using a pure pursuit algorithm.
|
||||
|
||||
The controller takes the intersection point between a circle around the vehicle and a line segment.
|
||||
In mission mode this line is usually constructed by connecting the previous and current waypoint.
|
||||
|
||||

|
||||
|
||||
The radius of the circle around the vehicle is used to tune the controller and is often referred to as look-ahead distance.
|
||||
|
||||
The look-ahead distance sets how aggressive the controller behaves and is defined as $l_d = v \cdot k$.
|
||||
It depends on the velocity $v$ of the rover and a tuning parameter $k$ that can be set with the parameter [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN).
|
||||
|
||||
::: info
|
||||
A lower value of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) makes the controller more aggressive but can lead to oscillations!
|
||||
:::
|
||||
|
||||
The lookahead is constrained between [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX) and [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
|
||||
If the distance from the path to the rover is bigger than the lookahead distance, the rover will target the point on the path that is closest to the rover.
|
||||
|
||||
To summarize, the following parameters can be used to tune the controller:
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| -------------------------------------------------------------------------------------------------------- | --------------------------------------- | ---- |
|
||||
| <a id="PP_LOOKAHD_GAIN"></a>[PP_LOOKAHD_GAIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_GAIN) | Main tuning parameter | - |
|
||||
| <a id="PP_LOOKAHD_MAX"></a>[PP_LOOKAHD_MAX](../advanced_config/parameter_reference.md#PP_LOOKAHD_MAX) | Maximum value for the look ahead radius | m |
|
||||
| <a id="PP_LOOKAHD_MIN"></a>[PP_LOOKAHD_MIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_MIN) | Minimum value for the look ahead radius | m |
|
||||
|
||||
## Mission Cornering Logic (Info only)
|
||||
|
||||
### Corner Cutting Logic
|
||||
|
||||
To enable a smooth trajectory, the acceptance radius of waypoints is scaled based on the angle between a line segment from the current-to-previous and current-to-next waypoints.
|
||||
The ideal trajectory would be to arrive at the next line segment with the heading pointing towards the next waypoint.
|
||||
For this purpose the minimum turning circle of the rover is inscribed tangentially to both line segments.
|
||||
|
||||

|
||||
|
||||
The acceptance radius of the waypoint is set to the distance from the waypoint to the tangential points between the circle and the line segments:
|
||||
|
||||
$$
|
||||
\begin{align*}
|
||||
r_{min} &= \frac{L}{\sin\left( \delta_{max}\right) } \\
|
||||
\theta &= \frac{1}{2}\arccos\left( \frac{\vec{a}*\vec{b}}{|\vec{a}||\vec{b}|}\right) \\
|
||||
r_{acc} &= \frac{r_{min}}{\tan\left( \theta\right) }
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
| Symbol | Description | Unit |
|
||||
| -------------- | ---------------------------------- | ---- |
|
||||
| $\vec{a}$ | Vector from current to previous WP | m |
|
||||
| $\vec{b}$ | Vector from current to next WP | m |
|
||||
| $r_{min}$ | Minimum turn radius | m |
|
||||
| $\delta_{max}$ | Maximum steer angle | m |
|
||||
| $r_{acc}$ | Acceptance radius | m |
|
||||
|
||||
### Cornering Speed
|
||||
|
||||
To smoothen the trajectory further and reduce the risk of the rover rolling over, the rover speed is regulated as follows:
|
||||
|
||||
1. During cornering the rover drives at the following speed:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
$$ v_{cor, max} = \dot{\psi}_{max} \cdot r $$
|
||||
|
||||
with $r:$ Turning radius for the upcoming corner and $\dot{\psi}_{max}:$ Maximum yaw rate ([RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM)).
|
||||
|
||||
2. In between waypoints (straight line) the rover speed is regulated such that it will arrive at the acceptance radius of the waypoint with the desired cornering speed.
|
||||
|
||||
The rover is constrained between the maximum speed [RO_SPEED_LIM](#RO_SPEED_LIM) and the speed where the maximum steering angle does not cause the rover to exceed the yaw rate limit:
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
$$ v_{min} = \frac{w_b \cdot \dot{\psi}_{max}}{tan(\delta_{max})} $$
|
||||
|
||||
with $w_b:$ Wheel base ([RA_WHEEL_BASE](#RA_WHEEL_BASE)), $\dot{\psi}_{max}:$ Maximum yaw rate ([RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM)) and $\delta_{max}:$ Maximum steering angle ([RA_MAX_STR_ANG](#RA_MAX_STR_ANG)).
|
||||
|
||||
## Parameter Overview
|
||||
|
||||
List of all parameters of the ackermann rover module:
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------- |
|
||||
| <a id="RA_WHEEL_BASE"></a>[RA_WHEEL_BASE](../advanced_config/parameter_reference.md#RA_WHEEL_BASE) | Wheel base | m |
|
||||
| <a id="RA_MAX_STR_ANG"></a>[RA_MAX_STR_ANG](../advanced_config/parameter_reference.md#RA_MAX_STR_ANG) | Maximum steering angle | deg |
|
||||
| <a id="RO_MAX_THR_SPEED"></a>[RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED) | Speed the rover drives at maximum throttle | m/s |
|
||||
| <a id="RO_YAW_RATE_LIM"></a>[RO_YAW_RATE_LIM](../advanced_config/parameter_reference.md#RO_YAW_RATE_LIM) | Maximum allowed yaw rate | m/s^2 |
|
||||
| <a id="RO_YAW_RATE_P"></a>[RO_YAW_RATE_P](../advanced_config/parameter_reference.md#RO_YAW_RATE_P) | Proportional gain for yaw rate controller | - |
|
||||
| <a id="RO_YAW_RATE_I"></a>[RO_YAW_RATE_I](../advanced_config/parameter_reference.md#RO_YAW_RATE_I) | Integral gain for yaw rate controller | - |
|
||||
| <a id="RO_YAW_P"></a>[RO_YAW_P](../advanced_config/parameter_reference.md#RO_YAW_P) | Proportional gain for yaw controller | - |
|
||||
| <a id="RO_SPEED_LIM"></a>[RO_SPEED_LIM](../advanced_config/parameter_reference.md#RO_SPEED_LIM) | Maximum allowed speed | m/s |
|
||||
| <a id="RO_SPEED_P"></a>[RO_SPEED_P](../advanced_config/parameter_reference.md#RO_SPEED_P) | Proportional gain for speed controller | - |
|
||||
| <a id="RO_SPEED_I"></a>[RO_SPEED_I](../advanced_config/parameter_reference.md#RO_SPEED_I) | Integral gain for speed controller | - |
|
||||
| <a id="PP_LOOKAHD_GAIN"></a>[PP_LOOKAHD_GAIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_GAIN) | Main tuning parameter for pure pursuit | - |
|
||||
| <a id="PP_LOOKAHD_MAX"></a>[PP_LOOKAHD_MAX](../advanced_config/parameter_reference.md#PP_LOOKAHD_MAX) | Maximum value for the look ahead radius of the pure pursuit algorithm | m |
|
||||
| <a id="PP_LOOKAHD_MIN"></a>[PP_LOOKAHD_MIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_MIN) | Minimum value for the look ahead radius of the pure pursuit algorithm | m |
|
||||
| <a id="NAV_ACC_RAD"></a>[NAV_ACC_RAD](../advanced_config/parameter_reference.md#NAV_ACC_RAD) | Default acceptance radius | m |
|
||||
| <a id="RA_STR_RATE_LIM"></a>[RA_STR_RATE_LIM](../advanced_config/parameter_reference.md#RA_STR_RATE_LIM) | (Optional) Maximum allowed steering rate | deg/s |
|
||||
| <a id="RO_ACCEL_LIM"></a>[RO_ACCEL_LIM](../advanced_config/parameter_reference.md#RO_ACCEL_LIM) | (Optional) Maximum allowed acceleration | m/s^2 |
|
||||
| <a id="RO_DECEL_LIM"></a>[RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM) | (Optional) Maximum allowed deceleration | m/s^2 |
|
||||
| <a id="RO_JERK_LIM"></a>[RO_JERK_LIM](../advanced_config/parameter_reference.md#RO_JERK_LIM) | (Optional) Maximum allowed jerk | $m/s^3$ |
|
||||
| <a id="RA_ACC_RAD_MAX"></a>[RA_ACC_RAD_MAX](../advanced_config/parameter_reference.md#RA_ACC_RAD_MAX) | (Optional) Maximum radius the acceptance radius can be scaled to | m |
|
||||
| <a id="RA_ACC_RAD_GAIN"></a>[RA_ACC_RAD_GAIN](../advanced_config/parameter_reference.md#RA_ACC_RAD_GAIN) | (Optional) Tuning parameter for the acceptance radius scaling | - |
|
||||
|
||||
## See Also
|
||||
|
||||
- [Drive Modes (Ackermann Rover)](../flight_modes_rover/ackermann.md).
|
||||
@@ -0,0 +1,37 @@
|
||||
# Attitude Tuning
|
||||
|
||||
::: warning
|
||||
The [rate tuning](rate_tuning.md) must've already been completed before this step!
|
||||
:::
|
||||
|
||||
To tune the attitude controller and unlock [Stabilized mode](../flight_modes_rover/manual.md#stabilized-mode) configure the following [parameters](../advanced_config/parameters.md) in QGroundControl:
|
||||
|
||||
1. [RO_YAW_P](#RO_YAW_P) [-]: Proportional gain for the closed loop yaw controller.
|
||||
|
||||
::: tip
|
||||
In stabilized mode the closed loop yaw control is only active when driving a straight line (no yaw rate input).
|
||||
To tune it start with a value of 1 for [RO_YAW_P](#RO_YAW_P).
|
||||
Put the rover into stabilized mode and move the left stick of your controller up to drive forwards.
|
||||
Disarm the rover and from the flight log plot the `measured_yaw` and the `adjusted_yaw_setpoint` from the [RoverAttitudeStatus](../msg_docs/RoverAttitudeStatus.md) message over each other.
|
||||
Increase/Decrease the parameter until you are satisfied with the setpoint tracking.
|
||||
If you observe a steady state error in the yaw setpoint increase the the integrator of the rate controller: [RO_YAW_RATE_I](../advanced_config/parameter_reference.md#RO_YAW_RATE_I) .
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Stabilized mode](../flight_modes_rover/manual.md#stabilized-mode) and the configuration can be continued with [velocity tuning](velocity_tuning.md).
|
||||
|
||||
## Attitude Controller Structure (Info Only)
|
||||
|
||||
This section provides additional information for developers and people with experience in control system design.
|
||||
|
||||
The attitude controller uses the following structure:
|
||||
|
||||

|
||||
|
||||
The rate and attitude controllers are cascaded, therefor we only require one integrator in the structure to eliminate steady state errors.
|
||||
We placed the integrator in the rate controller since it can run without the attitude controller but not the other way around.
|
||||
|
||||
## Parameter Overview
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------- | ------------------------------------ | ---- |
|
||||
| <a id="RO_YAW_P"></a>[RO_YAW_P](../advanced_config/parameter_reference.md#RO_YAW_P) | Proportional gain for yaw controller | - |
|
||||
@@ -0,0 +1,131 @@
|
||||
# Basic Setup
|
||||
|
||||
## Configure the rover frame and outputs:
|
||||
|
||||
1. Enable Rover support by flashing the [PX4 rover build](../config_rover/index.md#flashing-the-rover-build) onto your flight controller.
|
||||
Note that this is a special build that contains rover-specific modules.
|
||||
|
||||
2. In the [Airframe](../config/airframe.md) configuration select the your rover type: _Generic Rover Ackermann_/_Generic Rover Differential_/_Generic Rover Mecanum_:
|
||||
|
||||

|
||||
|
||||
Select the **Apply and Restart** button.
|
||||
|
||||
::: info
|
||||
If this airframe is not displayed and you have checked that you are using rover firmware (not the default), you can alternatively enable this frame by setting the [SYS_AUTOSTART](../advanced_config/parameter_reference.md#SYS_AUTOSTART) parameter directly to the following value:
|
||||
|
||||
| Rover Type | Value |
|
||||
| ------------ | ------- |
|
||||
| Ackermann | `51000` |
|
||||
| Differential | `50000` |
|
||||
| Mecanum | `52000` |
|
||||
:::
|
||||
|
||||
3. Open the [Actuators Configuration & Testing](../config/actuators.md) to map the motor/servo functions to flight controller outputs.
|
||||
|
||||
This already covers the minimum setup required to use the rover in [Manual mode](../flight_modes_rover/manual.md#manual-mode).
|
||||
|
||||
This mode is also affected by (optional) acceleration/deceleration limits.
|
||||
As configuration of these limits becomes mandatory later, we do this setup here.
|
||||
|
||||
Navigate to [Parameters](../advanced_config/parameters.md) in QGroundControl and set the following parameters:
|
||||
|
||||
## Geometric Paramters
|
||||
The geometric parameters are dependant on your rover type:
|
||||
|
||||

|
||||
|
||||
### Ackermann
|
||||
1. [RA_WHEEL_BASE](#RA_WHEEL_BASE) [m]: Measure the distance from the back to the front wheels.
|
||||
1. [RA_MAX_STR_ANG](#RA_MAX_STR_ANG) [deg]: Measure the maximum steering angle.
|
||||
1. (Optional) [RA_STR_RATE_LIM](#RA_STR_RATE_LIM) [deg/s]: Maximum steering rate you want to allow for your rover.
|
||||
|
||||
:::tip
|
||||
This value depends on your rover and use case.
|
||||
For bigger rovers there might be a mechanical limit that is easy to identify by steering the rover at a standstill and increasing
|
||||
[RA_STR_RATE_LIM](#RA_STR_RATE_LIM) until you observe the steering rate to no longer be limited by the parameter.
|
||||
For smaller rovers you might observe the steering to be too aggressive. Set [RA_STR_RATE_LIM](#RA_STR_RATE_LIM) to a low value and steer the rover at a standstill.
|
||||
Increase the parameter until you reach the maximum steering rate you are comfortable with.
|
||||
:::
|
||||
|
||||
:::warning
|
||||
A low maximum steering rate makes the rover worse at tracking steering setpoints, which can lead to a poor performance in the subsequent modes.
|
||||
:::
|
||||
|
||||
### Differential
|
||||
1. [RD_WHEEL_TRACK](#RD_WHEEL_TRACK) [m]: Measure the distance from the centre of the right wheel to the centre of the left wheel.
|
||||
|
||||
### Mecanum
|
||||
1. [RM_WHEEL_TRACK](#RM_WHEEL_TRACK) [m]: Measure the distance from the centre of the right wheel to the centre of the left wheel.
|
||||
|
||||
## Speed Parameters
|
||||
|
||||
1. [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) [m/s]: Drive the rover at full throttle and set this parameter to the observed value of the ground speed.
|
||||
|
||||
:::info
|
||||
This parameter is also used for the feed-forward term of the closed loop speed control.
|
||||
It will be further adjusted in the [velocity tuning](velocity_tuning.md) step.
|
||||
:::
|
||||
|
||||
1. (Optional) [RO_ACCEL_LIM](#RO_ACCEL_LIM) [m/s^2]: Maximum acceleration you want to allow for your rover.
|
||||
|
||||
<a id="RO_ACCEL_LIM_CONSIDERATIONS"></a>
|
||||
|
||||
:::tip
|
||||
Your rover has a maximum possible acceleration which is determined by the maximum torque the motor can supply.
|
||||
This may or may not be appropriate for your vehicle and use case.
|
||||
|
||||
One approach to determine an appropriate value is:
|
||||
|
||||
1. From a standstill, give the rover full throttle until it reaches the maximum speed.
|
||||
2. Disarm the rover and plot the `measured_speed_body_x` from [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md).
|
||||
3. Divide the maximum speed by the time it took to reach it and set this as the value for [RO_ACCEL_LIM](#RO_ACCEL_LIM).
|
||||
|
||||
Some RC rovers have enough torque to lift up if the maximum acceleration is not limited.
|
||||
If that is the case:
|
||||
|
||||
1. Set [RO_ACCEL_LIM](#RO_ACCEL_LIM) to a low value, give the rover full throttle from a standstill and observe its behaviour.
|
||||
2. Increase [RO_ACCEL_LIM](#RO_ACCEL_LIM) until the rover starts to lift up during the acceleration.
|
||||
3. Set [RO_ACCEL_LIM](#RO_ACCEL_LIM) to the highest value that does not cause the rover to lift up.
|
||||
:::
|
||||
|
||||
1. (Optional) [RO_DECEL_LIM](#RO_DECEL_LIM) [m/s^2]: Maximum deceleration you want to allow for your rover.
|
||||
|
||||
:::tip
|
||||
The same [considerations](#RO_ACCEL_LIM_CONSIDERATIONS) as in the configuration of [RO_ACCEL_LIM](#RO_ACCEL_LIM) apply.
|
||||
:::
|
||||
|
||||
:::info
|
||||
This parameter is also used for the calculation of the speed setpoint in modes that are [position controlled](position_tuning.md).
|
||||
:::
|
||||
|
||||
You can now continue the configuration process with [rate tuning](rate_tuning.md).
|
||||
|
||||
## Parameter Overview
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------ | ------- |
|
||||
| <a id="RO_MAX_THR_SPEED"></a>[RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED) | Speed the rover drives at maximum throttle | $m/s$ |
|
||||
| <a id="RO_ACCEL_LIM"></a>[RO_ACCEL_LIM](../advanced_config/parameter_reference.md#RO_ACCEL_LIM) | (Optional) Maximum allowed acceleration | $m/s^2$ |
|
||||
| <a id="RO_DECEL_LIM"></a>[RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM) | (Optional) Maximum allowed deceleration | $m/s^2$ |
|
||||
|
||||
### Ackermann Specific
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| -------------------------------------------------------------------------------------------------------- | ---------------------------------------- | ----- |
|
||||
| <a id="RA_WHEEL_BASE"></a>[RA_WHEEL_BASE](../advanced_config/parameter_reference.md#RA_WHEEL_BASE) | Wheel base | $m$ |
|
||||
| <a id="RA_MAX_STR_ANG"></a>[RA_MAX_STR_ANG](../advanced_config/parameter_reference.md#RA_MAX_STR_ANG) | Maximum steering angle | $deg$ |
|
||||
| <a id="RA_STR_RATE_LIM"></a>[RA_STR_RATE_LIM](../advanced_config/parameter_reference.md#RA_STR_RATE_LIM) | (Optional) Maximum allowed steering rate | deg/s |
|
||||
|
||||
### Differential Specific
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------- | ----------- | ---- |
|
||||
| <a id="RD_WHEEL_TRACK"></a>[RD_WHEEL_TRACK](../advanced_config/parameter_reference.md#RD_WHEEL_TRACK) | Wheel track | m |
|
||||
|
||||
|
||||
### Mecanum Specific
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------- | ----------- | ---- |
|
||||
| <a id="RM_WHEEL_TRACK"></a>[RM_WHEEL_TRACK](../advanced_config/parameter_reference.md#RM_WHEEL_TRACK) | Wheel track | m |
|
||||
@@ -1,376 +0,0 @@
|
||||
# Configuration/Tuning (Differential Rover)
|
||||
|
||||
This topic provides a step-by-step guide for setting up your [Differential rover](../frames_rover/differential.md).
|
||||
Successive steps enable [drive modes](../flight_modes_rover/differential.md) with more autopilot support and features.
|
||||
|
||||
::: warning
|
||||
Each step is dependent on the previous steps having been completed.
|
||||
Modes will only work properly if the preceding modes have been configured.
|
||||
:::
|
||||
|
||||
## Basic Setup
|
||||
|
||||
To configure the differential rover frame and outputs:
|
||||
|
||||
1. Enable Rover support by flashing the [PX4 rover build](../frames_rover/index.md#flashing-the-rover-build) onto your flight controller.
|
||||
Note that this is a special build that contains rover-specific modules.
|
||||
|
||||
2. In the [Airframe](../config/airframe.md) configuration select _Generic Rover Differential_ frame:
|
||||
|
||||

|
||||
|
||||
Select the **Apply and Restart** button.
|
||||
|
||||
::: info
|
||||
If this airframe is not displayed and you have checked that you are using rover firmware (not the default), you can alternatively enable this frame by setting the [SYS_AUTOSTART](../advanced_config/parameter_reference.md#SYS_AUTOSTART) parameter to `50000`.
|
||||
:::
|
||||
|
||||
3. Use [Actuators Configuration & Testing](../config/actuators.md) to map the motor functions to flight controller outputs.
|
||||
|
||||
## Manual Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly the [Basic Setup](#basic-setup) must've already been completed!
|
||||
:::
|
||||
|
||||
The basic setup already covers the minimum setup required to use the rover in [Manual mode](../flight_modes_rover/differential.md#manual-mode).
|
||||
|
||||
This mode is also affected by (optional) acceleration/deceleration limits.
|
||||
As configuration of these limits becomes mandatory for subsequent modes, we do this setup here.
|
||||
|
||||
Navigate to [Parameters](../advanced_config/parameters.md) in QGroundControl and set the following parameters:
|
||||
|
||||
1. [RD_WHEEL_TRACK](#RD_WHEEL_TRACK) [m]: Measure the distance from the centre of the right wheel to the centre of the left wheel.
|
||||
|
||||

|
||||
|
||||
2. [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) [m/s]: Drive the rover at full throttle and set this parameter to the observed value of the ground speed.
|
||||
|
||||
:::info
|
||||
This parameter is also used for the feed-forward term of the speed control.
|
||||
It will be further tuned in the configuration of [Position mode](#position-mode).
|
||||
:::
|
||||
|
||||
3. (Optional) [RO_ACCEL_LIM](#RO_ACCEL_LIM) [m/s^2]: Maximum acceleration you want to allow for your rover.
|
||||
|
||||
<a id="RO_ACCEL_LIM_CONSIDERATIONS"></a>
|
||||
|
||||
:::tip
|
||||
Your rover has a maximum possible acceleration which is determined by the maximum torque the motor can supply.
|
||||
This may or may not be appropriate for your vehicle and use case.
|
||||
|
||||
One approach to determine an appropriate value is:
|
||||
|
||||
1. From a standstill, give the rover full throttle until it reaches the maximum speed.
|
||||
2. Disarm the rover and plot the `measured_speed_body_x` from [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md).
|
||||
3. Divide the maximum speed by the time it took to reach it and set this as the value for [RO_ACCEL_LIM](#RO_ACCEL_LIM).
|
||||
|
||||
Some RC rovers have enough torque to lift up if the maximum acceleration is not limited.
|
||||
If that is the case:
|
||||
|
||||
4. Set [RO_ACCEL_LIM](#RO_ACCEL_LIM) to a low value, give the rover full throttle from a standstill and observe its behaviour.
|
||||
5. Increase [RO_ACCEL_LIM](#RO_ACCEL_LIM) until the rover starts to lift up during the acceleration.
|
||||
6. Set [RO_ACCEL_LIM](#RO_ACCEL_LIM) to the highest value that does not cause the rover to lift up.
|
||||
|
||||
:::
|
||||
|
||||
4. (Optional) [RO_DECEL_LIM](#RO_DECEL_LIM) [m/s^2]: Maximum deceleration you want to allow for your rover.
|
||||
|
||||
:::tip
|
||||
The same [considerations](#RO_ACCEL_LIM_CONSIDERATIONS) as in the configuration of [RO_ACCEL_LIM](#RO_ACCEL_LIM) apply.
|
||||
:::
|
||||
|
||||
:::info
|
||||
This parameter is also used for the calculation of the speed setpoint during [Auto modes](#auto-modes).
|
||||
:::
|
||||
|
||||
## Acro Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly [Manual mode](#manual-mode) must've already been configured!
|
||||
:::
|
||||
|
||||
To set up [Acro mode](../flight_modes_rover/differential.md#acro-mode), navigate to [Parameters](../advanced_config/parameters.md) in QGroundControl and set the following parameters:
|
||||
|
||||
1. [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM) [deg/s]: This is the maximum yaw rate you want to allow for your rover.
|
||||
This will define the stick-to-yaw-rate mapping for all manual modes using closed loop yaw control and set an upper limit for the yaw rate setpoint for all [auto modes](#auto-modes).
|
||||
1. [RD_MAX_THR_YAW_R](#RD_MAX_THR_YAW_R) [m/s]: This parameter is used to calculate the feed-forward term of the closed loop yaw rate control.
|
||||
The controller calculates the required speed difference between the left and right motor to achieve the desired yaw rate.
|
||||
This desired speed difference is then linearly mapped to normalized motor commands.
|
||||
To get a good starting value for this parameter drive the rover in manual mode forwards at full throttle and note the ground speed of the vehicle.
|
||||
Then enter _half_ this value for the parameter.
|
||||
<a id="RD_YAW_RATE_P_TUNING"></a>
|
||||
|
||||
::: tip
|
||||
To further tune this parameter, first make sure you set [RO_YAW_RATE_P](#RO_YAW_RATE_P) and [RO_YAW_RATE_I](#RO_YAW_RATE_I) to zero.
|
||||
This way the yaw rate is only controlled by the feed-forward term, which makes it easier to tune.
|
||||
Now put the rover in [Acro mode](../flight_modes_rover/differential.md#acro-mode) and then move the right-stick of your controller to the right and/or left and hold it at a few different levels for a couple of seconds each.
|
||||
Disarm the rover and from the flight log plot the `adjusted_yaw_rate_setpoint` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) and the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) over each other.
|
||||
If the actual yaw rate of the rover is higher than the yaw rate setpoint, increase [RD_MAX_THR_YAW_R](#RD_MAX_THR_YAW_R).
|
||||
If it is the other way around decrease the parameter and repeat until you are satisfied with the setpoint tracking.
|
||||
:::
|
||||
|
||||
1. [RO_YAW_RATE_P](#RO_YAW_RATE_P) [-]: Proportional gain of the closed loop yaw rate controller.
|
||||
Unlike the feed-forward part of the controller, the closed loop yaw rate control will compare the yaw rate setpoint with the measured yaw rate and adapt to motor commands based on the error between them.
|
||||
The proportional gain is multiplied with this error and that value is added to the motor command.
|
||||
This compensates for disturbances such as uneven ground and external forces.
|
||||
|
||||
::: tip
|
||||
This parameter can be tuned the same way as [RD_MAX_THR_YAW_R](#RD_YAW_RATE_P_TUNING).
|
||||
If you tuned [RD_MAX_THR_YAW_R](#RD_MAX_THR_YAW_R) well, you might only need a very small value.
|
||||
:::
|
||||
|
||||
1. [RO_YAW_RATE_I](#RO_YAW_RATE_I) [-]: Integral gain of the closed loop yaw controller.
|
||||
The integral gain accumulates the error between the desired and actual yaw rate scaled by the integral gain over time and that value is added to the motor command.
|
||||
|
||||
::: tip
|
||||
An integrator might not be neccessary at this stage, but it will become important for subsequent modes.
|
||||
:::
|
||||
|
||||
1. (Optional) [RO_YAW_ACCEL_LIM](#RO_YAW_ACCEL_LIM) and [RO_YAW_DECEL_LIM](#RO_YAW_DECEL_LIM) [deg/s^2]:
|
||||
This is the maximum yaw acceleration and deceleration you want to allow for your rover.
|
||||
This can be used to smooth the `yaw_rate` setpoints and make their trajectory feasible based on the physical limitations of the rover.
|
||||
It also improves tracking and avoid integrator build up.
|
||||
|
||||
::: tip
|
||||
Your rover has a maximum possible yaw acceleration/deceleration which is determined by the maximum torque the motor can supply.
|
||||
This may or may not be appropriate for your vehicle and use case.
|
||||
|
||||
One approach to determine an appropriate value is:
|
||||
|
||||
1. Put the rover into [Manual mode](../flight_modes_rover/differential.md#manual-mode).
|
||||
2. From a standstill, move the right stick all the way to the right or left until the rover reaches the maximum yaw rate then return the right stick to the middle.
|
||||
3. Disarm the rover and plot the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md).
|
||||
4. Divide the maximum yaw rate by the time it took to reach it and set this as the value for [RO_YAW_ACCEL_LIM](#RO_YAW_ACCEL_LIM).
|
||||
5. Divide the maximum yaw rate by the time it took to return to a standstill and set this as the value for [RO_YAW_ACCEL_LIM](#RO_YAW_ACCEL_LIM).
|
||||
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Acro mode](../flight_modes_rover/differential.md#acro-mode).
|
||||
|
||||
## Stabilized Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly [Acro mode](#acro-mode) must've already been configured!
|
||||
:::
|
||||
|
||||
For [Stabilized mode](../flight_modes_rover/differential.md#stabilized-mode) the controller utilizes a closed loop yaw controller, which creates a yaw rate setpoint to control the yaw when it is active:
|
||||
|
||||

|
||||
|
||||
Unlike the closed loop yaw rate, this controller has no feed-forward term.
|
||||
Therefore you only need to tune the closed loop gains:
|
||||
|
||||
1. [RO_YAW_P](#RO_YAW_P) [-]: Proportional gain for the closed loop yaw controller.
|
||||
|
||||
::: tip
|
||||
In stabilized mode the closed loop yaw control is only active when driving a straight line (no yaw rate input).
|
||||
|
||||
1. Start with a value of 1 for [RO_YAW_P](#RO_YAW_P).
|
||||
2. Put the rover into stabilized mode and move the left stick of your controller up and/or down to drive forwards/backwards.
|
||||
3. Disarm the rover and from the flight log plot the `measured_yaw` and the `adjusted_yaw_setpoint` from the [RoverAttitudeStatus](../msg_docs/RoverAttitudeStatus.md) message over each other.
|
||||
4. Increase/Decrease the parameter until you are satisfied with the setpoint tracking.
|
||||
:::
|
||||
|
||||
::: info
|
||||
For the closed loop yaw control an integrator gain is useful because this setpoint is often constant for a while and an integrator eliminates steady state errors that can cause the rover to never reach the setpoint.
|
||||
Since the yaw and yaw rate controllers are cascaded, there only needs to be one integrator which is in the yaw rate controller.
|
||||
If you observe a steady state error in the yaw setpoint increase the [RO_YAW_RATE_I](#RO_YAW_RATE_I) parameter.
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Stabilized mode](../flight_modes_rover/differential.md#stabilized-mode).
|
||||
|
||||
## Position Mode
|
||||
|
||||
:::warning
|
||||
For this mode to work properly [Stabilized mode](#stabilized-mode) must already be configured!
|
||||
:::
|
||||
|
||||
[Position mode](../flight_modes_rover/differential.md#position-mode) is the most advanced manual mode, utilizing closed loop yaw rate, yaw and speed control and leveraging position estimates.
|
||||
|
||||
To configure set the following parameters:
|
||||
|
||||
1. [RO_SPEED_LIM](#RO_SPEED_LIM) [m/s]: This is the maximum speed you want to allow for your rover.
|
||||
This will define the stick-to-speed mapping for position mode and set an upper limit for the speed setpoint for all [auto modes](#auto-modes).
|
||||
2. [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) [m/s]: This parameter is used to calculate the feed-forward term of the closed loop speed control which linearly maps desired speeds to normalized motor commands.
|
||||
A good starting point is the observed ground speed when the rover drives at maximum throttle in [Manual mode](../flight_modes_rover/differential.md#manual-mode).
|
||||
|
||||
<a id="RD_SPEED_P_TUNING"></a>
|
||||
|
||||
::: tip
|
||||
To further tune this parameter:
|
||||
|
||||
1. Set [RO_SPEED_P](#RO_SPEED_P) and [RO_SPEED_I](#RO_SPEED_I) to zero.
|
||||
This way the speed is only controlled by the feed-forward term, which makes it easier to tune.
|
||||
2. Put the rover in [Position mode](../flight_modes_rover/differential.md#position-mode) and then move the left stick of your controller up and/or down and hold it at a few different levels for a couple of seconds each.
|
||||
3. Disarm the rover and from the flight log plot the `adjusted_speed_body_x_setpoint` and the `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other.
|
||||
4. If the actual speed of the rover is higher than the speed setpoint, increase [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED).
|
||||
If it is the other way around decrease the parameter and repeat until you are satisfied with the setpoint tracking.
|
||||
|
||||
:::
|
||||
|
||||
::: info
|
||||
If your rover oscillates when driving a straight line in [Position mode](../flight_modes_rover/differential.md#position-mode) just set this parameter to the observed ground speed at maximum throttle in [Manual mode](../flight_modes_rover/differential.md#manual-mode) and complete steps 5-7 first before continuing the tuning of the closed loop speed control (Steps 2-4).
|
||||
:::
|
||||
|
||||
3. [RO_SPEED_P](#RO_SPEED_P) [-]: Proportional gain of the closed loop speed controller.
|
||||
|
||||
::: tip
|
||||
This parameter can be tuned the same way as [RO_MAX_THR_SPEED](#RD_SPEED_P_TUNING).
|
||||
If you tuned [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) well, you might only need a very small value.
|
||||
:::
|
||||
|
||||
4. [RO_SPEED_I](#RO_SPEED_I) [-]: Integral gain for the closed loop speed controller.
|
||||
|
||||
::: tip
|
||||
For the closed loop speed control an integrator gain is useful because this setpoint is often constant for a while and an integrator eliminates steady state errors that can cause the rover to never reach the setpoint.
|
||||
:::
|
||||
|
||||
5. [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN): When driving in a straight line (no yaw rate input) position mode leverages the same path following algorithm used in [auto modes](#auto-modes) called [pure pursuit](#pure-pursuit-guidance-logic) to achieve the best possible straight line driving behaviour ([Illustration of control architecture](#pure_pursuit_controller)).
|
||||
This parameter determines how aggressive the controller will steer towards the path.
|
||||
|
||||
::: tip
|
||||
Decreasing the parameter makes it more aggressive but can lead to oscillations.
|
||||
|
||||
To tune this:
|
||||
|
||||
1. Start with a value of 1 for [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN)
|
||||
2. Put the rover in [Position mode](../flight_modes_rover/differential.md#position-mode) and while driving a straight line at approximately half the maximum speed observe its behaviour.
|
||||
3. If the rover does not drive in a straight line, reduce the value of the parameter, if it oscillates around the path increase the value.
|
||||
4. Repeat until you are satisfied with the behaviour.
|
||||
|
||||
:::
|
||||
|
||||
6. [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN): Minimum threshold for the lookahead distance used by the [pure pursuit algorithm](#pure-pursuit-guidance-logic).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/differential.md#position-mode) and drive at very low speeds, if the rover starts to oscillate even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then increase the value of [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
:::
|
||||
|
||||
7. [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX): Maximum threshold for the lookahead distance used by [pure pursuit](#pure-pursuit-guidance-logic).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/differential.md#position-mode) and drive at very high speeds, if the rover does not drive in a straight line even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then decrease the value of [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX).
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Position mode](../flight_modes_rover/differential.md#position-mode).
|
||||
|
||||
## Auto Modes
|
||||
|
||||
::: warning
|
||||
For this mode to work properly [Position mode](#position-mode) must already be configured!
|
||||
:::
|
||||
|
||||
<a id="pure_pursuit_controller"></a>
|
||||
In [auto modes](../flight_modes_rover/differential.md#auto-modes) the autopilot takes over navigation tasks using the following control architecture:
|
||||
|
||||

|
||||
|
||||
The required parameters are separated into the following sections:
|
||||
|
||||
### Speed
|
||||
|
||||
These parameters are used to calculate the speed setpoint in auto modes:
|
||||
|
||||
1. [RO_DECEL_LIM](#RO_DECEL_LIM) ($m/s^2$) and [RO_JERK_LIM](#RO_JERK_LIM) ($m/s^3$) are used to calculate a velocity trajectory such that the rover comes to a smooth stop as it reaches a waypoint.
|
||||
|
||||
::: tip
|
||||
Plan a mission for the rover to drive a square and observe how it slows down when approaching a waypoint:
|
||||
|
||||
- If the rover decelerates too quickly decrease the [RO_DECEL_LIM](#RO_DECEL_LIM) parameter, if it starts slowing down too early increase the parameter.
|
||||
- If you observe a jerking motion as the rover slows down, decrease the [RO_JERK_LIM](#RO_JERK_LIM) parameter otherwise increase it as much as possible as it can interfere with the tuning of [RO_DECEL_LIM](#RO_DECEL_LIM).
|
||||
|
||||
These two parameters have to be tuned as a pair, repeat until you are satisfied with the behaviour.
|
||||
:::
|
||||
|
||||
2. Plot the `adjusted_speed_body_x_setpoint` and `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other.
|
||||
If the tracking of these setpoints is not satisfactory adjust the values for [RO_SPEED_P](#RO_SPEED_P) and [RO_SPEED_I](#RO_SPEED_I).
|
||||
|
||||
The rover only slows down when approaching the waypoint if the angle between the line segment between the previous/current waypoint and current/next waypoint is smaller than 180° - [RD_TRANS_DRV_TRN](#RD_TRANS_DRV_TRN).
|
||||
In other words: The rover slows down only if the expected heading error towards the next waypoint when arriving at the current waypoint is below [RD_TRANS_DRV_TRN](#RD_TRANS_DRV_TRN).
|
||||
|
||||

|
||||
|
||||
For more information on the [RD_TRANS_DRV_TRN](#RD_TRANS_DRV_TRN) parameter see [State Machine](#state-machine).
|
||||
|
||||
### State Machine
|
||||
|
||||
The module employs the following state machine to make full use of a differential rovers ability to turn on the spot:
|
||||
|
||||

|
||||
|
||||
These transition thresholds can be set with [RD_TRANS_DRV_TRN](#RD_TRANS_DRV_TRN) and [RD_TRANS_TRN_DRV](#RD_TRANS_TRN_DRV).
|
||||
|
||||
### Path Following
|
||||
|
||||
The [pure pursuit](#pure-pursuit-guidance-logic) algorithm is used to calculate a desired yaw for the vehicle that is then close loop controlled.
|
||||
The close loop yaw rate was tuned in the configuration of the [Stabilized mode](#stabilized-mode) and the pure pursuit was tuned when setting up the [Position mode](#position-mode).
|
||||
During any auto navigation task observe the behaviour of the rover.
|
||||
If you are unsatisfied with the path following, there are 3 steps to take:
|
||||
|
||||
1. Plot the `adjusted_yaw_rate_setpoint` and the `measured_yaw_rate` from the [RoverRateStatus](../msg_docs/RoverRateStatus.md) over each other.
|
||||
If the tracking of these setpoints is not satisfactory adjust the values for [RO_YAW_RATE_P](#RO_YAW_RATE_P) and [RO_YAW_RATE_I](#RO_YAW_RATE_I).
|
||||
2. Plot the `adjusted_yaw_setpoint` and the `measured_yaw` from the [RoverAttitudeStatus](../msg_docs/RoverAttitudeStatus.md) over each other.
|
||||
If the tracking of these setpoints is not satisfactory adjust the value for [RO_YAW_P](#RO_YAW_RATE_P) and potentially further tune [RO_YAW_RATE_I](#RO_YAW_RATE_I).
|
||||
3. Steps 1 and 2 ensures accurate setpoint tracking, if the path following is still unsatisfactory you need to further tune the [pure pursuit](#pure-pursuit-guidance-logic) parameters.
|
||||
|
||||
## Pure Pursuit Guidance Logic
|
||||
|
||||
The desired yaw setpoints are generated using a pure pursuit algorithm:
|
||||
The controller takes the intersection point between a circle around the vehicle and a line segment.
|
||||
In mission mode this line is usually constructed by connecting the previous and current waypoint:
|
||||
|
||||

|
||||
|
||||
The radius of the circle around the vehicle is used to tune the controller and is often referred to as look-ahead distance.
|
||||
|
||||
The look ahead distance sets how aggressive the controller behaves and is defined as $l_d = v \cdot k$.
|
||||
It depends on the velocity $v$ of the rover and a tuning parameter $k$ that can be set with the parameter [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN).
|
||||
|
||||
::: info
|
||||
A lower value of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) makes the controller more aggressive but can lead to oscillations!
|
||||
:::
|
||||
|
||||
The lookahead is constrained between [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX) and [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
|
||||
If the distance from the path to the rover is bigger than the lookahead distance, the rover will target the point on the path that is closest to the rover.
|
||||
|
||||
To summarize, the following parameters can be used to tune the controller:
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| -------------------------------------------------------------------------------------------------------- | --------------------------------------- | ---- |
|
||||
| <a id="PP_LOOKAHD_GAIN"></a>[PP_LOOKAHD_GAIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_GAIN) | Main tuning parameter | - |
|
||||
| <a id="PP_LOOKAHD_MAX"></a>[PP_LOOKAHD_MAX](../advanced_config/parameter_reference.md#PP_LOOKAHD_MAX) | Maximum value for the look ahead radius | m |
|
||||
| <a id="PP_LOOKAHD_MIN"></a>[PP_LOOKAHD_MIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_MIN) | Minimum value for the look ahead radius | m |
|
||||
|
||||
## Parameter Overview
|
||||
|
||||
List of all parameters of the differential rover module:
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------- |
|
||||
| <a id="RD_WHEEL_TRACK"></a>[RD_WHEEL_TRACK](../advanced_config/parameter_reference.md#RD_WHEEL_TRACK) | Wheel track | m |
|
||||
| <a id="RD_MAX_THR_YAW_R"></a>[RD_MAX_THR_YAW_R](../advanced_config/parameter_reference.md#RD_MAX_THR_YAW_R) | Yaw rate turning left/right wheels at max speed in opposite directions | m/s |
|
||||
| <a id="RD_TRANS_DRV_TRN"></a>[RD_TRANS_DRV_TRN](../advanced_config/parameter_reference.md#RD_TRANS_DRV_TRN) | Heading error threshold to switch from driving to spot turning | deg |
|
||||
| <a id="RD_TRANS_TRN_DRV"></a>[RD_TRANS_TRN_DRV](../advanced_config/parameter_reference.md#RD_TRANS_TRN_DRV) | Heading error threshold to switch from spot turning to driving | deg |
|
||||
| <a id="RD_MISS_SPD_GAIN"></a>[RD_MISS_SPD_GAIN](../advanced_config/parameter_reference.md#RD_MISS_SPD_GAIN) | Tuning parameter for the speed reduction during waypoint transition | m/s |
|
||||
| <a id="RO_YAW_RATE_LIM"></a>[RO_YAW_RATE_LIM](../advanced_config/parameter_reference.md#RO_YAW_RATE_LIM) | Maximum allowed yaw rate for the rover | deg/s |
|
||||
| <a id="RO_YAW_RATE_P"></a>[RO_YAW_RATE_P](../advanced_config/parameter_reference.md#RO_YAW_RATE_P) | Proportional gain for yaw rate controller | - |
|
||||
| <a id="RO_YAW_RATE_I"></a>[RO_YAW_RATE_I](../advanced_config/parameter_reference.md#RO_YAW_RATE_I) | Integral gain for yaw rate controller | - |
|
||||
| <a id="RO_YAW_P"></a>[RO_YAW_P](../advanced_config/parameter_reference.md#RO_YAW_P) | Proportional gain for yaw controller | - |
|
||||
| <a id="RO_MAX_THR_SPEED"></a>[RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED) | Speed the rover drives at maximum throttle | m/s |
|
||||
| <a id="RO_SPEED_P"></a>[RO_SPEED_P](../advanced_config/parameter_reference.md#RO_SPEED_P) | Proportional gain for speed controller | - |
|
||||
| <a id="RO_SPEED_I"></a>[RO_SPEED_I](../advanced_config/parameter_reference.md#RO_SPEED_I) | Integral gain for speed controller | - |
|
||||
| <a id="RO_SPEED_LIM"></a>[RO_SPEED_LIM](../advanced_config/parameter_reference.md#RO_SPEED_LIM) | Maximum allowed speed for the rover (and default mission speed). | m/s |
|
||||
| <a id="PP_LOOKAHD_GAIN"></a>[PP_LOOKAHD_GAIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_GAIN) | Main tuning parameter for pure pursuit | - |
|
||||
| <a id="PP_LOOKAHD_MAX"></a>[PP_LOOKAHD_MAX](../advanced_config/parameter_reference.md#PP_LOOKAHD_MAX) | Maximum value for the look ahead radius of the pure pursuit algorithm | m |
|
||||
| <a id="PP_LOOKAHD_MIN"></a>[PP_LOOKAHD_MIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_MIN) | Minimum value for the look ahead radius of the pure pursuit algorithm | m |
|
||||
| <a id="RO_ACCEL_LIM"></a>[RO_ACCEL_LIM](../advanced_config/parameter_reference.md#RO_ACCEL_LIM) | (Optional) Maximum allowed acceleration | m/s^2 |
|
||||
| <a id="RO_DECEL_LIM"></a>[RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM) | (Optional) Maximum allowed deceleration | m/s^2 |
|
||||
| <a id="RO_JERK_LIM"></a>[RO_JERK_LIM](../advanced_config/parameter_reference.md#RO_JERK_LIM) | (Optional) Maximum allowed jerk | $m/s^3$ |
|
||||
| <a id="RO_YAW_ACCEL_LIM"></a>[RO_YAW_ACCEL_LIM](../advanced_config/parameter_reference.md#RO_YAW_ACCEL_LIM) | (Optional) Maximum allowed yaw acceleration | m/s^2 |
|
||||
| <a id="RO_YAW_DECEL_LIM"></a>[RO_YAW_DECEL_LIM](../advanced_config/parameter_reference.md#RO_YAW_DECEL_LIM) | (Optional) Maximum allowed yaw deceleration | m/s^2 |
|
||||
|
||||
## See Also
|
||||
|
||||
- [Drive Modes (Differential Rover)](../flight_modes_rover/differential.md).
|
||||
@@ -0,0 +1,44 @@
|
||||
# Rover Configuration/Tuning
|
||||
This topic provides a step-by-step guide for setting up your rover.
|
||||
|
||||
Successive steps enable [drive modes](../flight_modes_rover/index.md) with more autopilot support and features:
|
||||
|
||||
| Step | Configuration | Unlocked PX4 Drive Mode |
|
||||
| ---- | ------------------------------------- | ------------------------------------------------------------------------- |
|
||||
| 1 | [Basic Setup](basic_setup.md) | [Full manual mode](../flight_modes_rover/manual.md#manual-mode) |
|
||||
| 2 | [Rate Tuning](rate_tuning.md) | [Manual acro mode](../flight_modes_rover/manual.md#acro-mode) |
|
||||
| 3 | [Attitude Tuning](attitude_tuning.md) | [Manual stabilized mode](../flight_modes_rover/manual.md#stabilized-mode) |
|
||||
| 4 | [Velocity Tuning](velocity_tuning.md) | [Manual position mode](../flight_modes_rover/manual.md#manual-mode) |
|
||||
| 5 | [Position Tuning](position_tuning.md) | [Auto modes](../flight_modes_rover/auto.md) |
|
||||
|
||||
::: warning
|
||||
Each step is dependent on the previous steps having been completed.
|
||||
Drive modes will only work properly if the preceding modes have been unlocked.
|
||||
:::
|
||||
|
||||
## Flashing the Rover Build
|
||||
|
||||
Rovers use a custom build that must be flashed onto your flight controller instead of the default PX4 build:
|
||||
|
||||
1. First build the rover firmware for your flight controller from the `main` branch (there is no release build, so you can't just select this build from QGroundControl).
|
||||
|
||||
To build for rover with the `make` command, replace the `_default` suffix with `_rover`.
|
||||
For example, to build rover for px4_fmu-v6x boards, you would use the command:
|
||||
|
||||
```sh
|
||||
make px4_fmu-v6x_rover
|
||||
```
|
||||
|
||||
::: info
|
||||
You can also enable the modules in default builds by adding these lines to your [board configuration](../hardware/porting_guide_config.md) (e.g. for fmu-v6x you might add them to [`main/boards/px4/fmu-v6x/default.px4board`](https://github.com/PX4/PX4-Autopilot/blob/main/boards/px4/fmu-v6x/default.px4board)):
|
||||
|
||||
```sh
|
||||
CONFIG_MODULES_ROVER_ACKERMANN=y
|
||||
CONFIG_MODULES_ROVER_DIFFERENTIAL=y
|
||||
CONFIG_MODULES_ROVER_MECANUM=y
|
||||
```
|
||||
|
||||
Note that adding the rover modules may lead to flash overflow, in which case you will need to disable modules that you do not plan to use (such as those related to multicopter or fixed wing).
|
||||
:::
|
||||
|
||||
2. Load the **custom firmware** that you just built onto your flight controller (see [Loading Firmware > Installing PX4 Main, Beta or Custom Firmware](../config/firmware.md#installing-px4-main-beta-or-custom-firmware)).
|
||||
@@ -1,376 +0,0 @@
|
||||
# Configuration/Tuning (Mecanum Rover)
|
||||
|
||||
This topic provides a step-by-step guide for setting up your [Mecanum rover](../frames_rover/mecanum.md).
|
||||
Successive steps enable [drive modes](../flight_modes_rover/mecanum.md) with more autopilot support and features.
|
||||
|
||||
::: warning
|
||||
Each step is dependent on the previous steps having been completed.
|
||||
Modes will only work properly if the preceding modes have been configured.
|
||||
:::
|
||||
|
||||
## Basic Setup
|
||||
|
||||
To start using the mecanum rover:
|
||||
|
||||
1. Enable Rover support by flashing the [PX4 rover build](../frames_rover/index.md#flashing-the-rover-build) onto your flight controller.
|
||||
Note that this is a special build that contains rover-specific modules.
|
||||
|
||||
2. In the [Airframe](../config/airframe.md) configuration select _Generic Rover Mecanum_ frame:
|
||||
|
||||

|
||||
|
||||
Select the **Apply and Restart** button.
|
||||
|
||||
::: info
|
||||
If this airframe does not show up in the UI, it can alternatively be selected by setting the [SYS_AUTOSTART](../advanced_config/parameter_reference.md#SYS_AUTOSTART) parameter to `52000`.
|
||||
:::
|
||||
|
||||
3. Use [Actuators Configuration & Testing](../config/actuators.md) to map the motor functions to flight controller outputs.
|
||||
|
||||
## Manual Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly the [Basic Setup](#basic-setup) must've already been completed!
|
||||
:::
|
||||
|
||||
The basic setup already covers the minimum setup required to use the rover in [Manual mode](../flight_modes_rover/mecanum.md#manual-mode).
|
||||
|
||||
This mode is also affected by (optional) acceleration/deceleration limits.
|
||||
As configuration of these limits becomes mandatory for subsequent modes, we do this setup here.
|
||||
|
||||
Navigate to [Parameters](../advanced_config/parameters.md) in QGroundControl and set the following parameters:
|
||||
|
||||
1. [RM_WHEEL_TRACK](#RM_WHEEL_TRACK) [m]: Measure the distance from the centre of the right wheel to the centre of the left wheel.
|
||||
|
||||

|
||||
|
||||
2. [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) [m/s]: Drive the rover at full throttle and set this parameter to the observed value of the ground speed.
|
||||
|
||||
:::info
|
||||
This parameter is also used for the feed-forward term of the speed control.
|
||||
It will be further tuned in the configuration of [Position mode](#position-mode).
|
||||
:::
|
||||
|
||||
3. (Optional) [RO_ACCEL_LIM](#RO_ACCEL_LIM) [m/s^2]: Maximum acceleration you want to allow for your rover.
|
||||
|
||||
<a id="RO_ACCEL_LIM_CONSIDERATIONS"></a>
|
||||
|
||||
:::tip
|
||||
Your rover has a maximum possible acceleration which is determined by the maximum torque the motor can supply.
|
||||
This may or may not be appropriate for your vehicle and use case.
|
||||
|
||||
One approach to determine an appropriate value is:
|
||||
|
||||
1. From a standstill, give the rover full throttle until it reaches the maximum speed.
|
||||
2. Disarm the rover and plot the `measured_speed_body_x` from [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md).
|
||||
3. Divide the maximum speed by the time it took to reach it and set this as the value for [RO_ACCEL_LIM](#RO_ACCEL_LIM).
|
||||
|
||||
Some RC rovers have enough torque to lift up if the maximum acceleration is not limited.
|
||||
If that is the case:
|
||||
|
||||
4. Set [RO_ACCEL_LIM](#RO_ACCEL_LIM) to a low value, give the rover full throttle from a standstill and observe its behaviour.
|
||||
5. Increase [RO_ACCEL_LIM](#RO_ACCEL_LIM) until the rover starts to lift up during the acceleration.
|
||||
6. Set [RO_ACCEL_LIM](#RO_ACCEL_LIM) to the highest value that does not cause the rover to lift up.
|
||||
|
||||
:::
|
||||
|
||||
4. (Optional) [RO_DECEL_LIM](#RO_DECEL_LIM) [m/s^2]: Maximum deceleration you want to allow for your rover.
|
||||
|
||||
:::tip
|
||||
The same [considerations](#RO_ACCEL_LIM_CONSIDERATIONS) as in the configuration of [RO_ACCEL_LIM](#RO_ACCEL_LIM) apply.
|
||||
:::
|
||||
|
||||
:::info
|
||||
This parameter is also used for the calculation of the speed setpoint during [Auto modes](#auto-modes).
|
||||
:::
|
||||
|
||||
## Acro Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly [Manual mode](#manual-mode) must've already been configured!
|
||||
:::
|
||||
|
||||
To set up [Acro mode](../flight_modes_rover/mecanum.md#acro-mode) navigate to [Parameters](../advanced_config/parameters.md) in QGroundControl and set the following parameters:
|
||||
|
||||
1. [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM) [deg/s]: This is the maximum yaw rate you want to allow for your rover.
|
||||
This will define the stick-to-yaw-rate mapping for all manual modes using closed loop yaw control and set an upper limit for the yaw rate setpoint for all [auto modes](#auto-modes).
|
||||
1. [RM_MAX_THR_YAW_R](#RM_MAX_THR_YAW_R) [m/s]: This parameter is used to calculate the feed-forward term of the closed loop yaw rate control.
|
||||
The controller calculates the required speed difference between the left and right motor to achieve the desired yaw rate.
|
||||
This desired speed difference is then linearly mapped to normalized motor commands.
|
||||
To get a good starting value for this parameter drive the rover in manual mode forwards at full throttle and note the ground speed of the vehicle.
|
||||
Then enter _half_ this value for the parameter.
|
||||
<a id="RM_YAW_RATE_P_TUNING"></a>
|
||||
|
||||
::: tip
|
||||
To further tune this parameter, first make sure you set [RO_YAW_RATE_P](#RO_YAW_RATE_P) and [RO_YAW_RATE_I](#RO_YAW_RATE_I) to zero.
|
||||
This way the yaw rate is only controlled by the feed-forward term, which makes it easier to tune.
|
||||
Now put the rover in [Acro mode](../flight_modes_rover/mecanum.md#acro-mode) and then move the right-stick of your controller to the right and/or left and hold it at a few different levels for a couple of seconds each.
|
||||
Disarm the rover and from the flight log plot the `adjusted_yaw_rate_setpoint` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) and the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) over each other.
|
||||
If the actual yaw rate of the rover is higher than the yaw rate setpoint, increase [RM_MAX_THR_YAW_R](#RM_MAX_THR_YAW_R).
|
||||
If it is the other way around decrease the parameter and repeat until you are satisfied with the setpoint tracking.
|
||||
:::
|
||||
|
||||
1. [RO_YAW_RATE_P](#RO_YAW_RATE_P) [-]: Proportional gain of the closed loop yaw rate controller.
|
||||
Unlike the feed-forward part of the controller, the closed loop yaw rate control will compare the yaw rate setpoint with the measured yaw rate and adapt to motor commands based on the error between them.
|
||||
The proportional gain is multiplied with this error and that value is added to the motor command.
|
||||
This compensates for disturbances such as uneven ground and external forces.
|
||||
|
||||
::: tip
|
||||
This parameter can be tuned the same way as [RM_MAX_THR_YAW_R](#RM_YAW_RATE_P_TUNING).
|
||||
If you tuned [RM_MAX_THR_YAW_R](#RM_MAX_THR_YAW_R) well, you might only need a very small value.
|
||||
:::
|
||||
|
||||
1. [RO_YAW_RATE_I](#RO_YAW_RATE_I) [-]: Integral gain of the closed loop yaw controller.
|
||||
The integral gain accumulates the error between the desired and actual yaw rate scaled by the integral gain over time and that value is added to the motor command.
|
||||
|
||||
::: tip
|
||||
An integrator might not be neccessary at this stage, but it will become important for subsequent modes.
|
||||
:::
|
||||
|
||||
1. (Optional) [RO_YAW_ACCEL_LIM](#RO_YAW_ACCEL_LIM) and [RO_YAW_DECEL_LIM](#RO_YAW_DECEL_LIM) [deg/s^2]: This is the maximum yaw acceleration and deceleration you want to allow for your rover.
|
||||
This can be used to smooth the `yaw_rate` setpoints and make their trajectory feasible based on the physical limitation on the rover to improve tracking and avoid integrator build up.
|
||||
|
||||
::: tip
|
||||
Your rover has a maximum possible yaw acceleration/deceleration which is determined by the maximum torque the motor can supply.
|
||||
This may or may not be appropriate for your vehicle and use case.
|
||||
|
||||
One approach to determine an appropriate value is:
|
||||
|
||||
1. Put the rover into [Manual mode](../flight_modes_rover/mecanum.md#manual-mode).
|
||||
2. From a standstill, move the right stick all the way to the right or left until the rover reaches the maximum yaw rate then return the right stick to the middle.
|
||||
3. Disarm the rover and plot the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md).
|
||||
4. Divide the maximum yaw rate by the time it took to reach it and set this as the value for [RO_YAW_ACCEL_LIM](#RO_YAW_ACCEL_LIM).
|
||||
5. Divide the maximum yaw rate by the time it took to return to a standstill and set this as the value for [RO_YAW_ACCEL_LIM](#RO_YAW_ACCEL_LIM).
|
||||
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Acro mode](../flight_modes_rover/mecanum.md#acro-mode).
|
||||
|
||||
## Stabilized Mode
|
||||
|
||||
::: warning
|
||||
For this mode to work properly [Acro mode](#acro-mode) must've already been configured!
|
||||
:::
|
||||
|
||||
For [Stabilized mode](../flight_modes_rover/mecanum.md#stabilized-mode) the controller utilizes a closed loop yaw controller, which creates a yaw rate setpoint to control the yaw when it is active:
|
||||
|
||||

|
||||
|
||||
Unlike the closed loop yaw rate, this controller has no feed-forward term.
|
||||
Therefore you only need to tune the closed loop gains:
|
||||
|
||||
1. [RO_YAW_P](#RO_YAW_P) [-]: Proportional gain for the closed loop yaw controller.
|
||||
|
||||
::: tip
|
||||
In stabilized mode the closed loop yaw control is only active when driving a straight line (no yaw rate input).
|
||||
Start with a value of 1 for [RO_YAW_P](#RO_YAW_P).
|
||||
Put the rover into stabilized mode and move the left stick of your controller up and/or down to drive forwards/backwards.
|
||||
Disarm the rover and from the flight log plot the `measured_yaw` and the `adjusted_yaw_setpoint` from the [RoverAttitudeStatus](../msg_docs/RoverAttitudeStatus.md) message over each other.
|
||||
Increase/Decrease the parameter until you are satisfied with the setpoint tracking.
|
||||
:::
|
||||
|
||||
::: info
|
||||
For the closed loop yaw control an integrator gain is useful because this setpoint is often constant for a while and an integrator eliminates steady state errors that can cause the rover to never reach the setpoint.
|
||||
Since the yaw and yaw rate controllers are cascaded, there only needs to be one integrator which is in the yaw rate controller.
|
||||
If you observe a steady state error in the yaw setpoint increase the [RO_YAW_RATE_I](#RO_YAW_RATE_I) parameter.
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Stabilized mode](../flight_modes_rover/mecanum.md#stabilized-mode).
|
||||
|
||||
## Position Mode
|
||||
|
||||
:::warning
|
||||
For this mode to work properly [Stabilized mode](#stabilized-mode) must already be configured!
|
||||
:::
|
||||
|
||||
[Position mode](../flight_modes_rover/mecanum.md#position-mode) is the most advanced manual mode, utilizing closed loop yaw rate, yaw and speed control and leveraging position estimates.
|
||||
|
||||
To configure set the following parameters:
|
||||
|
||||
::: info
|
||||
The speed control in longitudinal and lateral direction use the same tuning parameters.
|
||||
:::
|
||||
|
||||
1. [RO_SPEED_LIM](#RO_SPEED_LIM) [m/s]: This is the maximum speed you want to allow for your rover.
|
||||
This will define the stick-to-speed mapping for position mode and set an upper limit for the speed setpoint for all [auto modes](#auto-modes).
|
||||
For mecanum rovers the speed is defined in the direction of travel (magnitude of the velocity vector consisting of the longitudinal and lateral speed).
|
||||
2. [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) [m/s]: This parameter is used to calculate the feed-forward term of the closed loop speed control which linearly maps desired speeds to normalized motor commands.
|
||||
A good starting point is the observed ground speed when the rover drives at maximum throttle in [Manual mode](../flight_modes_rover/mecanum.md#manual-mode).
|
||||
|
||||
<a id="RD_SPEED_P_TUNING"></a>
|
||||
|
||||
::: tip
|
||||
To further tune this parameter:
|
||||
|
||||
1. Set [RO_SPEED_P](#RO_SPEED_P) and [RO_SPEED_I](#RO_SPEED_I) to zero.
|
||||
This way the speed is only controlled by the feed-forward term, which makes it easier to tune.
|
||||
2. Put the rover in [Position mode](../flight_modes_rover/mecanum.md#position-mode) and then move the left stick of your controller up and/or down and hold it at a few different levels for a couple of seconds each.
|
||||
3. Disarm the rover and from the flight log plot the `adjusted_speed_body_x_setpoint` and the `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other.
|
||||
4. If the actual speed of the rover is higher than the speed setpoint, increase [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED).
|
||||
If it is the other way around decrease the parameter and repeat until you are satisfied with the setpoint tracking.
|
||||
|
||||
:::
|
||||
|
||||
::: info
|
||||
If your rover oscillates when driving a straight line in [Position mode](../flight_modes_rover/mecanum.md#position-mode) just set this parameter to the observed ground speed at maximum throttle in [Manual mode](../flight_modes_rover/mecanum.md#manual-mode) and complete steps 5-7 first before continuing the tuning of the closed loop speed control (Steps 2-4).
|
||||
:::
|
||||
|
||||
3. [RO_SPEED_P](#RO_SPEED_P) [-]: Proportional gain of the closed loop speed controller.
|
||||
|
||||
::: tip
|
||||
This parameter can be tuned the same way as [RO_MAX_THR_SPEED](#RD_SPEED_P_TUNING).
|
||||
If you tuned [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) well, you might only need a very small value.
|
||||
:::
|
||||
|
||||
4. [RO_SPEED_I](#RO_SPEED_I) [-]: Integral gain for the closed loop speed controller.
|
||||
|
||||
::: tip
|
||||
For the closed loop speed control an integrator gain is useful because this setpoint is often constant for a while and an integrator eliminates steady state errors that can cause the rover to never reach the setpoint.
|
||||
:::
|
||||
|
||||
5. [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN): When driving in a straight line (no yaw rate input) position mode leverages the same path following algorithm used in [auto modes](#auto-modes) called [pure pursuit](#pure-pursuit-guidance-logic) to achieve the best possible straight line driving behaviour ([Illustration of control architecture](#pure_pursuit_controller)).
|
||||
This parameter determines how aggressive the controller will steer towards the path.
|
||||
|
||||
::: tip
|
||||
Decreasing the parameter makes it more aggressive but can lead to oscillations.
|
||||
|
||||
To tune this:
|
||||
|
||||
1. Start with a value of 1 for [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN)
|
||||
2. Put the rover in [Position mode](../flight_modes_rover/mecanum.md#position-mode) and while driving a straight line at approximately half the maximum speed observe its behaviour.
|
||||
3. If the rover does not drive in a straight line, reduce the value of the parameter, if it oscillates around the path increase the value.
|
||||
4. Repeat until you are satisfied with the behaviour.
|
||||
|
||||
:::
|
||||
|
||||
6. [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN): Minimum threshold for the lookahead distance used by the [pure pursuit algorithm](#pure-pursuit-guidance-logic).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/mecanum.md#position-mode) and drive at very low speeds, if the rover starts to oscillate even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then increase the value of [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
:::
|
||||
|
||||
7. [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX): Maximum threshold for the lookahead distance used by [pure pursuit](#pure-pursuit-guidance-logic).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/mecanum.md#position-mode) and drive at very high speeds, if the rover does not drive in a straight line even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then decrease the value of [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX).
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Position mode](../flight_modes_rover/mecanum.md#position-mode).
|
||||
|
||||
## Auto Modes
|
||||
|
||||
::: warning
|
||||
For this mode to work properly [Position mode](#position-mode) must already be configured!
|
||||
:::
|
||||
|
||||
<a id="pure_pursuit_controller"></a>
|
||||
In [auto modes](../flight_modes_rover/mecanum.md#auto-modes) the autopilot takes over navigation tasks using the following control architecture:
|
||||
|
||||

|
||||
|
||||
The mecanum module fully leverages the omnidirectionality of this type of rover by maintaining the initial heading of the rover during the entire mission (see [Pure Pursuit Guidance Logic](#pure-pursuit-guidance-logic)).
|
||||
|
||||
The required parameters are separated into the following sections:
|
||||
|
||||
### Speed
|
||||
|
||||
These parameters are used to calculate the velocity setpoint in auto modes:
|
||||
|
||||
1. [RO_SPEED_LIM](#RO_SPEED_LIM): Sets the default speed ($m/s$) for the rover during the mission (as well as the maximum speed).
|
||||
For mecanum rovers the speed is defined in the direction of travel (magnitude of the velocity vector consisting of the longitudinal and lateral speed).
|
||||
2. [RO_DECEL_LIM](#RO_DECEL_LIM) ($m/s^2$) and [RO_JERK_LIM](#RO_JERK_LIM) ($m/s^3$) are used to calculate a velocity trajectory such that the rover comes to a smooth stop as it reaches a waypoint.
|
||||
|
||||
::: tip
|
||||
Plan a mission for the rover to drive a square and observe how it slows down when approaching a waypoint:
|
||||
|
||||
- If the rover decelerates too quickly decrease the [RO_DECEL_LIM](#RO_DECEL_LIM) parameter, if it starts slowing down too early increase the parameter.
|
||||
- If you observe a jerking motion as the rover slows down, decrease the [RO_JERK_LIM](#RO_JERK_LIM) parameter otherwise increase it as much as possible as it can interfere with the tuning of [RO_DECEL_LIM](#RO_DECEL_LIM).
|
||||
|
||||
These two parameters have to be tuned as a pair, repeat until you are satisfied with the behaviour.
|
||||
:::
|
||||
|
||||
3. [RM_MISS_SPD_GAIN](#RM_MISS_SPD_GAIN): The rover slows down when approaching a waypoint based on the angle between the line segment from the previous to current waypoint and current to next waypoint.
|
||||
How much the rover slows down can be tuned with this parameter:
|
||||
|
||||
$$
|
||||
v_{transition} = v_{max} \cdot (1 - \theta_{normalized} * k)
|
||||
$$
|
||||
|
||||
with:
|
||||
|
||||
- $v_{transition}:$ Transition speed
|
||||
- $v_{max}:$ Maximum speed ([RO_SPEED_LIM](#RO_SPEED_LIM))
|
||||
- $\theta_{normalized}:$ Angle between the line segment of the prev-current and current-next waypoints, normalized from $[0\degree, 180\degree]$ to $[0, 1]$
|
||||
- $k:$ Tuning parameter ([RM_MISS_SPD_GAIN](#RM_MISS_SPD_GAIN)).
|
||||
|
||||
4. Plot the `adjusted_speed_body_x_setpoint` and `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other.
|
||||
If the tracking of these setpoints is not satisfactory adjust the values for [RO_SPEED_P](#RO_SPEED_P) and [RO_SPEED_I](#RO_SPEED_I).
|
||||
|
||||
### Path Following
|
||||
|
||||
The [pure pursuit](#pure-pursuit-guidance-logic) algorithm is used to calculate a desired bearing for the vehicle that is then close loop controlled.
|
||||
For mecanum rovers the path following is achieved by directly controlling the velocity of the rover in direction of the desired bearing.
|
||||
During any auto navigation task observe the behaviour of the rover:
|
||||
|
||||
1. If you are unsatisfied with the path following you need to further tune the [pure pursuit](#pure-pursuit-guidance-logic) parameters.
|
||||
2. If the rover does not maintain its initial heading well enough, adjust the value for [RO_YAW_P](#RO_YAW_RATE_P) and potentially further tune [RO_YAW_RATE_I](#RO_YAW_RATE_I).
|
||||
|
||||
## Pure Pursuit Guidance Logic
|
||||
|
||||
The desired bearing setpoints are generated using a pure pursuit algorithm:
|
||||
The controller takes the intersection point between a circle around the vehicle and a line segment.
|
||||
In mission mode this line is usually constructed by connecting the previous and current waypoint:
|
||||
|
||||

|
||||
|
||||
The radius of the circle around the vehicle is used to tune the controller and is often referred to as look-ahead distance.
|
||||
|
||||
The look ahead distance sets how aggressive the controller behaves and is defined as $l_d = v \cdot k$.
|
||||
It depends on the velocity $v$ of the rover and a tuning parameter $k$ that can be set with the parameter [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN).
|
||||
|
||||
::: info
|
||||
A lower value of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) makes the controller more aggressive but can lead to oscillations!
|
||||
:::
|
||||
|
||||
The lookahead is constrained between [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX) and [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
|
||||
If the distance from the path to the rover is bigger than the lookahead distance, the rover will target the point on the path that is closest to the rover.
|
||||
|
||||
To summarize, the following parameters can be used to tune the controller:
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| -------------------------------------------------------------------------------------------------------- | --------------------------------------- | ---- |
|
||||
| <a id="PP_LOOKAHD_GAIN"></a>[PP_LOOKAHD_GAIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_GAIN) | Main tuning parameter | - |
|
||||
| <a id="PP_LOOKAHD_MAX"></a>[PP_LOOKAHD_MAX](../advanced_config/parameter_reference.md#PP_LOOKAHD_MAX) | Maximum value for the look ahead radius | m |
|
||||
| <a id="PP_LOOKAHD_MIN"></a>[PP_LOOKAHD_MIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_MIN) | Minimum value for the look ahead radius | m |
|
||||
|
||||
## Parameter Overview
|
||||
|
||||
List of all parameters of the mecanum rover module:
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------- |
|
||||
| <a id="RM_WHEEL_TRACK"></a>[RM_WHEEL_TRACK](../advanced_config/parameter_reference.md#RM_WHEEL_TRACK) | Wheel track | m |
|
||||
| <a id="RM_MAX_THR_YAW_R"></a>[RM_MAX_THR_YAW_R](../advanced_config/parameter_reference.md#RM_MAX_THR_YAW_R) | Yaw rate turning left/right wheels at max speed in opposite directions | m/s |
|
||||
| <a id="RM_MISS_SPD_GAIN"></a>[RM_MISS_SPD_GAIN](../advanced_config/parameter_reference.md#RM_MISS_SPD_GAIN) | Tuning parameter for the velocity reduction during waypoint transition | - |
|
||||
| <a id="RM_COURSE_CTL_TH"></a>[RM_COURSE_CTL_TH](../advanced_config/parameter_reference.md#RM_COURSE_CTL_TH) | Threshold to update course control in manual position mode | rad |
|
||||
| <a id="RO_YAW_RATE_LIM"></a>[RO_YAW_RATE_LIM](../advanced_config/parameter_reference.md#RO_YAW_RATE_LIM) | Maximum allowed yaw rate for the rover | deg/s |
|
||||
| <a id="RO_YAW_RATE_P"></a>[RO_YAW_RATE_P](../advanced_config/parameter_reference.md#RO_YAW_RATE_P) | Proportional gain for yaw rate controller | - |
|
||||
| <a id="RO_YAW_RATE_I"></a>[RO_YAW_RATE_I](../advanced_config/parameter_reference.md#RO_YAW_RATE_I) | Integral gain for yaw rate controller | - |
|
||||
| <a id="RO_YAW_P"></a>[RO_YAW_P](../advanced_config/parameter_reference.md#RO_YAW_P) | Proportional gain for yaw controller | - |
|
||||
| <a id="RO_SPEED_LIM"></a>[RO_SPEED_LIM](../advanced_config/parameter_reference.md#RO_SPEED_LIM) | Maximum allowed speed for the rover (and default mission speed). | m/s |
|
||||
| <a id="RO_MAX_THR_SPEED"></a>[RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED) | Speed the rover drives at maximum throttle | m/s |
|
||||
| <a id="RO_SPEED_P"></a>[RO_SPEED_P](../advanced_config/parameter_reference.md#RO_SPEED_P) | Proportional gain for speed controller | - |
|
||||
| <a id="RO_SPEED_I"></a>[RO_SPEED_I](../advanced_config/parameter_reference.md#RO_SPEED_I) | Integral gain for speed controller | - |
|
||||
| <a id="PP_LOOKAHD_GAIN"></a>[PP_LOOKAHD_GAIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_GAIN) | Main tuning parameter for pure pursuit | - |
|
||||
| <a id="PP_LOOKAHD_MAX"></a>[PP_LOOKAHD_MAX](../advanced_config/parameter_reference.md#PP_LOOKAHD_MAX) | Maximum value for the look ahead radius of the pure pursuit algorithm | m |
|
||||
| <a id="PP_LOOKAHD_MIN"></a>[PP_LOOKAHD_MIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_MIN) | Minimum value for the look ahead radius of the pure pursuit algorithm | m |
|
||||
| <a id="RO_ACCEL_LIM"></a>[RO_ACCEL_LIM](../advanced_config/parameter_reference.md#RO_ACCEL_LIM) | (Optional) Maximum allowed acceleration | m/s^2 |
|
||||
| <a id="RO_DECEL_LIM"></a>[RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM) | (Optional) Maximum allowed deceleration | m/s^2 |
|
||||
| <a id="RO_JERK_LIM"></a>[RO_JERK_LIM](../advanced_config/parameter_reference.md#RO_JERK_LIM) | (Optional) Maximum allowed jerk | $m/s^3$ |
|
||||
| <a id="RO_YAW_ACCEL_LIM"></a>[RO_YAW_ACCEL_LIM](../advanced_config/parameter_reference.md#RO_YAW_ACCEL_LIM) | (Optional) Maximum allowed yaw acceleration | m/s^2 |
|
||||
| <a id="RO_YAW_DECEL_LIM"></a>[RO_YAW_DECEL_LIM](../advanced_config/parameter_reference.md#RO_YAW_DECEL_LIM) | (Optional) Maximum allowed yaw deceleration | m/s^2 |
|
||||
|
||||
## See Also
|
||||
|
||||
- [Drive Modes (Mecanum Rover)](../flight_modes_rover/mecanum.md).
|
||||
@@ -0,0 +1,198 @@
|
||||
# Position Tuning
|
||||
|
||||
:::warning
|
||||
The [velocity tuning](velocity_tuning.md) must've already been completed before this step!
|
||||
:::
|
||||
|
||||
The position controller is responsible for autonomously guiding the vehicle to a position setpoint.
|
||||
These position setpoints are automatically generated by the internal PX4 auto modes (Mission, Return, GoTo, ...) or can directly be sent to the rover through the `RoverPositionSetpoint.msg` (External Modes).
|
||||
A path is generated for the rover to reach its destination, which tracked through a path following algorithm called [pure pursuit](#pure-pursuit-guidance-logic-info-only).
|
||||
|
||||
To tune the position controller and unlock [Auto modes](../flight_modes_rover/auto.md) configure the following [parameters](../advanced_config/parameters.md) in QGroundControl:
|
||||
|
||||
## Speed
|
||||
|
||||
1. (Optional) [RO_SPEED_RED](#RO_SPEED_RED): Tuning parameter for the speed reduction based on the course error.
|
||||
This can be used to limit the maximum allowed speed based on the difference between the current course and the bearing setpoint:
|
||||
$v_{max} = v_{full throttle} \cdot (1 - \theta_{normalized} \cdot k) $
|
||||
|
||||
with
|
||||
|
||||
- $v_{max}:$ Maximum speed
|
||||
- $v_{full throttle}:$ Speed at maximum throttle [RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED).
|
||||
- $\theta_{normalized}:$ Course error (Course - bearing setpoint) normalized from $[0\degree, 180\degree]$ to $[0, 1]$
|
||||
- $k:$ Tuning parameter [RO_SPEED_RED](#RO_SPEED_RED)
|
||||
|
||||
::: note
|
||||
This parameter is used to calculate the speed at which the vehicle arrives at a waypoint based on the upcoming corner.
|
||||
Set to -1 to disable course error based speed reduction.
|
||||
:::
|
||||
|
||||
2. (Optional) [RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM) [m/s^2] and [RO_JERK_LIM](../advanced_config/parameter_reference.md#RO_JERK_LIM) [m/s^3] are used to calculate a speed trajectory such that the rover reaches the next waypoint with the calculated cornering speed.
|
||||
|
||||
::: tip
|
||||
Plan a mission for the rover to drive a square and observe how it slows down when approaching a waypoint:
|
||||
|
||||
- If the rover decelerates too quickly decrease the [RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM) parameter, if it starts slowing down too early increase the parameter.
|
||||
- If you observe a jerking motion as the rover slows down, decrease the [RO_JERK_LIM](../advanced_config/parameter_reference.md#RO_JERK_LIM) parameter otherwise increase it as much as possible as it can interfere with the tuning of [RO_DECEL_LIM](../advanced_config/parameter_reference.md#RO_DECEL_LIM).
|
||||
|
||||
These two parameters have to be tuned as a pair, repeat until you are satisfied with the behaviour.
|
||||
:::
|
||||
|
||||
3. Plot the `adjusted_speed_body_x_setpoint` and `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other.
|
||||
If the tracking of these setpoints is not satisfactory adjust the values for [RO_SPEED_P](../advanced_config/parameter_reference.md#RO_SPEED_P) and [RO_SPEED_I](../advanced_config/parameter_reference.md#RO_SPEED_I).
|
||||
|
||||
|
||||
## Path Following
|
||||
|
||||
The [pure pursuit](#pure-pursuit-guidance-logic-info-only) algorithm is used to calculate a bearing setpoint for the vehicle that is then close loop controlled.
|
||||
|
||||
The following parameters are used to tune the algorithm:
|
||||
|
||||
1. [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN): When driving in a straight line (right stick centered) position mode leverages the same path following algorithm used in [auto modes](../flight_modes_rover/auto.md) called [pure pursuit](#pure-pursuit-guidance-logic-info-only) to achieve the best possible straight line driving behaviour.
|
||||
This parameter determines how aggressive the controller will steer towards the path.
|
||||
|
||||
::: tip
|
||||
Decreasing the parameter makes it more aggressive but can lead to oscillations.
|
||||
|
||||
To tune this:
|
||||
|
||||
1. Start with a value of 1 for [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN)
|
||||
2. Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and while driving a straight line at approximately half the maximum speed observe its behaviour.
|
||||
3. If the rover does not drive in a straight line, reduce the value of the parameter, if it oscillates around the path increase the value.
|
||||
4. Repeat until you are satisfied with the behaviour.
|
||||
|
||||
:::
|
||||
|
||||
2. [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN): Minimum threshold for the lookahead distance used by the [pure pursuit algorithm](#pure-pursuit-guidance-logic-info-only).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and drive at very low speeds, if the rover starts to oscillate even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then increase the value of [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
:::
|
||||
|
||||
3. [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX): Maximum threshold for the lookahead distance used by [pure pursuit](#pure-pursuit-guidance-logic-info-only).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and drive at very high speeds, if the rover does not drive in a straight line even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then decrease the value of [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX).
|
||||
:::
|
||||
|
||||
During any auto navigation task observe the behaviour of the rover and if you are unsatisfied with the path following, there are 2 steps to take:
|
||||
|
||||
1. Check if all the setpoints ([rate](rate_tuning.md), [attitude](attitude_tuning.md) and [velocity](velocity_tuning.md)) are properly tracked.
|
||||
2. Further tune the [path following algorithm](#path-following).
|
||||
|
||||
## Ackermann Rover Only
|
||||
|
||||
Ackermann rovers employ a special cornering logic causing the rover to "cut corners" to achieve a smooth trajectory.
|
||||
This is done by scaling the acceptance radius based on the corner the rover has to drive (for geometric explanation see [Cornering logic](#corner-cutting-logic-info-only)).
|
||||
|
||||

|
||||
|
||||
The degree to which corner cutting is allowed can be tuned, or disabled, with the following parameters:
|
||||
|
||||
::: info
|
||||
The corner cutting effect is a tradeoff between how close you get to the waypoint and the smoothness of the trajectory.
|
||||
:::
|
||||
|
||||
1. [NAV_ACC_RAD](../advanced_config/parameter_reference.md#NAV_ACC_RAD) [m]: Default acceptance radius
|
||||
This is also used as a lower bound for the acceptance radius scaling.
|
||||
2. [RA_ACC_RAD_MAX](#RA_ACC_RAD_MAX) [m]: The maximum the acceptance radius can be scaled to.
|
||||
Set equal to [NAV_ACC_RAD](../advanced_config/parameter_reference.md#NAV_ACC_RAD) to disable the corner cutting effect.
|
||||
3. [RA_ACC_RAD_GAIN](#RA_ACC_RAD_GAIN) [-]: This tuning parameter is a multiplicand on the [calculated ideal acceptance radius](#corner-cutting-logic-info-only) to account for dynamic effects.
|
||||
|
||||
:::tip
|
||||
Initially set this parameter to `1`.
|
||||
If you observe the rover overshooting the corner, increase this parameter until you are satisfied with the behaviour.
|
||||
Note that the scaling of the acceptance radius is limited by [RA_ACC_RAD_MAX](#RA_ACC_RAD_MAX).
|
||||
:::
|
||||
|
||||
### Corner Cutting Logic (Info only)
|
||||
|
||||
To enable a smooth trajectory, the acceptance radius of waypoints is scaled based on the angle between a line segment from the current-to-previous and current-to-next waypoints.
|
||||
The ideal trajectory would be to arrive at the next line segment with the heading pointing towards the next waypoint.
|
||||
For this purpose the minimum turning circle of the rover is inscribed tangentially to both line segments.
|
||||
|
||||

|
||||
|
||||
The acceptance radius of the waypoint is set to the distance from the waypoint to the tangential points between the circle and the line segments:
|
||||
|
||||
$$
|
||||
\begin{align*}
|
||||
r_{min} &= \frac{L}{\sin\left( \delta_{max}\right) } \\
|
||||
\theta &= \frac{1}{2}\arccos\left( \frac{\vec{a}*\vec{b}}{|\vec{a}||\vec{b}|}\right) \\
|
||||
r_{acc} &= \frac{r_{min}}{\tan\left( \theta\right) }
|
||||
\end{align*}
|
||||
$$
|
||||
|
||||
| Symbol | Description | Unit |
|
||||
| -------------- | ---------------------------------- | ---- |
|
||||
| $\vec{a}$ | Vector from current to previous WP | m |
|
||||
| $\vec{b}$ | Vector from current to next WP | m |
|
||||
| $r_{min}$ | Minimum turn radius | m |
|
||||
| $\delta_{max}$ | Maximum steer angle | m |
|
||||
| $r_{acc}$ | Acceptance radius | m |
|
||||
|
||||
## Differential Rover Only
|
||||
|
||||
Differential rovers employ the following state machine to make full use of a differential rovers ability to turn on the spot:
|
||||
|
||||

|
||||
|
||||
These transition thresholds can be set with [RD_TRANS_DRV_TRN](#RD_TRANS_DRV_TRN) and [RD_TRANS_TRN_DRV](#RD_TRANS_TRN_DRV).
|
||||
|
||||
In mission modes [RD_TRANS_DRV_TRN](#RD_TRANS_DRV_TRN) is also used to slow down the rover to a standstill, if the transition angle between the waypoints exceeds this threshold:
|
||||
|
||||

|
||||
|
||||
## Pure Pursuit Guidance Logic (Info Only)
|
||||
|
||||
The desired bearing setpoints are generated using the pure pursuit algorithm.
|
||||
|
||||
The controller takes the intersection point between a circle around the vehicle and a line segment.
|
||||
When targeting a position setpoint this line is constructed from the current position to the destination or when executing a mission it is usually constructed by connecting the previous and current waypoint.
|
||||
|
||||

|
||||
|
||||
The radius of the circle around the vehicle is used to tune the controller and is often referred to as look-ahead distance.
|
||||
|
||||
The look-ahead distance sets how aggressive the controller behaves and is defined as $l_d = v \cdot k$.
|
||||
It depends on the velocity $v$ of the rover and a tuning parameter $k$ that can be set with the parameter [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN).
|
||||
|
||||
::: info
|
||||
A lower value of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) makes the controller more aggressive but can lead to oscillations!
|
||||
:::
|
||||
|
||||
The lookahead is constrained between [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX) and [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
|
||||
If the distance from the path to the rover is bigger than the lookahead distance, the rover will target the point on the path that is closest to the rover.
|
||||
|
||||
## Position Controller Structure (Info Only)
|
||||
|
||||
This section provides additional information for developers and people with experience in control system design.
|
||||
|
||||
The position controller uses the following structure:
|
||||
|
||||

|
||||
|
||||
## Parameter Overview
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---- |
|
||||
| <a id="RO_SPEED_RED"></a>[RO_SPEED_RED](../advanced_config/parameter_reference.md#RO_SPEED_RED) | (Optional) Tuning parameter for the speed reduction based on the course error | - |
|
||||
| <a id="PP_LOOKAHD_GAIN"></a>[PP_LOOKAHD_GAIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_GAIN) | Pure pursuit: Main tuning parameter | - |
|
||||
| <a id="PP_LOOKAHD_MAX"></a>[PP_LOOKAHD_MAX](../advanced_config/parameter_reference.md#PP_LOOKAHD_MAX) | Pure pursuit: Maximum value for the look ahead radius | m |
|
||||
| <a id="PP_LOOKAHD_MIN"></a>[PP_LOOKAHD_MIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_MIN) | Pure pursuit: Minimum value for the look ahead radius | m |
|
||||
|
||||
## Ackermann Specific
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | ---- |
|
||||
| <a id="RA_ACC_RAD_MAX"></a>[RA_ACC_RAD_MAX](../advanced_config/parameter_reference.md#RA_ACC_RAD_MAX) | (Optional) Maximum radius the acceptance radius can be scaled to | m |
|
||||
| <a id="RA_ACC_RAD_GAIN"></a>[RA_ACC_RAD_GAIN](../advanced_config/parameter_reference.md#RA_ACC_RAD_GAIN) | (Optional) Tuning parameter for the acceptance radius scaling | - |
|
||||
|
||||
## Differential Specific
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ---- |
|
||||
| <a id="RD_TRANS_DRV_TRN"></a>[RD_TRANS_DRV_TRN](../advanced_config/parameter_reference.md#RD_TRANS_DRV_TRN) | Heading error threshold to switch from driving to spot turning | deg |
|
||||
| <a id="RD_TRANS_TRN_DRV"></a>[RD_TRANS_TRN_DRV](../advanced_config/parameter_reference.md#RD_TRANS_TRN_DRV) | Heading error threshold to switch from spot turning to driving | deg |
|
||||
@@ -0,0 +1,137 @@
|
||||
# Rate Tuning
|
||||
|
||||
::: warning
|
||||
The [basic setup](basic_setup.md) must've already been completed before this step!
|
||||
:::
|
||||
|
||||
To tune the rate controller and unlock [Acro mode](../flight_modes_rover/manual.md#acro-mode) configure the following [parameters](../advanced_config/parameters.md) in QGroundControl:
|
||||
|
||||
1. [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM): Maximum yaw rate you want to allow for your rover.
|
||||
|
||||
:::tip
|
||||
Limiting the yaw rate is necessary if the rover is prone rolling over, loosing traction at high speeds or if passenger comfort is important.
|
||||
Small rovers especially can be prone to rolling over when steering aggressively at high speeds.
|
||||
|
||||
If this is the case:
|
||||
|
||||
1. In [Acro mode](../flight_modes_rover/manual.md#acro-mode), set [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM) to a small value, drive the rover at full throttle and steer all the way to the left or right.
|
||||
1. Increase [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM) until the wheels of the rover start to lift up.
|
||||
1. Set [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM) to the highest value that does not cause the rover to lift up.
|
||||
|
||||
If you see no need to limit the yaw rate, set this parameter to the maximum yaw rate the rover can achieve:
|
||||
|
||||
1. In [Manual mode](../flight_modes_rover/manual.md#manual-mode) drive the rover at full throttle and with the maximum steering angle.
|
||||
1. Plot the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) and enter the highest observed value for [RO_YAW_RATE_LIM](#RO_YAW_RATE_LIM).
|
||||
|
||||
:::
|
||||
|
||||
1. (Optional) [RO_YAW_RATE_CORR](#RO_YAW_RATE_CORR) [-]: Yaw rate correction factor.
|
||||
|
||||
This can be used to scale the mapping from the yaw rate setpoint to the steering effort if it is offset from the [idealized mapping](#kinematic-models) (This could be due to wheel misalignments, excessive friction etc.).
|
||||
|
||||
:::note
|
||||
Skid/tank-steered and mecanum rovers will most likely require this adjustment.
|
||||
:::
|
||||
|
||||
:::tip
|
||||
To tune this parameter, first make sure you set [RO_YAW_RATE_P](#RO_YAW_RATE_P) and [RO_YAW_RATE_I](#RO_YAW_RATE_I) to zero.
|
||||
This way the yaw rate is only controlled by the feed-forward term, which makes it easier to tune.
|
||||
Now put the rover in [Acro mode](../flight_modes_rover/manual.md#acro-mode) and then move the right-stick of your controller to the right and/or left and hold it at a few different levels for a couple of seconds each while driving with a constant throttle (for differential/mecanum rovers this can also be done while standing still).
|
||||
Disarm the rover and from the flight log plot the `adjusted_yaw_rate_setpoint` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) and the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) over each other.
|
||||
If the actual yaw rate of the rover is higher than the yaw rate setpoint, decrease [RO_YAW_RATE_CORR](#RO_YAW_RATE_CORR) (between (0, 1]).
|
||||
If it is the other way around increase the parameter [1, inf) and repeat until you are satisfied with the setpoint tracking.
|
||||
:::
|
||||
|
||||
1. [RO_YAW_RATE_P](#RO_YAW_RATE_P) [-]: Proportional gain of the closed loop yaw rate controller.
|
||||
The closed loop acceleration control will compare the yaw rate setpoint with the measured yaw rate and adapt the motor commands based on the error between them.
|
||||
The proportional gain is multiplied with this error and that value is added to the motor command.
|
||||
This compensates for disturbances such as uneven ground and external forces.
|
||||
|
||||
:::tip
|
||||
To tune this parameter:
|
||||
|
||||
1. Put the rover in [Acro mode](../flight_modes_rover/manual.md#acro-mode) and hold the throttle stick and the right stick at a few different levels for a couple of seconds each.
|
||||
1. Disarm the rover and from the flight log plot the `adjusted_yaw_rate_setpoint` and the `measured_yaw_rate` from [RoverRateStatus](../msg_docs/RoverRateStatus.md) over each other.
|
||||
1. Increase [RO_YAW_RATE_P](#RO_YAW_RATE_P) if the measured value does not track the setpoint fast enough or decrease it if the measurement overshoots the setpoint by too much.
|
||||
1. Repeat until you are satisfied with the behaviour.
|
||||
:::
|
||||
|
||||
1. [RO_YAW_RATE_I](#RO_YAW_RATE_I) [-]: Integral gain of the closed loop yaw rate controller.
|
||||
The integral gain accumulates the error between the desired and actual yaw rate scaled by the integral gain over time and that value is added to the motor command.
|
||||
|
||||
::: tip
|
||||
An integrator might not be necessary at this stage, but it will become important for subsequent modes.
|
||||
:::
|
||||
|
||||
1. (Optional) [RO_YAW_ACCEL_LIM](#RO_YAW_ACCEL_LIM)/[RO_YAW_DECEL_LIM](#RO_YAW_DECEL_LIM) [deg/s^2]: Used to limit the yaw acceleration/deceleration.
|
||||
This can be used to smoothen the yaw rate setpoint trajectory.
|
||||
|
||||
1. (Optional) [RO_YAW_STICK_DZ](#RO_YAW_STICK_DZ) [-]: Percentage of yaw stick input range that will be interpreted as zero around the stick centered value.
|
||||
|
||||
1. (Advanced) [RO_YAW_RATE_TH](#RO_YAW_RATE_TH) [deg/s]: The minimum threshold for the yaw rate measurement not to be interpreted as zero.
|
||||
This can be used to cut off measurement noise when the rover is standing still.
|
||||
|
||||
The rover is now ready to drive in [Acro mode](../flight_modes_rover/manual.md#acro-mode) and the configuration can be continued with [attitude tuning](attitude_tuning.md).
|
||||
|
||||
## Rate Controller Structure (Info Only)
|
||||
|
||||
This section provides additional information for developers and people with experience in control system design.
|
||||
|
||||
The rate controller uses the following structure:
|
||||
|
||||

|
||||
|
||||
::: info
|
||||
For ackermann rovers the yaw rate is only close loop controlled when driving forwards.
|
||||
When driving backwards the yaw rate setpoint is directly mapped to a steering angle using the equation above.
|
||||
This is due to the fact that rear wheel steering (driving a car with front-wheel steering backwards) is non-minimum-phase w.r.t to the yaw rate which leads to instabilities when doing closed loop control.
|
||||
:::
|
||||
|
||||
The feed forward mapping is done using the kinematic model of the rover to translate the yaw rate setpoint to a normalized steering setpoint.
|
||||
|
||||
### Kinematic Models
|
||||
|
||||
#### Ackermann
|
||||
<!-- prettier-ignore -->
|
||||
$$ \delta = \arctan(\frac{w_b \cdot \dot{\psi}}{v}) $$
|
||||
|
||||
with
|
||||
|
||||
- $w_b:$ Wheel base,
|
||||
- $\delta:$ Steering angle,
|
||||
- $\dot{\psi}:$ Yaw rate
|
||||
- $v:$ Forward speed.
|
||||
|
||||
The steering setpoint is equal to $\delta$ interpolated from [-[RA_MAX_STR_ANG](../advanced_config/parameter_reference.md#RA_MAX_STR_ANG), [RA_MAX_STR_ANG](../advanced_config/parameter_reference.md#RA_MAX_STR_ANG)] to [-1, 1].
|
||||
|
||||
For driving this means that the same right hand stick input will cause a different steering angle based on how fast you are driving.
|
||||
By limiting the maximum yaw rate, we can restrict the steering angle based on the speed, which can prevent the rover from rolling over.
|
||||
This mode will feel more like "driving a car" than [Manual mode](../flight_modes_rover/manual.md#manual-mode).
|
||||
|
||||
#### Differential/Mecanum
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
$$ v_{diff} = \frac{w_t \cdot \dot{\psi}}{2} $$
|
||||
|
||||
with
|
||||
|
||||
- $v_{diff}:$ Speed difference between the right/left wheels,
|
||||
- $w_t:$ Wheel track ([RD_WHEEL_TRACK](../advanced_config/parameter_reference.md#RD_WHEEL_TRACK)),
|
||||
- $\dot{\psi}:$ Yaw rate setpoint
|
||||
|
||||
The steering setpoint is equal to $v_{diff}$ interpolated from [-[RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED), [RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED)] to [-1, 1].
|
||||
|
||||
These mappings based on the idealized kinematic models can be adjusted with the multiplicative factor [RO_YAW_RATE_CORR](../advanced_config/parameter_reference.md#RO_YAW_RATE_CORR) to tune the feed forward part of the yaw rate controller to account for wheel misalignemnts, high friction etc.
|
||||
|
||||
## Parameter Overview
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------- | --------- |
|
||||
| <a id="RO_YAW_RATE_LIM"></a>[RO_YAW_RATE_LIM](../advanced_config/parameter_reference.md#RO_YAW_RATE_LIM) | Maximum allowed yaw rate | $m/s^2$ |
|
||||
| <a id="RO_YAW_RATE_P"></a>[RO_YAW_RATE_P](../advanced_config/parameter_reference.md#RO_YAW_RATE_P) | Proportional gain for yaw rate controller | - |
|
||||
| <a id="RO_YAW_RATE_I"></a>[RO_YAW_RATE_I](../advanced_config/parameter_reference.md#RO_YAW_RATE_I) | Integral gain for yaw rate controller | - |
|
||||
| <a id="RO_YAW_STICK_DZ"></a>[RO_YAW_STICK_DZ](../advanced_config/parameter_reference.md#RO_YAW_STICK_DZ) | Yaw stick deadzone | - |
|
||||
| <a id="RO_YAW_ACCEL_LIM"></a>[RO_YAW_ACCEL_LIM](../advanced_config/parameter_reference.md#RO_YAW_ACCEL_LIM) | (Optional) Yaw acceleration limit | $deg/s^2$ |
|
||||
| <a id="RO_YAW_DECEL_LIM"></a>[RO_YAW_DECEL_LIM](../advanced_config/parameter_reference.md#RO_YAW_DECEL_LIM) | (Optional) Yaw deceleration limit | $deg/s^2$ |
|
||||
| <a id="RO_YAW_RATE_CORR"></a>[RO_YAW_RATE_CORR](../advanced_config/parameter_reference.md#RO_YAW_RATE_CORR) | (Optional) Yaw rate correction factor | - |
|
||||
| <a id="RO_YAW_RATE_TH"></a>[RO_YAW_RATE_TH](../advanced_config/parameter_reference.md#RO_YAW_RATE_TH) | (Advanced) Yaw rate measurement threshold | $deg/s$ |
|
||||
@@ -0,0 +1,124 @@
|
||||
# Velocity Tuning
|
||||
|
||||
:::warning
|
||||
The [attitude tuning](attitude_tuning.md) must've already been completed before this step!
|
||||
:::
|
||||
|
||||
:::note
|
||||
To tune we will be using the manual [Position mode](../flight_modes_rover/manual.md#position-mode).
|
||||
This mode requires a global position estimate (GPS) and tuning of some parameters that go beyond the velocity controller.
|
||||
If you use a custom external flight mode that controls velocity but does not require a global position estimate you can ignore the [manual position mode parameters](#manual-position-mode-parameters).
|
||||
:::
|
||||
|
||||
## Speed Parameters
|
||||
|
||||
To tune the velocity controller configure the following [parameters](../advanced_config/parameters.md) in QGroundControl:
|
||||
|
||||
1. [RO_SPEED_LIM](#RO_SPEED_LIM) [m/s]: This is the maximum speed you want to allow for your rover.
|
||||
This will define the stick-to-speed mapping for [Position mode](../flight_modes_rover/manual.md#position-mode) and set an upper limit for the speed setpoint.
|
||||
1. [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) [m/s]: This parameter is used to calculate the feed-forward term of the closed loop speed control which linearly maps desired speeds to normalized motor commands.
|
||||
As mentioned in the [Manual mode](../flight_modes_rover/manual.md#manual-mode) configuration , a good starting point is the observed ground speed when the rover drives at maximum throttle in [Manual mode](../flight_modes_rover/manual.md#manual-mode).
|
||||
|
||||
<a id="RA_SPEED_TUNING"></a>
|
||||
|
||||
::: tip
|
||||
To further tune this parameter:
|
||||
|
||||
1. Set [RO_SPEED_P](#RO_SPEED_P) and [RO_SPEED_I](#RO_SPEED_I) to zero.
|
||||
This way the speed is only controlled by the feed-forward term, which makes it easier to tune.
|
||||
2. Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and then move the left stick of your controller up and/or down and hold it at a few different levels for a couple of seconds each.
|
||||
3. Disarm the rover and from the flight log plot the `adjusted_speed_body_x_setpoint` and the `measured_speed_body_x` from the [RoverVelocityStatus](../msg_docs/RoverVelocityStatus.md) message over each other.
|
||||
4. If the actual speed of the rover is higher than the speed setpoint, increase [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED).
|
||||
If it is the other way around decrease the parameter and repeat until you are satisfied with the setpoint tracking.
|
||||
|
||||
:::
|
||||
|
||||
::: info
|
||||
If your rover oscillates when driving a straight line in [Position mode](../flight_modes_rover/manual.md#position-mode), set this parameter to the observed ground speed at maximum throttle in [Manual mode](../flight_modes_rover/manual.md#manual-mode) and complete the tuning of the [manual position mode parameters](#manual-position-mode-parameters) first before continuing the tuning of the closed loop speed control.
|
||||
:::
|
||||
|
||||
2. [RO_SPEED_P](#RO_SPEED_P) [-]: Proportional gain of the closed loop speed controller.
|
||||
|
||||
::: tip
|
||||
This parameter can be tuned the same way as [RO_MAX_THR_SPEED](#RA_SPEED_TUNING).
|
||||
If you tuned [RO_MAX_THR_SPEED](#RO_MAX_THR_SPEED) well, you might only need a very small value.
|
||||
:::
|
||||
|
||||
3. [RO_SPEED_I](#RO_SPEED_I) [-]: Integral gain for the closed loop speed controller.
|
||||
|
||||
::: tip
|
||||
For the closed loop speed control an integrator gain is useful because this setpoint is often constant for a while and an integrator eliminates steady state errors that can cause the rover to never reach the setpoint.
|
||||
:::
|
||||
|
||||
4. (Advanced) [RO_SPEED_TH](#RO_SPEED_TH) [m/s]: The minimum threshold for the speed measurement not to be interpreted as zero.
|
||||
This can be used to cut off measurement noise when the rover is standing still.
|
||||
|
||||
## Manual Position Mode Parameters
|
||||
|
||||
These steps are only necessary if you are tuning/want to unlock the manual [Position mode](../flight_modes_rover/manual.md#position-mode). Othwerwise, you can continue with [position tuning](position_tuning.md) where these same parameters will also be configured.
|
||||
|
||||
1. [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN): When driving in a straight line (right stick centered) position mode leverages the same path following algorithm used in [auto modes](../flight_modes_rover/auto.md) called [pure pursuit](position_tuning.md#pure-pursuit-guidance-logic-info-only) to achieve the best possible straight line driving behaviour.
|
||||
This parameter determines how aggressive the controller will steer towards the path.
|
||||
|
||||
::: tip
|
||||
Decreasing the parameter makes it more aggressive but can lead to oscillations.
|
||||
|
||||
To tune this:
|
||||
|
||||
1. Start with a value of 1 for [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN)
|
||||
2. Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and while driving a straight line at approximately half the maximum speed observe its behaviour.
|
||||
3. If the rover does not drive in a straight line, reduce the value of the parameter, if it oscillates around the path increase the value.
|
||||
4. Repeat until you are satisfied with the behaviour.
|
||||
|
||||
:::
|
||||
|
||||
2. [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN): Minimum threshold for the lookahead distance used by the [pure pursuit algorithm](position_tuning.md#pure-pursuit-guidance-logic-info-only).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and drive at very low speeds, if the rover starts to oscillate even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then increase the value of [PP_LOOKAHD_MIN](#PP_LOOKAHD_MIN).
|
||||
:::
|
||||
|
||||
3. [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX): Maximum threshold for the lookahead distance used by [pure pursuit](position_tuning.md#pure-pursuit-guidance-logic-info-only).
|
||||
|
||||
::: tip
|
||||
Put the rover in [Position mode](../flight_modes_rover/manual.md#position-mode) and drive at very high speeds, if the rover does not drive in a straight line even though the tuning of [PP_LOOKAHD_GAIN](#PP_LOOKAHD_GAIN) was good for medium speeds, then decrease the value of [PP_LOOKAHD_MAX](#PP_LOOKAHD_MAX).
|
||||
:::
|
||||
|
||||
The rover is now ready to drive in [Position mode](../flight_modes_rover/manual.md#position-mode) and the configuration can be continued with [position tuning](position_tuning.md).
|
||||
|
||||
## Attitude Controller Structure (Info Only)
|
||||
|
||||
This section provides additional information for developers and people with experience in control system design.
|
||||
|
||||
The velocity vector is defined by the following two values:
|
||||
1. The absolute speed [$m/s$]
|
||||
2. The direction (bearing) [$rad$]
|
||||
|
||||
The speed controller uses the following structure:
|
||||
|
||||

|
||||
|
||||
The feed forward mapping is done by interpolating the speed setpoint from [-[RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED), [RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED)] to [-1, 1].
|
||||
|
||||
For ackermann and differential rovers the bearing is aligned with the vehicle yaw. Therefor the bearing is simply sent as a yaw setpoint to the [yaw controller](attitude_tuning.md#attitude-controller-structure-info-only) and the speed setpoint is always defined in body x direction.
|
||||
|
||||
For mecanum vehicles, the bearing and yaw are decoupled. The direction is controlled by splitting the velocity vector into one speed component in body x direction and one in body y direction.
|
||||
Both these setpoint are then sent to their own closed loop speed controllers.
|
||||
|
||||
## Parmeter Overview
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ------- |
|
||||
| <a id="RO_MAX_THR_SPEED"></a>[RO_MAX_THR_SPEED](../advanced_config/parameter_reference.md#RO_MAX_THR_SPEED) | Speed the rover drives at maximum throttle | $m/s$ |
|
||||
| <a id="RO_SPEED_LIM"></a>[RO_SPEED_LIM](../advanced_config/parameter_reference.md#RO_SPEED_LIM) | Maximum allowed speed | $m/s$ |
|
||||
| <a id="RO_SPEED_P"></a>[RO_SPEED_P](../advanced_config/parameter_reference.md#RO_SPEED_P) | Proportional gain for speed controller | - |
|
||||
| <a id="RO_SPEED_I"></a>[RO_SPEED_I](../advanced_config/parameter_reference.md#RO_SPEED_I) | Integral gain for speed controller | - |
|
||||
| <a id="RO_SPEED_TH"></a>[RO_SPEED_TH](../advanced_config/parameter_reference.md#RO_SPEED_TH) | (Advanced) Speed measurement threshold | $m/s$ |
|
||||
|
||||
### Pure Pursuit
|
||||
|
||||
| Parameter | Description | Unit |
|
||||
| -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---- |
|
||||
| <a id="PP_LOOKAHD_GAIN"></a>[PP_LOOKAHD_GAIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_GAIN) | Pure pursuit: Main tuning parameter | - |
|
||||
| <a id="PP_LOOKAHD_MAX"></a>[PP_LOOKAHD_MAX](../advanced_config/parameter_reference.md#PP_LOOKAHD_MAX) | Pure pursuit: Maximum value for the look ahead radius | m |
|
||||
| <a id="PP_LOOKAHD_MIN"></a>[PP_LOOKAHD_MIN](../advanced_config/parameter_reference.md#PP_LOOKAHD_MIN) | Pure pursuit: Minimum value for the look ahead radius | m |
|
||||
Reference in New Issue
Block a user