The position data of crazyflie

All discussions related to the Loco Positioning system
liuyuzhen
Beginner
Posts: 14
Joined: Sun Sep 24, 2017 4:07 am

The position data of crazyflie

Post by liuyuzhen » Sun Mar 11, 2018 4:12 am

Hello,

I have used the flow deck and an external camera to achieve some tracking tasks. I found that crazyflie could fly smoothly with the flow deck.However,I can't exactly know the 3D position of the crazyflie and the target so that the tracking effect can't be accurately evaluated.So recently I bought your local position system to get the information of the 3D position of the crazyflie. But location information is acquired through the client not the ‘crazyflie-lib-python’(I need send control command through 'crazyflie-lib-python').So what should I do ?

Another question is that Can I use flow deck and local position system at the same time ? I want to use the control command from 'crazyflie-lib-python\cflib\positioning\motion_commander' with the flow deck, and local position system is tightly as an external benchmark (like vicon), rather than the control of the crazyflie.
Thank you!

Jackie



arnaud
Bitcraze
Posts: 2202
Joined: Tue Feb 06, 2007 12:36 pm

Re: The position data of crazyflie

Post by arnaud » Mon Mar 12, 2018 1:12 pm

You can setup a log block using the ‘crazyflie-lib-python’ to get the 3D position estimate from the Crazyflie. You can look at the example folder of the lib for example on how to setup a log block and get the log variables values at regular interval: https://github.com/bitcraze/crazyflie-l ... asiclog.py and https://github.com/bitcraze/crazyflie-l ... logSync.py.

You can look at the logTOC tab in the client to list the available variables. The variables stateEstimate.x, stateEstimate.y and stateEstimate.z would allow you to recover the position estimate.

For the second question: Yes you can use both flow and LPS at the same time. It tend to work very well as long as no big noise is introduced in the flow. I have seen it becoming unstable if informations from the LPS contradicts the flow measurements. When you have both flow and LPS installed, the behaviour of the Crazyflie will be to used all the data available to calculate the state estimate, you will get precise velocity estimate thanks to the flow and absolute position estimate with the LPS.

liuyuzhen
Beginner
Posts: 14
Joined: Sun Sep 24, 2017 4:07 am

Re: The position data of crazyflie

Post by liuyuzhen » Tue Mar 13, 2018 5:00 am

Thank you very much for your reply!
I did experiments one, two, three:1)flow deck: crazyflie can hover stably only with flow deck. 2)flow deck + LPS: crazyflie also can hover stably. 3) only LPS: the crazyflie can't hover only with local position system . It will float far away and be out of control. I want to know why crazyflie can't achieve stable hovering only with local position system? Is the accuracy of positioning too low(or inferior to the flow deck)?
Another question is about ‘stateEstimate.x, stateEstimate.y and stateEstimate.z ’,I have modified the ‘basiclogSync.py' to obtain the value of 'stateEstimate.x, stateEstimate.y and stateEstimate.z' in three cases:1) (crazyflie) with flow deck : Is ‘stateestmate.x(y,z)' a relative location information? 2)with LPS: Is ‘stateestmate.x(y,z)' a absolute location information? 3)flow deck + LPS:Is ‘stateestmate.x(y,z)' also a absolute location information?
You mentioned ‘I have seen it becoming unstable if informations from the LPS contradicts the flow measurements’ in your reply.I have also encountered this situation.When I ran the ‘autonomousSequence.py’, the crazyflie flipped directly.
Thanks again for your help!

Jackie

arnaud
Bitcraze
Posts: 2202
Joined: Tue Feb 06, 2007 12:36 pm

Re: The position data of crazyflie

Post by arnaud » Wed Mar 14, 2018 10:10 am

Hi,

For the experiment: The LPS alone should be a bit more noisy than with the flow: the reason is that the measurement from the LPS are less accurate and more noisy than the optical measurement you can obtain from the flow sensor. Though, there should not be any drift, the only thing I would expect is some inaccuracy in the absolute position and the crazyflie moving around the setpoint a bit more (the absolute position should be the same as with the flow in x/y, it can be different in Z since the flow deck has an absolute Z position sensor).

How is your LPS setup? How many anchor, in which mode and how are the anchor placed? Can you see a stable position estimate in the LPS tab?

For the logs: Yes your interpretation is correct. stateestimate.x/y/z is the position estimate calculated by the kalman filter. If you only have the flow deck attached, the position estimate will be generated with velocity measurements only and so it is an integration of the velocity.

liuyuzhen
Beginner
Posts: 14
Joined: Sun Sep 24, 2017 4:07 am

Re: The position data of crazyflie

Post by liuyuzhen » Thu Mar 15, 2018 4:31 am

Thanks again for your reply.I have 6 anchors. I use the client in windows.There is no mode option(Auto/TWR/WDoA)(attached picture '2.jpg'). I can see a stable position estimate in the LPS tab in client(It doesn't look like much error).But I can't stabilize crazyflie with the gamepad in position hold (according to the 'Getting started with Position hold'), the crazyflie will float away just like there is no LPS. I also ran the program using the commands from 'crazyflie-lib-python\cflib\positioning\motion_commander' or 'crazyflie-lib-python\cflib\crazyflie\commander'.The crazyflie also can't hover and floats away.I don't know what caused it.The coordinates of these six anchors are: 0(0,0,0.09),1(0,2.6,0.09),2(0,1.3,0.09),3(1.91,1.3,0.09),4(0,1.3,1.92),5(1.91,2.6,1.92)(Unit/m).The attached pictures('869848721.jpg') show the place situation of LPS.

Looking forward to your reply.Thank you!
Attachments
2.png
869848721.jpg

arnaud
Bitcraze
Posts: 2202
Joined: Tue Feb 06, 2007 12:36 pm

Re: The position data of crazyflie

Post by arnaud » Thu Mar 15, 2018 4:22 pm

Thanks for the details. Your setup looks correct for TWR positioning.

Your client does not seems to be at the latest version, this is why you do not see TWR/TDoA. This is not a problem if your want to fly only one CF in TWR.

I think I understand where the drift is coming from: When only using the LPS, the position estimate is good and does not drift, but for some reason the velocity estimate is a bit drifting. This means that if you run position hold mode or velocity control you will see some drift. If you send position setpoint instead there should be no drift.

Can you test the ‘autonomousSequence.py’ script with LPS only? If my intuition is right there should not be any drift using this script.

liuyuzhen
Beginner
Posts: 14
Joined: Sun Sep 24, 2017 4:07 am

Re: The position data of crazyflie

Post by liuyuzhen » Fri Mar 16, 2018 6:13 am

Thank you for your reply.I tested the ‘autonomousSequence.py’ script with LPS only. Though, I don't kown whether there is drift, it looks like the crazyflie didn't fly according to the setpoint I gave.I have read 'autonomousSequence.py'.I found that the function 'cf.commander.send_setpoint(position[1], position[0], position[3],int(position[2] * 1000))' was called in 'run_sequence'.I also read the function 'send_setpoint'. I found that the parameter used by this function is 'roll,pitch,trust,yaw'(def send_setpoint(self, roll, pitch, yaw, thrust):).So the sequence pointsthat we set up at the beginning in ‘autonomousSequence.py’ are ‘roll, pitch, trust, yaw’ instead of ‘x, y, z, yaw’.It seems that the LPS system position control is meaningless.I want to know what's wrong with my understanding?

Thank you!!
Attachments
3.png
2.png
2.png (8.7 KiB) Viewed 3006 times
1.png

arnaud
Bitcraze
Posts: 2202
Joined: Tue Feb 06, 2007 12:36 pm

Re: The position data of crazyflie

Post by arnaud » Fri Mar 16, 2018 7:11 am

This script is using a little bit of legacy code: originally Crazyflie 2.0 did not support any kind of position control and back then we used the roll/pitch/yaw/thrust setpoint packet for everything the meaning of the packet fields. For example we had a parameter to start interpreting thrust as height-change to implement height-hold. This script is setting to 1 the parameter "flightMode.posSet" which makes the Crazyflie interpret roll/pitch/yaw/thrust as y/x/yaw/Z(in mm).

This is a bit of a hack. We now have proper setpoint packets for the different modes. A position packet was added lately, I am waiting for the next firmware update to update the examples (I would like the examples to work with the stable firmware).

What was the behavior of the Crazyflie?

liuyuzhen
Beginner
Posts: 14
Joined: Sun Sep 24, 2017 4:07 am

Re: The position data of crazyflie

Post by liuyuzhen » Fri Mar 16, 2018 10:29 am

Thank for your reply.The crazyflie flied randomly and often run into walls (when ran the 'autonomousSequence.py').One of the rotors was damaged. So I'm set only one point (0,0.5,0.5,0).I hope to find the law of crazyflie flight in flightMode.posSet mode,but I didn't. I think that when I set the point (0,0.5,0.5,0), the crazyflie will fly into the space (0,0.5,0.5) (x/y/z,absolute position), but it didn't, but it was flying in a direction that was not expected and then fell.When I set the point to (0,0,1,0), the crazyflie will fly sideways and fall (should it not fly vertically?).

Another question is that every command will be executed 50 times to maintain the 5s?(

Code: Select all

for i in range(5):
            cf.commander.send_setpoint(position[1], position[0],
                                       position[3],
                                       int(position[2] * 1000))
            time.sleep(0.1)
). I don't know the exact meaning of this command, and why does it have to be executed 50 times? For example, executing once command ' cf.commander.send_setpoint(position[1], position[0],position[3],int(position[2] * 1000)', the crazyflie should move ‘position[0]’(Unit /m) along the X-axis, ‘position[1]’ along the Y-axis and 'position[2]' along the z-axis, right?

Are the sequence of points we set at the beginning the absolute position in space? Under normal circumstances, the crazyflie will arrive at these points in turn, right?

Thank you!!

arnaud
Bitcraze
Posts: 2202
Joined: Tue Feb 06, 2007 12:36 pm

Re: The position data of crazyflie

Post by arnaud » Mon Mar 19, 2018 1:44 pm

The setpoint needs to be sent often: the Crazyflie has a watchdog that will makes roll/pitch=0 after 0.5s and cut the motors after 1s if no setpoint is received. Sending setoint at 10Hz like in the loop you copy-pasted.

The positions in this script are absolute positions and the expected behavior is that the Crazyflie should hover at the set position.

Are you sure you are starting the Crazyflie facing X like in this picture: https://www.bitcraze.io/getting-started ... tion-hold/. More often than not, when the position estimate looks good but the Crazyflie just flies away, the cause is a bad initial orientation.

Post Reply