Controlling Crazyflie with LPS

All discussions related to the Loco Positioning system
youngbin1130
Member
Posts: 46
Joined: Thu Dec 12, 2019 4:28 am

Controlling Crazyflie with LPS

Post by youngbin1130 »

Hi,

I was looking through the Python library for Crazyflie but I'm confused about where I should start for my project because, from what I understand, there are alot of similar functions.

I would just like to see where the following functions are:
1. The turning velocity
2. Moving from Point A to Point B (In world space)
3. Moving along the relative X, Y, Z

I would also like to ask if I start off with a single Crazyflie, whether the functions can be accommodated for a Swarm in the future.

Cheers,
Youngbin
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Controlling Crazyflie with LPS

Post by kimberly »

Hi.

So the examples/position_commander_demo.py in that same repo is already doing number 2 and 3 of your request. Motion_commander_demo.py does 1 and 3 but do be carefule of mixing the types of 'commanders' (see this issue).

You can look in the examples/swarm/ folder for some examples for flying multiple Crazyflies at the same time.
youngbin1130
Member
Posts: 46
Joined: Thu Dec 12, 2019 4:28 am

Re: Controlling Crazyflie with LPS

Post by youngbin1130 »

Hi,

Thanks for your reply!

I had forgotten to mention that if all my questions take into account the boundary set by the LPS nodes.

Also, I think you had forgotten to link the issue which you wanted to mention when mixing two kinds of commanders.
kristoffer
Bitcraze
Posts: 630
Joined: Tue Jun 30, 2015 7:47 am

Re: Controlling Crazyflie with LPS

Post by kristoffer »

I had forgotten to mention that if all my questions take into account the boundary set by the LPS nodes.
I'm not sure what you mean, could you please explain a bit further?

The issue Kimberly referred to was https://github.com/bitcraze/crazyflie-f ... issues/536
youngbin1130
Member
Posts: 46
Joined: Thu Dec 12, 2019 4:28 am

Re: Controlling Crazyflie with LPS

Post by youngbin1130 »

Hi,

Basically, I would like to control the Crazyflie to move from (x,y,z) to (x1,y1,z1) within inside the LPS "box" while being able to access low level commands.

I have taken a look at the examples/position_commander_demo.py and tested it on my Crazyflie. It seems to behave a little strangely on my Crazyflie. When running the first "pc.forward(1.0)", I've noticed that the Crazyflie flies backwards diagonally and I'm not sure what the expected behaviour is. Here is the link to the video: https://youtu.be/7WKfWd7pX-s

Also after further research, I've noticed that examples/autonomousSequence.py has a similar function (moving from Point x,y,z to x1,y1,z1) using the set_position setpoint. How is this different with the position_commander_demo.py or is there any difference at all?
kristoffer
Bitcraze
Posts: 630
Joined: Tue Jun 30, 2015 7:47 am

Re: Controlling Crazyflie with LPS

Post by kristoffer »

Thanks!

That looks a bit weird. your system set up looks pretty good, I guess you have double checked that the anchors positions are correct?
Just to make sure, the Crazyflie must be oriented facing the positive X direction when taking off.

pc.forward(1.0) should move one meter in the forward direction.

Maybe you should start by taking off and landing. The easiest way should be to replace the motion commands with a time.sleep(5)
Also after further research, I've noticed that examples/autonomousSequence.py has a similar function (moving from Point x,y,z to x1,y1,z1) using the set_position setpoint. How is this different with the position_commander_demo.py or is there any difference at all?
There are many ways to do it :-)
In the autonomousSequence.py script we continuously send setpoints to the Crazyflie. In position_commander_demo.py the high level commander handles that on board the Crazyflie instead.
youngbin1130
Member
Posts: 46
Joined: Thu Dec 12, 2019 4:28 am

Re: Controlling Crazyflie with LPS

Post by youngbin1130 »

I've check and confirmed that my Crazyflie is facing the correct direction. I will start by taking off and landing, as per your suggestion.

Also, I would like to ask regarding the Github which you and Kimberly linked met to. If I'm understanding this correctly, if I set lower-level commands and run high level commands afterwards, the lower level commands doesn't override the higher level commands? So does this mean that I am unable to combine the linear/angular velocity variable with the go_to functions in worldspace?

Finally, I would also like to ask if it is possible for the example/autonomousSequence.py to work within a swarm environment? For my project, I would like to use the variable "YAW" within the sequence of autonomousSequence.py but, so far, I've only manage to make the swarm system work in only the example/SwarmSequence.py.

My team is currently trying to use a machine learning model and bringing those accumulated data from a simulated environment so being able to use the three variables I mentioned at the beginning of this post would be really great.

Thanks for all the help! Hope you stay well and healthy during this time period. Cheer!
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Controlling Crazyflie with LPS

Post by kimberly »

Hi!

Hmm yes good question. It is fine as long as you are not changing the commander type I believe. If you just use the regular commander: https://github.com/bitcraze/crazyflie-l ... mmander.py, it has both functionalities for sending angle setpoints and position velocity setpoints. That might be able to work as well. I might work on this myself since I'm working on tuning scripts for the PID attitude controller

So in the swarm example you mentioned, you can change yaw if you want: https://github.com/bitcraze/crazyflie-l ... ce.py#L268. The last value in this send function is in fact yaw and just zero for now. If you add the wanted yaw value in the sequence structure ( on top of the script, where for now there is just x,y,z and time), your able to input yaw there as well.

You stay healthy as well!
youngbin1130
Member
Posts: 46
Joined: Thu Dec 12, 2019 4:28 am

Re: Controlling Crazyflie with LPS

Post by youngbin1130 »

Thanks for the reply Kimberly!

I'll look into the commander.py!

Just another quick question. I was trying to run exmaple/Motion_Commander_demo.py using the my Crazyflie and the LPS nodes but it would either not take off take off the floor or touch the floor during the sequence. I've checked my propellers and they are in the correct orientation. I've attached a video my Crazyflie running this. I'm pretty sure this isn't the intended behavior.

https://youtu.be/thxPbXRfI7g

Cheers.
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: Controlling Crazyflie with LPS

Post by kimberly »

Thanks for sharing the video.

Actually, the flight looks pretty good but it's flying a bit low. I think that the state estimation is a bit off. If you place your crazyflie on the floor and look at state.Z log in the plotter of the cfclient, what does it say?

By the way, it looks like you have setup your lab now at your place? Can you let us know more or can we share this with the rest of the community? We are currently trying to help out and inspire users to continue their work at home in this current situation.
Post Reply