Firmware and Python Library

Post Reply
Posts: 3
Joined: Tue Jan 22, 2019 8:43 am
Location: Canada

Firmware and Python Library

Post 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 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!
Posts: 2389
Joined: Tue Feb 06, 2007 12:36 pm

Re: Firmware and Python Library

Post by arnaud »


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: ... vel.c#L262

In the lib, you can then add a function that generates this packet and send it over the radio: ...

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": ... 2f4.c#L388.
Posts: 1
Joined: Thu Jun 27, 2019 6:10 am

Re: Firmware and Python Library

Post by pragatisatpute »

That was quite awesome thread.Looking forward to your posts. Keep up!
Posts: 2
Joined: Mon Aug 10, 2020 8:05 am

Re: Firmware and Python Library

Post by Harmanpubg18 »

Keep up Thnx
Post Reply