You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/interfaces/README.md
+41-1Lines changed: 41 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ message 2346 'Converter temperature error' after the warning time1) (ID32943) ha
128
128
- inverter's internal value of (TD) kd
129
129
- AKA SERCOS parameter ID102
130
130
131
-
## VCF Interfaces
131
+
## VCF Interface
132
132
133
133
The VCR is connected over CAN and Ethernet to the VCF. We will use the CAN communication for latency-sensitive communication such as the driver input and controller input sensor signals. The Ethernet link will be used for the non-timing-sensitive data.
134
134
@@ -183,3 +183,43 @@ VCF Outputs:
183
183
- means that the firmware was flashed while there was changes made that had not been commited
184
184
- `char git_short_hash[8]`
185
185
- the git hash of the commit that was flashed to the
186
+
187
+
## Drivebrain Interface
188
+
189
+
### CAN interface
190
+
191
+
#### preface
192
+
__NOTE__: the following messages that are on the bus are listened to by the drivebrain and are output from other boards (not VCR)
193
+
- pedal data CAN packet (VCF)
194
+
- inverter data (FL, FR, RL, RR inverters) -> these will be forwarded messages being forwarded by VCR onto the telem CAN line
195
+
196
+
VCR Outputs:
197
+
198
+
- VCR suspension data CAN packet:
199
+
-`uint16_t rl_load_cell`
200
+
-`uint16_t rr_load_cell`
201
+
-`uint16_t rl_shock_pot`
202
+
-`uint16_t rr_shock_pot`
203
+
204
+
- VCR status CAN packet:
205
+
- vehicle state (oneof: RTD, tractive system enabled, etc.)
206
+
- control mode
207
+
- VCR
208
+
- VCR error state word
209
+
- drivebrain timeout, VCF timeout, VCR firmware error, etc.
210
+
211
+
VCR inputs (sent by drivebrain):
212
+
- desired RPMs
213
+
-`int16_t fl_rpm`
214
+
-`int16_t fr_rpm`
215
+
-`int16_t rl_rpm`
216
+
-`int16_t rr_rpm`
217
+
218
+
- torque limits
219
+
-__note__: in units of .01nm: 2100 = 21nm, 2150 = 21.5nm
Copy file name to clipboardExpand all lines: lib/systems/README.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,4 +101,26 @@ stateDiagram-v2
101
101
torq_mode --> err: incorrect user command type OR any inverter error
102
102
err --> clear_err: on user request of error reset
103
103
clear_err --> not_en_hv: on successful reset of errors (either internally to the drivetrain system or of the inverters themselves)
104
-
```
104
+
```
105
+
106
+
## drivebrain controller system
107
+
108
+
Drivebrain Controller for fail-safe pass-through control of the car
109
+
110
+
this class is the "controller" that allows for pass-through control as commanded by the drivebrain. It also calculates the latency of the most recent input and checks to see if the most recent input is still valid and has not expired. If the input has expired then it switches over to the fail-safe control mode (MODE0) to allow for safe failing even while the car is driving so that we dont lose hard-braking capabilities.
111
+
112
+
The controller can clear it's own fault by switching off of this operating mode and then swapping back to this operating mode. The fault clears the first time this controller gets evaluated while switch from the swapped-to mode back to this pass through mode.
113
+
- all controllers get evaluated once when being evaluated as a mode to switch to. during this evaluation is when the fault clears.
114
+
115
+
### latency measurement:
116
+
- the latency is measured by the difference in times in received messages from drivebrain over CAN. if the difference is too great, we swap to MODE0 control. it is assumed that the transmission delay is negligible
117
+
118
+
### config and I/O
119
+
config:
120
+
- maximum allowed latency
121
+
- assigned controller mode (currently defaults to MODE4)
122
+
inputs:
123
+
- the current car state from which it gets the latest drivebrain input, current controller mode and the stamped drivebrain message data
124
+
outputs:
125
+
- drivetrain command either from drivebrain or mode0 depending on if an error is present
126
+
- getter for the internal state of the drivebrain controller (error present, etc.)
// TODO - [ ] need to validate that the times that are apparent in the drivebrain data
9
+
// and ensure that they are within tolerence to current sys-tick
10
+
11
+
// TODO - [ ] if the drivebrain controller is currently the active controller,
12
+
// the latency fault should be latching
13
+
14
+
// meaning that if we fail any of the latency checks while active we cannot clear the timing failure fault
15
+
// unless we switch to another controller and back again. in reality, the CAN line or ethernet conditions
16
+
// probably wont improve randomly during runtime so it will keep faulting. primarily this is just to make sure
17
+
// we dont keep going from latent to not latent while driving and thus the driver gets jittered and the
18
+
// drivetrain will keep "powering up" and "powering down"
19
+
20
+
// TODO - [ ] correctly measure latency between drivebrain and VCR:
21
+
//
22
+
23
+
/*! \brief Drivebrain Controller for fail-safe pass-through control of the car
24
+
RESPONSIBILITIES AND DOCUMENTATION
25
+
26
+
this class is the "controller" that allows for pass-through control as commanded by the drivebrain. It also calculates the
27
+
latency of the most recent input and checks to see if the most recent input is still valid and has not expired. If the
28
+
input has expired then it switches over to the fail-safe control mode (MODE0) to allow for safe failing even while the car
29
+
is driving so that we dont lose hard-braking capabilities.
30
+
31
+
This class can clear it's own fault by switching off of this operating mode and then swapping back to this operating mode.
32
+
The fault clears the first time this controller gets evaluated while switch from the swapped-to mode back to this pass
33
+
through mode.
34
+
35
+
latency measurement:
36
+
- the latency is measured by the difference in times in received messages from drivebrain over CAN. if the difference
37
+
is too great, we swap to MODE0 control. it is assumed that the transmission delay is negligible
38
+
39
+
config:
40
+
- maximum allowed latency
41
+
- assigned controller mode (currently defaults to MODE4)
42
+
inputs:
43
+
- the current car state from which it gets the latest drivebrain input, current controller mode and the stamped drivebrain
44
+
message data
45
+
*/
46
+
classDrivebrainController
47
+
{
48
+
public:
49
+
50
+
/// @brief constructor for the drivebrain controller class
51
+
/// @param allowed_latency the allowed latency in milliseconds for which if the most recent packet has a timestamp older than this measure of time we fail safe
52
+
/// @param assigned_controller_mode the controller mode that the drivebrain controller is assigned to. is required for evaluating whether or not we are active or not
0 commit comments