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

Copter: Obey loiter_ccw flag for loiter turns #22834

Merged
merged 3 commits into from Feb 15, 2023

Conversation

rishabsingh3003
Copy link
Contributor

It was currently impossible to set the direction of travel in loiter turns even though we have a flag in AP_Mission just to set that. Setting a radius negative would allow you to travel in ccw direction. Also, this aligns with the mavlink message description: https://mavlink.io/en/messages/common.html#MAV_CMD_NAV_LOITER_TURNS

log of SITL testing: https://drive.google.com/drive/folders/1nYc4-lnAd6QgAIBKLO5yVyDQlQWoZ7hC?usp=share_link

switch (_direction)
{
case TurnDirection::CIRCLE_CW:
return fabsf(_rate);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not just encode the direction in _rate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was thinking about it; it would make it much simpler. But that would mean if we go to circle mode after auto, we might have an inverted turn. We could save the original "_rate" and return back to default on exiting auto though..

@rmackay9
Copy link
Contributor

rmackay9 commented Feb 5, 2023

Thanks this looks pretty good. Similar to what Andy is saying, I think we should perhaps change the interface so that the direction is included in the rate (e.g. rates can be -ve or +ve) or use a separate accessor and ensure the rate is always +ve. I think this would be best because otherwise different callers (or different portions of the code) could arrive at different answers as to whether they think the vehicle is moving cw or ccw.

@rishabsingh3003
Copy link
Contributor Author

I have gone back to just using rate like Andy suggested. Its much simpler this way

/// caller should set the position controller's x,y and z speeds and accelerations before calling this
void init(const Vector3p& center, bool terrain_alt);
void init(const Vector3p& center, bool terrain_alt, float rate_deg_per_sec);
Copy link
Contributor

Choose a reason for hiding this comment

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

I probably would have made the new init argument the direction rather than the rate but I guess it's ok.

@tridge tridge removed the DevCallEU label Feb 15, 2023
@tridge tridge merged commit 34702ed into ArduPilot:master Feb 15, 2023
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.

None yet

4 participants