Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multicopter auto - Yaw at waypoint before move #12348

Merged
merged 2 commits into from
Jul 11, 2019
Merged

Conversation

bresch
Copy link
Member

@bresch bresch commented Jun 27, 2019

Describe problem solved by the proposed pull request
In some cases, the user wants the drone to yaw first and then move instead of doing a simultaneous yaw and linear motion. A few examples are:

  • A drone with a front facing anti-collision sensor (camera, rangefinder, ...)
  • A standard vtol plane (low yaw speed and lateral motions are to avoid)
  • A highspeed multirotor with specific aerodynamic properties

Test data / coverage
SITL tests with MPC_POS_MODE 0 and 1.
On the plot below, you can see that the drone starts to move only when the yaw setpoint reaches the desired heading.
2019-06-27_13-42-20_01_plot

Usage
Set MPC_YAW_MODE = 4

Note that the proposed solution only cares about setpoints and doesn't check for the actual yaw of the vehicle. If the yaw tracking of your vehicle is bad, improve it or reduce MPC_YAWR_AUTO_MAX

fixes #11053

@mrivi Can you try that with avoidance please?

@mrivi
Copy link
Contributor

mrivi commented Jun 27, 2019

@bresch
This PR
pr_yaw

Master

master_yaw

@bresch
Copy link
Member Author

bresch commented Jun 27, 2019

@PX4/testflights Can you try this PR with the parameter MPC_YAW_MODE = 0,1,2,3 and 4 please?

0 towards waypoint
1 towards home
2 away from home
3 along trajectory
4 towards waypoint (yaw first)

Copy link
Contributor

@jkflying jkflying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some questions.

// Wait for the yaw setpoint to be aligned
if (!_position_locked) {
_velocity_setpoint.setAll(0.f);
_position_setpoint = _position;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this happens at considerable speed we might have some strange behavior with overshoot and returning back to the point where the trajectory change happened. Maybe just setting the velocity setpoint to 0 would be enough?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no smoothing in that flight task, setting velocity to 0 would lead to some drift.

@xdwgood
Copy link
Contributor

xdwgood commented Jun 28, 2019

Will this parameter be automatically selected when automatic avoidance is turned on?
Is it necessary for the customer to manually select and then perform an automatic avoidance flight? 😃

@Stifael
Copy link
Contributor

Stifael commented Jun 28, 2019

I have a couple of questions:

In some cases, the user wants the drone to yaw first and then move instead of doing simultaneous yaw and linear motion

Unfortunately, the way the navigator is written, you basically always have to yaw first before proceeding the next waypoint IF the vehicle heading is set to point towards the next waypoint. Otherwise, the heading check within mission_block (https://github.com/PX4/Firmware/blob/master/src/modules/navigator/mission_block.cpp#L368) is not true and will introduce a sudden brake. I am actually surprised that this has not yet happened with the new smoothing algorithm (I haven't had time yet to test the smoothing yet).

@bresch
Copy link
Member Author

bresch commented Jun 28, 2019

@xdwgood I don't think we should couple those because voidance doesn't necessarily mean that the vehicle has a single front facing sensor.

@Stifael It's only performing that check in navigator if the yaw is defined in a mission item. In out case, the yaw setpoint is generated in the FlightTaskAuto and the Navigator check is not done.

Btw, I added the logic to force yaw before linear acceleration in the standard line tracking algorithm to be consistent but I am not sure is this is really required since it is already limiting the lateral acceleration when the yaw isn't aligned.

@dannyfpv
Copy link

dannyfpv commented Jun 28, 2019

Tested on Pixhawk4 v5 f-450
Modes Tested:

Position Mode: no issue
Altitude Mode: no issue
Stabilized Mode: no issue
mission mode : no issues

PR log: towards waypoint:
https://review.px4.io/plot_app?log=94089c0d-7833-4f81-98b4-0b32f37260d4

PR log: towards home:
https://review.px4.io/plot_app?log=c04830b5-16ba-4b0a-8c67-d260ec7fbe7c

PR log: away from home:
https://review.px4.io/plot_app?log=d85f24b3-992c-4b10-8788-7339ce28f84f

PR log: along trajectory:
https://review.px4.io/plot_app?log=b9a7ab4a-7a69-4698-a580-06e425fbec21

@jorge789
Copy link

jorge789 commented Jun 28, 2019

Tested on Pixhawk 2 Cube V3:

Modes Tested

Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.
Mission Plan Mode (Automated): Good.
RTL (Automated): Good.
Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode proceed to switch to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint activate RTL and see landing behaviour.

Notes:

No issues noted, good flight in general.

Log: The MPC_YAW_MODE 0 towards waypoint parameter has changed.
**Note:**The vehicle flippel when landing by the strong air.
https://review.px4.io/plot_app?log=2f682235-2328-4974-a798-6f4f66cae5e3

Log: The MPC_YAW_MODE 1 towards home parameter has changed.
https://review.px4.io/plot_app?log=b6257d4d-523c-4c5d-baed-4ac7b769085b

Log: The MPC_YAW_MODE 2 away from home parameter has changed.
https://review.px4.io/plot_app?log=0f19cc06-e33a-4e6b-8abb-31334d05257a

Log: The MPC_YAW_MODE 3 along trajectory parameter has changed.
https://review.px4.io/plot_app?log=6acc9c06-4137-4d91-bfac-f8db9de87b02

@jorge789
Copy link

jorge789 commented Jul 1, 2019

Tested on PixRacer V4:

Flight Card 2

Modes Tested
Mission Plan Mode (Automated): Good.
RTL (Return To Land): Good.

Procedure
Arm and Take off in mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint see landing behavior.

Note:
At the landing the vehicle began to oscillate and descend at the same time, but the descent was not continuous, had brief breaks.Wind 6.0 meters per second

Log: The MPC_YAW_MODE 0 towards waypoint parameter has changed.
https://review.px4.io/plot_app?log=50ae8918-64d8-4777-ae15-42a4fca30c65

Log: The MPC_YAW_MODE 1 towards home parameter has changed.
https://review.px4.io/plot_app?log=42f20474-bc33-4d8c-9127-3b77d142306e

Log: The MPC_YAW_MODE 2 away from home parameter has changed.
https://review.px4.io/plot_app?log=f7f8bcfa-bec5-44ca-b65a-b52c58445f36

Log: The MPC_YAW_MODE 3 along trajectory parameter has changed.
https://review.px4.io/plot_app?log=0fae0055-1baa-41c2-8843-f47412974d37

@Junkim3DR
Copy link

Junkim3DR commented Jul 1, 2019

Tested on Pixhawk Pro v4:

Modes Tested

  • Position Mode: Good.
  • Altitude Mode: Good.
  • Stabilized Mode: Good.
  • Mission Plan Mode (Automated): Good.
  • RTL (Automated): Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode proceed to switch to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoint activate RTL and see landing behaviour.

Notes:
No issues noted, good flight in general.

Logs:

@jkflying
Copy link
Contributor

jkflying commented Jul 5, 2019

Test flew with avoidance with MPC_YAW_MODE=4. The mission at the end is with the avoidance enabled:
Flight log: https://logs.px4.io/plot_app?log=09d60813-d0b3-4f3b-83f0-0459eb5c6bb6

This was flown immediately before with MPC_YAW_MODE=0 and MPC_AUTO_MODE=1, same mission:
https://logs.px4.io/plot_app?log=28337c55-137d-4003-a477-d92dd7e4acc5

It seemed to have strange behavior when turning. It would go back to the location where it was when the new setpoint was received (while yawing), instead of coming to a standstill.
This gave it a wobbly appearance, and it had lots of weird 'overshoot'-like behavior any time there was a yaw as can be seen in the picture.

MPC_YAW_MODE=4
bokeh_plot(3)

MPC_YAW_MODE=0 and MPC_AUTO_MODE=1
bokeh_plot(2)

@bresch
Copy link
Member Author

bresch commented Jul 9, 2019

@jkflying As you can see in the first 2D plot you shared and the one here below, the vehicle overshoots the setpoint, it's not the setpoint that overshoots
bokeh_plot(20)
For me, the problem is that the velocity/position loops are poorly tuned. The reason why you didn't see it with the other mission mode is that is resets the setpoint to the current position when the vehicle reaches the waypoint. This is not something I would since such a reset produce infinite jerk, acceleration and velocity.

@bresch bresch force-pushed the dev-auto-yaw-before-move branch from f52fea0 to 20a7e88 Compare July 10, 2019 16:47
@bresch
Copy link
Member Author

bresch commented Jul 10, 2019

@jkflying I rebased on top of master, can you review again please such that we can merge?
Btw, the diff in FlightTaskAutoLineSmoothVel.cpp looks large, but in fact, I just added :

	if (_param_mpc_yaw_mode.get() == 4 && !_yaw_sp_aligned) {
		// Wait for the yaw setpoint to be aligned
		_velocity_setpoint.setAll(0.f);
        } else {

the rest is just indentation

jkflying
jkflying previously approved these changes Jul 11, 2019
Copy link
Contributor

@jkflying jkflying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bresch
Copy link
Member Author

bresch commented Jul 11, 2019

12 bytes overflow on v2 xD

…mode ensures that

the vehicle yaws towards the next waypoint before accelerating. This is
required for drones with front vision and aerodynamic multicopters such
as standard vtol planes or highspeed multirotors.
@bresch bresch force-pushed the dev-auto-yaw-before-move branch from a94b10e to 019e613 Compare July 11, 2019 11:31
@bresch bresch force-pushed the dev-auto-yaw-before-move branch from 019e613 to 56d7c1b Compare July 11, 2019 14:15
@bresch bresch merged commit e5128ac into master Jul 11, 2019
@bresch bresch deleted the dev-auto-yaw-before-move branch July 11, 2019 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto mode - yaw before accelerating
8 participants