Page 1 of 1

Firmware and Python Library

Posted: Wed Jun 05, 2019 4:30 pm
by droneEnthusiast
Hi all,

I was wondering if I were to add a function in crtp_commander_high_level.c, I understand how to build the code and flash the crazyflie. However, I'm a bit confused on how I can modify high_level_commander.py in order to use this C function in a python script?

Another related question is how can I access the pmGetBatteryVoltage() function in pm_stm32f4.c from a python script? I would like to monitor the battery level as the crazyflie is in flight.

Any suggestions are greatly appreciated! Thanks!

Re: Firmware and Python Library

Posted: Wed Jun 12, 2019 9:34 am
by arnaud
Hi,

If you add a function in the high level commander, you need to add a packet decoding for it so that this function can be called when a packet is sent to the Crazyflie: https://github.com/bitcraze/crazyflie-f ... vel.c#L262

In the lib, you can then add a function that generates this packet and send it over the radio: https://github.com/bitcraze/crazyflie-l ... der.py#L39.

Generally, there will be one file in the python lib talking to one file in the firmware, packet will be encoded on one side and decoded on the other side. This is the case with the high level commander.

As for the pmGetBatteryVoltage(), this is something that would typically be available as a log variable. In that case it is available as the variable "pm.vbat": https://github.com/bitcraze/crazyflie-f ... 2f4.c#L388.

Re: Firmware and Python Library

Posted: Thu Jun 27, 2019 6:11 am
by pragatisatpute
That was quite awesome thread.Looking forward to your posts. Keep up!