gustavo
(Gustavo Fring)
October 15, 2021, 3:06am
1
Hello Everyone,
I’d like to know that channel 1~4 meaning and how to calculate the specific time for each data from mavlink data.
I could obtain the RC_CHANNEL data like below.
I reckon the channel is the related joystick, but I cannot find out which channel is related to each joystick move.
“data”: {“time_boot_ms”: 2265, “chancount”: 16, “chan1_raw”: 1500, “chan2_raw”: 1500, “chan3_raw”: 1000, “chan4_raw”: 1500, “chan5_raw”: 1800, “chan6_raw”: 1000, “chan7_raw”: 1000, “chan8_raw”: 1800, “chan9_raw”: 0, “chan10_raw”: 0, “chan11_raw”: 0, “chan12_raw”: 0, “chan13_raw”: 0, “chan14_raw”: 0, “chan15_raw”: 0, “chan16_raw”: 0, “chan17_raw”: 0, “chan18_raw”: 0, “rssi”: 255}}
Secondly, there is a time_boot_ms column, but don’t know how to get timestamp using time_boot_ms?
I know that there is a metadata section in the JSON file, but I saw that there is no metadata in the mavlink UDP packet, but only time_boot_ms. that is why I am questioning it.
Thanks for your reply in advance.
Take a Look at your RCMAP parameter to find out which channel is which.
I do not understand your second question. Time_boot_ms is the time since ArduCopter booted in milliseconds.
gustavo
(Gustavo Fring)
October 17, 2021, 7:44am
3
Thanks for reply.
If someone wants to get timestamp by time_boot_ms, you can refer code below.
jsonfile = "../data/2021-10-15/flight1/flight/RC_CHANNELS.json"
with open(jsonfile) as lines:
for line in lines:
jsondata = json.loads(line)
row = {}
for key in jsondata['data'].keys():
row[key] = jsondata['data'][key]
rows.append(row)
base = 1634254063923000 # microseconds
timed_base = pd.to_datetime(base, unit="us")
channelData = pd.DataFrame(rows)
channelData.rename({"time_boot_ms":"timestamp"}, axis=1, inplace=True)
channelData["timestamp"] = pd.to_datetime(channelData["timestamp"], unit="ms", origin=timed_base)
jsonfile = "../data/2021-10-15/flight1/flight/SERVO_OUTPUT_RAW.json"
with open(jsonfile) as lines:
for line in lines:
jsondata = json.loads(line)
row = {}
for key in jsondata['data'].keys():
row[key] = jsondata['data'][key]
rows.append(row)
servoData = pd.DataFrame(rows)
servoData.rename({"time_usec":"timestamp"}, axis=1, inplace=True)
servoData["timestamp"] = pd.to_datetime(servoData["timestamp"], unit="us", origin=timed_base)