Controlling Yaw Autonomously [solved]

Discussions about autonomous flight in general, regardless of positioning method
Post Reply
relame
Beginner
Posts: 10
Joined: Thu Feb 18, 2021 6:34 pm

Controlling Yaw Autonomously [solved]

Post by relame »

I am very much new to crazyflie so I will try and share as much information as possible.

I am currently working with a Crazyflie bolt UAV with an external Qualysis MoCap system and I am using commands like takeoff(z), goto(x,y,z,yaw) and hover(time). The X, Y and Z positions are able to be controlled but I need to be able to control the UAV's yaw direction.

Currently, I am using the following scripts to accomplish the task and these scripts are similar to Whoenig's scripts on GitHub There are two clear ways to go about controlling yaw that I would like to test.
  • Using gyroscope to receive yaw state and I believe this is the standard method. I also believe this is the case when I use external camera to publish "external_position" (x,y,z)
  • Using external cameras to publish quaternian values and derive yaw from here. I believe this occurs when I publish external camera data under "external_pose" (position.x,position.y,position.z,orientation.x,orientation.y,orientation.z,orientation.w)
(I may be completely wrong about this but it seems to be the case when I look at the Crazyflie server generated by Whoenig)

Either way, when I command yaw to a new position, I do not get any results. I have tried to find a solution and it seems like the issue lies either in crtp_commander_generic.c or crpt_commander_rpyt.c. I believe I need to change mode.yaw to modeABS from modeVelocity but I do not know where.

I believe this to be the case from the following forums. If I am correct in my assumptions, my question becomes how/where do I need to change "mode.yaw"?
kristoffer
Bitcraze
Posts: 464
Joined: Tue Jun 30, 2015 7:47 am

Re: Controlling Yaw Autonomously

Post by kristoffer »

Hi!

I could not open your scripts so I might be off.

You are correct in that cf.extpos.send_extpos() pushes the position to the estimator, while cf.extpos.send_extpose() pushes the full pose.
If you are using the kalman estimator (sounds like you should) it will use any data that is pushed into it, so if you only push the position it will mainly used IMU data for orientation (but also derive it from motion). If you are pushing the full pose, the orientation from your data will be added to the mix.

There is an example script for qualisys systems that might be interesting to look at for you, https://github.com/bitcraze/crazyflie-l ... mmander.py.

This script only pushes the position by default, but there is a variable (send_full_pose) that you can set to True if you want to use the full pose instead. I had some issues with stability (especially around yaw=90 degrees if I remember correctly) with the full pose solution and settled for position only.

If you use position only, remember to start the CF facing in the positive X direction as this is the orientation the estimator assumes by default.


What ever solution you use, yaw should work out of the box in your scripts so I'm a bit puzzled by your problems. One caveat is that there is a bit of mixup in the use of degrees and radians for parameters so maybe you are using radians for a parameter that expects degrees?

If you are sending raw setpoints with https://github.com/bitcraze/crazyflie-l ... er.py#L132, yaw should be in degrees.

If you are using the high level commander directly and call https://github.com/bitcraze/crazyflie-l ... er.py#L134 for instance, the yaw should be in radians.

There is also a wrapper class for the high level commander (https://github.com/bitcraze/crazyflie-l ... mmander.py) but it currently does not support yaw.


I think option 2 above is the easiest to use. Unfortunately I could not find an example with yaw, but the qualisys example script I referred to earlier should be easy to modify to use go_to() instead of commander.start_trajectory()
relame
Beginner
Posts: 10
Joined: Thu Feb 18, 2021 6:34 pm

Re: Controlling Yaw Autonomously

Post by relame »

Thank you for the fast response!

I had my Github repository set to private and I just made it public. I believe that the Qualisys script I am using (the third link from my original post) does and adequate job at generating data from the cameras.

As for the command method, I am indeed using something like method two and it is the first link. I am using a script that was generated by a previous researcher and he claims that yaw control using the commands like "GoTo" do not have any result. I will certainty look at the script you sent me to see if I can notice any noticeable differences.

There is the potential that I tuned the Yaw PID parameters down enough where they do not have a notice response to commanded inputs but I do not think this is the case. I am thinking that the way the high level commands that are defined in "Crazyflie.py" is not correct and they could use some potential debugging.

Again, I appreciate the quick and quality response.
relame
Beginner
Posts: 10
Joined: Thu Feb 18, 2021 6:34 pm

Re: Controlling Yaw Autonomously

Post by relame »

I ended up figuring it mostly out. The GoTo command was only checking for if x, y, and z are within a tolerance and not Yaw. Right now, I can control yaw but if its anything more than a 15 degree change, it spirals out of control. I believe it to be an issue with the PID and I need to tune some of the parameters down.

Furthermore, I believe I found a post about issue of controlling yaw at 90 degrees. viewtopic.php?f=18&t=4507 but I am not sure where the "LocExtQuatStdDev" parameter they are referring to is.
kristoffer
Bitcraze
Posts: 464
Joined: Tue Jun 30, 2015 7:47 am

Re: Controlling Yaw Autonomously

Post by kristoffer »

Great!

I have also seen this instability when pushing the full pose from a mocap system into the Crazyflie. It seemed to be sensitive at yaw = +-90 degrees if the std was too low. In the qualisys example script I used a different std (at line 254) if you want to play around with it. I think I picked the number based on trial and error so it can probably be improved :-)
relame
Beginner
Posts: 10
Joined: Thu Feb 18, 2021 6:34 pm

Re: Controlling Yaw Autonomously

Post by relame »

I was able to get stable yawing today with full pose messages. The issue was 100% the "LocExtQuatStdDev" value and I ended up setting it to 0.04. Its very surprising how much of an effect that value had on angles around +/- 90 degrees and how much better the UAV flies with the updated parameter.

Thank you for your help

(I am not sure how to set the topic as "solved").
kristoffer
Bitcraze
Posts: 464
Joined: Tue Jun 30, 2015 7:47 am

Re: Controlling Yaw Autonomously [solved]

Post by kristoffer »

Great that it worked out!

You can edit the first message to change the title to solved (I did it for you)
Post Reply