I'm working on extending the deviationTx firmware to implement telemetry via the logging framework and I'm wanting to do some prototyping via the crazyradio and the python library for the crazyradio. I'm intentionally hooking in at a very low layer (the crazyradio.py library directly instead of the full crazyflie python library built on top of it) since I'm trying to use the radio directly as I will in deviationTx.
I'm having some trouble with the data field in the ack packet returned by send_packet(). My code is below.
Code: Select all
import sys
import struct
sys.path.append("../crazyflie-clients-python/src/cflib")
from cflib.drivers import crazyradio
from cflib.crtp.crtpstack import CRTPPacket
from cflib.crtp.crtpstack import CRTPPort
cr = crazyradio.Crazyradio()
cr.set_channel(0)
cr.set_data_rate(cr.DR_2MPS)
pk = CRTPPacket()
pk.set_header(CRTPPort.COMMANDER, 0)
roll = 0.0
pitch = 0.0
yaw = 0.0
thrust = 0
pk.data = bytearray(struct.pack("f", roll))
pk.data += bytearray(struct.pack("f", pitch))
pk.data += bytearray(struct.pack("f", yaw))
pk.data += bytearray(struct.pack("H", thrust))
packet = bytearray([pk.header]) + pk.data
print("Sending: " + "".join("0x%02x " % b for b in packet))
res = cr.send_packet(packet)
print(res.ack)
print(res.powerDet)
print(res.retry)
print("Recieved ACK: " + "".join("0x%02x " % b for b in res.data))
roll = 0.0
pitch = 0.0
yaw = 0.0
thrust = 5000
pk.data = bytearray(struct.pack("f", roll))
pk.data += bytearray(struct.pack("f", pitch))
pk.data += bytearray(struct.pack("f", yaw))
pk.data += bytearray(struct.pack("H", thrust))
packet = bytearray([pk.header]) + pk.data
print("Sending: " + "".join("0x%02x " % b for b in packet))
res = cr.send_packet(packet)
print(res.ack)
print(res.powerDet)
print(res.retry)
print("Recieved ACK: " + "".join("0x%02x " % b for b in res.data))
"0xF7 0x01 0xNN 0x02 0xNN 0xNN 0xNN 0xNN" or "0xF3 0x01 0xNN 0x02 0xNN 0xNN 0xNN 0xNN"
Here's the sample output when I run the code. The motors *do* spin up on the second packet, so my transmission is in fact making it to the copter.
Code: Select all
Sending: 0x3c 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
True
False
0
Recieved ACK: 0x00 0x53 0x59 0x53 0x3a 0x20 0x42 0x75 0x69 0x6c 0x64 0x20 0x31 0x34 0x37 0x3a 0x30 0x37 0x34 0x38 0x61 0x36 0x31 0x66 0x32 0x39 0x62 0x63 0x20 0x28 0x32
Sending: 0x3c 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x88 0x13
True
False
0
Recieved ACK: 0x00 0x30 0x31 0x35 0x2e 0x30 0x38 0x2e 0x31 0x2d 0x31 0x34 0x37 0x29 0x20 0x43 0x4c 0x45 0x41 0x4e 0x0a