positioning question

All discussions related to the Loco Positioning system
Posts: 369
Joined: Tue Jun 30, 2015 7:47 am

Re: positioning question

Post by kristoffer »

Scanning interfaces for Crazyflies...
Crazyflies found:
No Crazyflies found, cannot run example
Can you connect to the Crazyflie using the python client? It is using the same code and if it works from the client it should from the example script. Not sure what is happening.
From your next post I get the feeling that it works, at least some times, correct?

The basiclog.py example is designed to scan for crazyflies and use the first one. If you want to, you can also hard code the radio settings like this

Code: Select all

    # Scan for Crazyflies and use the first one found
    # print('Scanning interfaces for Crazyflies...')
    # available = cflib.crtp.scan_interfaces()
    # print('Crazyflies found:')
    # for i in available:
    #     print(i[0])

    # if len(available) > 0:
    #     le = LoggingExample(available[0][0])
    # else:
    #     print('No Crazyflies found, cannot run example')

    uri = 'radio://0/30'
    le = LoggingExample(uri)
I got the crazyflie's python script to run with this. But how do I get outputed position from lg_stab.
Not sure what you mean. The log data is available in the _stab_log_data() callback and is printed

Code: Select all

    def _stab_log_data(self, timestamp, data, logconf):
        """Callback from a the log API when data arrives"""
        print('[%d][%s]: %s' % (timestamp, logconf.name, data))
Posts: 2391
Joined: Tue Feb 06, 2007 12:36 pm

Re: positioning question

Post by arnaud »

For your first question, it seems that you are trying to run 2 scripts at the same time? If so, this is not possible, a script will take control of a Crazyradio and of the Crazyflie connection (there should be only one client connected to the Crazyflie at once).

As for the logging, you need to add it to the Crazyflie, setup a callback in lg_stab and start it. The callback function will be called for each new value received from the Crazyflie. See the autonomous sequence example for an example of position logging: https://github.com/bitcraze/crazyflie-l ... #L122-L124
Posts: 15
Joined: Fri Jul 31, 2020 1:45 am

Re: positioning question

Post by newcuriousstudent »

Thanks a lot guys!
I was able to finally get logging to work!

So what you are referring to would let me fly a drone and get the position at the same time, right?
Posts: 700
Joined: Fri Jul 06, 2018 11:13 am

Re: positioning question

Post by kimberly »


Yes, what arnaud suggested should work.

Btw, using a callback to get the logging variables while the crazyflie is flying is also covered in the step-by-step guides (the motion commander one).

https://www.bitcraze.io/documentation/r ... commander/
Post Reply