positioning question

All discussions related to the Loco Positioning system
newcuriousstudent
Beginner
Posts: 10
Joined: Fri Jul 31, 2020 1:45 am

positioning question

Post by newcuriousstudent »

hey quick question,

So I was trying to find how to get the position data for the drones(I am using the LPS system). In various links on this forum I saw comments about using:
stateEstimate.x, stateEstimate.y, stateEstimate.z to get the position data. Are there any examples to get position data using those variables or another method to get position data?


- Thanks!
kristoffer
Bitcraze
Posts: 322
Joined: Tue Jun 30, 2015 7:47 am

Re: positioning question

Post by kristoffer »

Yes, stateEstimate.x, stateEstimate.y, stateEstimate.z contains the estimated position.
You can find examples of how to read log data in https://github.com/bitcraze/crazyflie-l ... asiclog.py and https://github.com/bitcraze/crazyflie-l ... logSync.py
newcuriousstudent
Beginner
Posts: 10
Joined: Fri Jul 31, 2020 1:45 am

Re: positioning question

Post by newcuriousstudent »

Thanks for the reply!

So for stateEstimate.x and the other two, can I just use them straight up in a program or is anything else needed to be able to get the values of position with stateEstimate?

Also for those links, do I run them at the same time as another program? I mean I run a script to move the drone and then at the same time one of those scripts to get the position?
kimberly
Bitcraze
Posts: 518
Joined: Fri Jul 06, 2018 11:13 am

Re: positioning question

Post by kimberly »

Hi!

The scripts can be used separately from eachother. You don't need to connect anything else and the LPS system provides already positioning onboard. You can look at the state estimates from the plotter functionality or you can use this step-by-step guide to know how to use the logging variables in the python library.
newcuriousstudent
Beginner
Posts: 10
Joined: Fri Jul 31, 2020 1:45 am

Re: positioning question

Post by newcuriousstudent »

Hey again!

I was still trying to test out stateEstimate.x and I still cannot get it to work.
I keep getting:
NameError: name 'stateEstimate' is not defined


How should I fix this?

Also in those examples you linked for the logging, this might be a stupid question but those only give roll, pitch, yaw right?
Is there any way to get them to give x,y,z position?
kristoffer
Bitcraze
Posts: 322
Joined: Tue Jun 30, 2015 7:47 am

Re: positioning question

Post by kristoffer »

Hi!

Try this log config

Code: Select all

    lg_stab = LogConfig(name='Stabilizer', period_in_ms=50)
    lg_stab.add_variable('stateEstimateZ.x', 'float')
    lg_stab.add_variable('stateEstimateZ.y', 'float')
    lg_stab.add_variable('stateEstimateZ.z', 'float')
You can find the exact name and type by looking in the firmware code. You will find the state estimate logging here https://github.com/bitcraze/crazyflie-f ... #L637-L640

As you can see the log group name is "stateEstimate", the variable name "x" and the type float.

By the way, I saw your question earlier if it is possible to run multiple scripts at the same time, and the short answer is no.
If you want to do multiple things at the same time you have to write one script that does it.
The example scripts that shows synchronous functionality (synch in the name) are usually easier to understand, but also more limited and might be hard to extend with parallell functionality. You are probably better off starting from one of the asynchronous scripts instead. They are a bit more messy but the callback structure offers more possibilities.
newcuriousstudent
Beginner
Posts: 10
Joined: Fri Jul 31, 2020 1:45 am

Re: positioning question

Post by newcuriousstudent »

First of all Thank you for your reply!

1) So to get position I use: 'stateEstimateZ.x'?
How do I scale this why I would fly many drones at the same time?

2) Ok so for asynchronous drones could show me an example? I think I know what you are talking about but I am not sure.

But are there asynch examples for velocity flight?
That was what I was trying to do. Fly multiple crazyflies (eventually large swarms) at the same time using velocity based flight.
kristoffer
Bitcraze
Posts: 322
Joined: Tue Jun 30, 2015 7:47 am

Re: positioning question

Post by kristoffer »

1) Argh! copy/paste error, sorry my bad, it should have been

Code: Select all

    lg_stab = LogConfig(name='Stabilizer', period_in_ms=50)
    lg_stab.add_variable('stateEstimate.x', 'float')
    lg_stab.add_variable('stateEstimate.y', 'float')
    lg_stab.add_variable('stateEstimate.z', 'float')
you should use the "stateEstimate" group.

2) basiclog.py is a good example of how to connect and set up logging asynchronously. In the while loop at the bottom you do what every you like, for instance send setpoints to the Crazyflie to move it around.
I don't think there are any async examples of sending set points, the sending part is no different from a sync solution though. Check out the sync examples and also look in the underlying classes in the lib that are used by the examples, you should find lots of good stuff there.
newcuriousstudent
Beginner
Posts: 10
Joined: Fri Jul 31, 2020 1:45 am

Re: positioning question

Post by newcuriousstudent »

Hi again!

So I attempted the basiclog.py example. I cannot seem to get it to work.

When I run the program I keep getting:
Scanning interfaces for Crazyflies...
Crazyflies found:
No Crazyflies found, cannot run example


I have a crazyflie on and everything. I have tried this while another script is running aswell.
What should I do?
I tried multiple crazyflies and it happens to all of them.
newcuriousstudent
Beginner
Posts: 10
Joined: Fri Jul 31, 2020 1:45 am

Re: positioning question

Post by newcuriousstudent »

Also for the logging config:

lg_stab = LogConfig(name='Stabilizer', period_in_ms=50)
lg_stab.add_variable('stateEstimate.x', 'float')
lg_stab.add_variable('stateEstimate.y', 'float')
lg_stab.add_variable('stateEstimate.z', 'float')

I got the crazyflie's python script to run with this. But how do I get outputed position from lg_stab.
I am sorry if this is a simple thing but I just cannot figure it out
Post Reply