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

rotateToYaw(yaw) returns at yaw but drone rotates more before stopping #856

Closed
wagnboss opened this issue Mar 1, 2018 · 5 comments
Closed

Comments

@wagnboss
Copy link

wagnboss commented Mar 1, 2018

I am using the Python API.
MultirotorClient class method rotateToYaw(yaw, max_wait_seconds, margin) always over shoots the target yaw. If large enough max_wait_seconds argument is supplied, method return when yaw is within margin of target yaw, but drone continues to rotate for a while. For example, see following pyton code:
from AirSimClient import *
import time
import math

factor = 180./math.pi

def print_info():
pitch, roll, yaw = client.getPitchRollYaw()
print("pitch %5.1f, roll %5.1f, yaw %5.1f" % (pitchfactor, rollfactor, yaw*factor))
print()

client = MultirotorClient()
client.confirmConnection()
client.enableApiControl(True)
client.armDisarm(True)

delay = 5
max_wait_seconds = delay

client.takeoff()
time.sleep(delay)
print_info()

print("rotateToYaw (90)")
client.rotateToYaw(90., max_wait_seconds, 1)
print_info() # it reached 90
time.sleep(delay)
print_info() # it continued rotating


which produces the following output:
Waiting for connection:
after takoff
pitch 0.0, roll 0.0, yaw 0.0

rotateToYaw (90)
pitch 0.0, roll 0.0, yaw 90.5

pitch 0.0, roll 0.0, yaw 114.4


Is this is normal/expected/desired behavior?
If so, how do I get the drone to STOP rotating when it reaches target yaw?
I've tried adding the following line immediately after the call to rotateToYaw, but it does not work.

client.rotateByYawRate(0.,1) #try to stop rotation

@sytelus
Copy link
Contributor

sytelus commented Mar 2, 2018

You might want to play around to turn PID controller. Overshoots might happen because p is too high for example. There is plenty of literature on web on PID tuning...

PID parameters:
Play with rate and level PID parameters: https://github.com/Microsoft/AirSim/blob/master/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/Params.hpp#L51

Code: https://github.com/Microsoft/AirSim/blob/master/AirLib/include/vehicles/multirotor/firmwares/simple_flight/firmware/AngleLevelController.hpp

@mwanggh
Copy link

mwanggh commented Oct 31, 2019

I found this command to work when the drone is hovering. If you control the head direction in move, you may use the drivetrain parameter.

client.hoverAsync().join()
client.rotateToYawAsync().join

@Yuchen-sky
Copy link

I found this command to work when the drone is hovering. If you control the head direction in move, you may use the drivetrain parameter.

client.hoverAsync().join()
client.rotateToYawAsync().join

i do as you said, but it is not work two airsim 1.2

@cloudlakecho
Copy link

@wangnboss, Would you share your AirSim version?

I don't have those Classes in my Python API. When I try to use rotateToYaw function, I receive this error:

client.rotateToYaw(math.radians(orientation[2]), max_wait_seconds, margin[2])
AttributeError: 'MultirotorClient' object has no attribute 'rotateToYaw'

It looks like that I don't have getPitchRollYaw() neither....

@jonyMarino
Copy link
Collaborator

Solved by PR2516

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants