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

Added moveByVelocityBodyFrame #3169

Merged
merged 2 commits into from
Dec 2, 2020

Conversation

ahmed-elsaharti
Copy link
Contributor

Added a moveByVelocityBodyFrameAsync API that allows movement by velocity in the direction of the vehicle's X-Y frame based on the 2-D vector decomposition shown in #3138 where:

VX_world = VX_vehicle * cos(yaw) - VY_vehicle * sin(yaw)
VY_world = VX_vehicle * sin(yaw) + VY_vehicle * cos(yaw)

Usage:
moveByVelocityBodyFrameAsync(vx, vy, vz, duration, drivetrain (optional), yaw_mode (optional), vehicle_name (optional))

Demo video:
https://drive.google.com/file/d/1G5ihjNSVyxDBw8GXOCeqlGpWFwCxeelZ/view?usp=sharing

Any testing and/or review of the method would be greatly appreciated.
Thanks again to @jonyMarino for suggesting this.

added an API that works like movebyvelocity but in the vehicle's frame.
@ghost
Copy link

ghost commented Nov 25, 2020

CLA assistant check
All CLA requirements met.

@jonyMarino
Copy link
Collaborator

Great Ahmed! Thank you! Why are you not using the pitch and roll in the transformation? This is just for 2D?

@ahmed-elsaharti
Copy link
Contributor Author

ahmed-elsaharti commented Dec 1, 2020

Hi @jonyMarino, You're right, This is to control the motion direction in the 2D plane of the vehicle similar to moveByVelocity where it's always in the horizontal direction.
Since this is to mimic the action of controlling a UAV using RC where it's just a matter of moving in the plane of the UAV relative to where its heading angle is regardless of the pitch/roll angles. Which is why I intentionally left out pitch and roll (ie: the absolute direction the UAV is pointing) to not make the API confusing and or cause misbehavior if move commands were sent while the drone was recovering from a previous command which would make this very difficult to use for users.

Example: if the drone was moving previously and the command is complete, it will still have a slight residual pitch angle while trying to stop (due to inertia), if that gets incorporated in the API, the resulting motion in the drone's X direction would not be truly horizontal if we consider pitch and roll:
image
This means that the user will have to wait for the vehicle to be 100% horizontal before issuing the moveByVelocityBodyFrame command, making this super difficult to control

The way it is now (without pitch and yaw):
image
Which is exactly like the expected behavior with RC.

Edit: another example would be the drone resisting wind (so the drone would be pitched forward while standing still) which if pitch and roll are considered would make this API impossible to use to make the drone move forward.

@ahmed-elsaharti
Copy link
Contributor Author

Here's a screenshot from the wind example:
image
here the drone is hovering but is forced to be pitched forward due to wind. In this case, it would be impossible to make the drone move horizontally forward if the pitch is included in the equation.

@jonyMarino
Copy link
Collaborator

Thanks, Ahmed, for your excellent explanations! I will learn a lot from you! But don't get tired of generating so many graphics.

@jonyMarino jonyMarino linked an issue Dec 1, 2020 that may be closed by this pull request
@ahmed-elsaharti
Copy link
Contributor Author

@jonyMarino Thank you for your kind words! I'm the one who's learning from you.
And do not worry, explanation through images is the essence of my existence 😂

Copy link
Contributor

@zimmy87 zimmy87 left a comment

Choose a reason for hiding this comment

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

PR looks good to me other than my 2 comments.

AirLib/src/vehicles/multirotor/api/MultirotorApiBase.cpp Outdated Show resolved Hide resolved
PythonClient/airsim/client.py Outdated Show resolved Hide resolved
@zimmy87 zimmy87 merged commit b8a06ac into microsoft:master Dec 2, 2020
@ahmed-elsaharti ahmed-elsaharti deleted the Local-move-API branch December 3, 2020 06:05
@ahmed-elsaharti ahmed-elsaharti restored the Local-move-API branch December 3, 2020 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No horizontal movement API in drone's x, y, z axes
3 participants