Communincation between python client and Crazyflie
Posted: Thu Dec 31, 2015 6:48 pm
Hi,
I am having a bit of trouble with crazyflie 2.0 and I was hoping somebody could help me with it please. Just a quick background, I have done some C programming and have worked on 2 separate arduino projects, both of which were of a much smaller scale than the CF. I have done very little python. I do have a strong background in Java though and have done some networking through Java (with sockets, etc). So to sum up, I am pretty much a novice in this area.
Firstly, I will explain the end goal of my project. I want to write a program that will make the CF take off, hover for a number of seconds, and land again. (By hover I mean remain as stationary as possible while in mid air, so not just "altitude hold"). I am developing on the VM provided. Thanks to the ramp.py example python program provided in the VM to ramp up the motors, I have been able to partly see how the client communicates with the CF. From what I can see, the commands to the motors are sent though the "send_setpoint" python function in commander.py. From there, a CRTPacket object is created, and the thrust, roll, yaw and pitch data are structured so they can be added as data to this packet object, and then the packet is sent.
The problem is that I cannot see where the packet is "incoming" on the CF side of things.
My plan is to create a hover class in the "modules" firmware package. In this class there will be several methods to (hopefully!) make the CF hover (I have an idea to make the CF hover but I won't get into it here). I want to write a python program that uses the send_setpoint function to send a message (such as "hover") to the CF to call one of the methods in the hover class. So far I have edited the commander.py class and added the following method to send my message:
When the CF firmware receives this message, it should call the hover_init() method in my hover.c class. For now, my hover_init method will just have a some simple task in it (such as turn off the motors or print hello world to console), just so I can see that it is working properly.
So my problem is that I cannot see where the packets are coming in, and I do not know how to analyse them, and I would be very grateful if someone could even point me in the right direction.
Thanks.
I am having a bit of trouble with crazyflie 2.0 and I was hoping somebody could help me with it please. Just a quick background, I have done some C programming and have worked on 2 separate arduino projects, both of which were of a much smaller scale than the CF. I have done very little python. I do have a strong background in Java though and have done some networking through Java (with sockets, etc). So to sum up, I am pretty much a novice in this area.
Firstly, I will explain the end goal of my project. I want to write a program that will make the CF take off, hover for a number of seconds, and land again. (By hover I mean remain as stationary as possible while in mid air, so not just "altitude hold"). I am developing on the VM provided. Thanks to the ramp.py example python program provided in the VM to ramp up the motors, I have been able to partly see how the client communicates with the CF. From what I can see, the commands to the motors are sent though the "send_setpoint" python function in commander.py. From there, a CRTPacket object is created, and the thrust, roll, yaw and pitch data are structured so they can be added as data to this packet object, and then the packet is sent.
The problem is that I cannot see where the packet is "incoming" on the CF side of things.
My plan is to create a hover class in the "modules" firmware package. In this class there will be several methods to (hopefully!) make the CF hover (I have an idea to make the CF hover but I won't get into it here). I want to write a python program that uses the send_setpoint function to send a message (such as "hover") to the CF to call one of the methods in the hover class. So far I have edited the commander.py class and added the following method to send my message:
Code: Select all
def send_hover_command(self, hover_message):
pk = CRTPPacket()
pk.port = CRTPPort.COMMANDER
pk.data = struct.pack('10s', hover_message)
self._cf.send_packet(pk)
So my problem is that I cannot see where the packets are coming in, and I do not know how to analyse them, and I would be very grateful if someone could even point me in the right direction.
Thanks.