Firmware and Python Library

Firmware/software/electronics/mechanics
Post Reply
droneEnthusiast
Beginner
Posts: 3
Joined: Tue Jan 22, 2019 8:43 am
Location: Canada

Firmware and Python Library

Post by droneEnthusiast » Wed Jun 05, 2019 4:30 pm

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!



arnaud
Bitcraze
Posts: 2024
Joined: Tue Feb 06, 2007 12:36 pm

Re: Firmware and Python Library

Post by arnaud » Wed Jun 12, 2019 9:34 am

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.

pragatisatpute
Beginner
Posts: 1
Joined: Thu Jun 27, 2019 6:10 am
Contact:

Re: Firmware and Python Library

Post by pragatisatpute » Thu Jun 27, 2019 6:11 am

That was quite awesome thread.Looking forward to your posts. Keep up!

Post Reply