Queston about the crazyradio python library's ack.data
Posted: Mon Jun 13, 2016 3:46 pm
Hey Forum
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.
So essentially I'm just sending two commander packets back to back. The first with zero thrust to unlock the commander, and the second with thrust set to 5000 so I can see the motors spin up a little bit. In the ACK payload, I expect to see the 'empty' ACK which is really the RSSI ack packet. Byte 0 alternates between 0xF7 and 0xF3, byte 1 is always 0x01, and the byte 2 is RSSI. I've also extended it to include vBat, so byte 3 is always 0x02, and bytes 4, 5, 6, and 7 are the vBat. So in summary, I should see an ack that looks something like this (where 'N' is a value that changes):
"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.
Any clues what's up with that ACK packet? It looks like garbage data to me. The payload length varies wildly as I re-run the script.
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