Repository navigation
Expand file tree
/
Copy pathrt_data.h
More file actions
86 lines (76 loc) · 5.14 KB
/
Copy pathrt_data.h
File metadata and controls
86 lines (76 loc) · 5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright 2024 Lukas Hrazky
//
// This file is part of the Refloat VESC package.
//
// Refloat VESC package is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
//
// Refloat VESC package is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
// List of items to send via the REALTIME_DATA command and record in the data
// recorder.
//
// S: Send in realtime data
// R: Record the data in data recorder in addition to sending in realtime data
//
// RT_DATA_ITEMS are always sent, RT_DATA_RUNTIME_ITEMS are sent only when Running.
// Items from both lists are recorded all the time (when recording is on).
//
// The listed items directly reference members of the Data struct.
//
// Caution when changing or removing existing items! Their IDs are part of the
// Command interface (an inherent drawback of the design, a price for having a
// single easy-to-modify list). Renaming or removing an item here may make a
// client app miss the item and potentially misbehave (the package AppUI
// handles this gracefully, but the value may still be missing if it's used in
// the UI).
#define RT_DATA_ITEMS(S, R) \
R(imu_freq_tracker.dt, "control.dt") \
R(imu_freq_tracker.frequency, "control.freq") \
R(imu_latency_tracker.excess, "control.latency") \
S(motor.speed, "speed") \
R(motor.erpm, "erpm") \
S(motor.current, "current") \
R(motor.dir_current, "dir_current") \
S(motor.filt_current.value, "filt_current") \
R(motor.duty_cycle.value, "duty_cycle") \
R(motor.batt_voltage, "batt_voltage") \
S(motor.batt_current.value, "batt_current") \
S(motor.mosfet_temp, "mosfet_temp") \
S(motor.motor_temp, "motor_temp") \
R(imu.pitch, "pitch") \
R(imu.balance_pitch, "balance_pitch") \
S(imu.roll, "roll") \
S(footpad.adc_left, "adc_left") \
S(footpad.adc_right, "adc_right") \
S(remote.input, "remote.input")
#define RT_DATA_RUNTIME_ITEMS(S, R) \
R(setpoint, "setpoint") \
R(atr.setpoint.value, "atr.setpoint") \
S(brake_tilt.setpoint.value, "brake_tilt.setpoint") \
R(torque_tilt.setpoint.value, "torque_tilt.setpoint") \
S(turn_tilt.setpoint.value, "turn_tilt.setpoint") \
S(remote.setpoint.value, "remote.setpoint") \
R(balance_current.value, "balance_current") \
S(atr.accel_diff, "atr.accel_diff") \
S(atr.speed_boost, "atr.speed_boost") \
R(atr.transition_boost, "atr.transition_boost") \
S(booster.torque.value, "booster.torque")
#define RT_DATA_ALL_ITEMS(S, R) RT_DATA_ITEMS(S, R) RT_DATA_RUNTIME_ITEMS(S, R)
#define __NOOP(target, id)
#define VISIT(LIST, ACTION) LIST(ACTION, ACTION)
#define VISIT_REC(LIST, ACTION) LIST(__NOOP, ACTION)
#define __COUNT_ITEMS(target, id) +1
#define __COUNT_IDS_SIZE(target, id) +sizeof(id)
#define ITEMS_COUNT(LIST) (VISIT(LIST, __COUNT_ITEMS))
#define ITEMS_IDS_SIZE(LIST) (VISIT(LIST, __COUNT_IDS_SIZE))
#define ITEMS_COUNT_REC(LIST) (VISIT_REC(LIST, __COUNT_ITEMS))
#define ITEMS_IDS_SIZE_REC(LIST) (VISIT_REC(LIST, __COUNT_IDS_SIZE))