-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Orbit: Adding orbit yaw behaviours #13426
Conversation
Also relevant to combine with obstacle avoidance when one has a forward facing sensor and wants to safely execute an orbit around a certain position. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for looking into it.
I hope my review comments make sense to you. If you're tired of them I can also put a commit somewhere with my suggestion and you check it.
acd193d
to
663dc06
Compare
@MaEtUgR Following your advice, please have a look at the most recent commit. I restructured the code a little and created an enum. Btw, does it make sense to do a setpoint for yawspeed and yaw at the same time? |
22643b7
to
82a4d96
Compare
@dayjaby can you rebase on master? |
82a4d96
to
6b35fca
Compare
@TSC21 Done. Thanks for the command ;) |
Neat! Now it appears without any conflicts :) |
@MaEtUgR all good here for you? |
@@ -104,6 +105,10 @@ class FlightTaskOrbit : public FlightTaskManualAltitudeSmooth | |||
const float _velocity_max = 10.f; | |||
const float _acceleration_max = 2.f; | |||
|
|||
int _yaw_behaviour = | |||
orbit_status_s::ORBIT_YAW_BEHAVIOUR_HOLD_FRONT_TO_CIRCLE_CENTER; /**< yaw behaviour during the orbit flight according to MAVLink's ORBIT_YAW_BEHAVIOUR enum */ | |||
float _initial_heading = 0.f; /**< the heading of the drone when the orbit command was issued */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dayjaby this is actually the heading of the vehicle when the vehicle command DO_ORBIT gets processed, or when we can say when the MAV_CMD_DO_ORBIT
is received and processed in the flight controller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @dayjaby looks a lot better with the enumerated behaviors 👍 Sorry for the remaining complaints but I'd like to keep this clean and since I have to maintain it also according to how it was designed. I really appreciate your implementation of the yaw modes and could help you directly with code suggestions. Just let me know.
@@ -224,5 +231,37 @@ void FlightTaskOrbit::generate_circle_setpoints(Vector2f center_to_position) | |||
_position_setpoint(0) = _position_setpoint(1) = NAN; | |||
|
|||
// yawspeed feed-forward because we know the necessary angular rate | |||
_yawspeed_setpoint = _v / _r; | |||
_yawspeed_setpoint = NAN; //_v / _r; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't leave commented out code
case orbit_status_s::ORBIT_YAW_BEHAVIOUR_HOLD_FRONT_TANGENT_TO_CIRCLE: | ||
if (_r > 0) { | ||
_yaw_setpoint = atan2f(center_to_position(1), center_to_position(0)) + M_PI_F / 2.f; | ||
|
||
} else { | ||
_yaw_setpoint = atan2f(center_to_position(1), center_to_position(0)) - M_PI_F / 2.f; | ||
} | ||
|
||
break; | ||
|
||
case orbit_status_s::ORBIT_YAW_BEHAVIOUR_RC_CONTROLLED: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the front tangential and front to center yaw behavior you want a yawspeed feed forward which was there before and is now commented out otherwise the tracking performance in real world scenarios significantly degrades.
|
||
// make vehicle front always point towards the center | ||
_yaw_setpoint = atan2f(center_to_position(1), center_to_position(0)) + M_PI_F; | ||
if (start_to_circle.norm() < 0.5f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is overriding the logic of the motion primitive StraightLine _circle_approach_line
. I can only guess that according to your taste the approach takes too much time to slow down at the end. But then it's the fault of the StraightLine
implementation which we want to fill with the jerk optimized trajectory generation anyways very soon and we should not interfere with its operation locally here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added that not because the slow down took too much time, but because switching from one orbit command to another orbit command made the drone brake down (same orbit center, same radius, but different yaw behaviour). But thinking about it now, this braking down seems reasonable.
_yawspeed_setpoint = _v / _r; | ||
_yawspeed_setpoint = NAN; //_v / _r; | ||
|
||
switch (_yaw_behaviour) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was asking to put this logic in its own function. Now it's not in the main update anymore but just uses another already existing one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is generate_circle_setpoints not the proper place? Or do you prefer an additional generate_circle_yaw_setpoints function?
7152c5f
to
e454e34
Compare
Rebased and addressed your comments @MaEtUgR . Thanks for your help with this! |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
For the RC controlled yaw behaviour, we do a yaw setpoint according to the stick expo. The uncontrolled yaw behaviour behaves undefined. Switching between yaw behaviours makes the drone stand still for a moment, which probably can be improved.
e454e34
to
f92f168
Compare
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
@dayjaby Hey, thanks a lot for your contribution and patience! I'm so sorry for the slow follow up! I finally went through it in all detail and have some suggestions that I pushed on top here: https://github.com/PX4/Firmware/compare/adding_orbit_yaw_behaviours Explanations:
|
@MaEtUgR I agree with all your changes! Thanks for taking the time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. Let's get it in 👍
Describe problem solved by this pull request
Implementing the yaw behaviours for orbit flight mode according the current mavlink specification (https://mavlink.io/en/messages/common.html#MAV_CMD_DO_ORBIT) and an additional yaw behaviour as suggested in mavlink/mavlink#1266. This new addition is important if you have a fpv camera installed in the front of the drone and expect the drone to always look forward.
Describe your solution
Test data / coverage
Tested via QGC (without parameter 3 being set) and via mavros (https://logs.px4.io/plot_app?log=7725a2a3-5af4-4710-a6a6-dbba12f5dd20):
rosservice call /mavros/cmd/command "{broadcast: false, command: 34, confirmation: 0, param1: 50.0, param2: 5.0, param3: 3.0, param4: 0.0, param5: 47.3977449, param6: 8.5465953, param7: 2.5}"
@TSC21 Thank you for your help with the implementation!