-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRBSharedMemory.h
296 lines (241 loc) · 6.91 KB
/
RBSharedMemory.h
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#ifndef RB_SHARED_MEMORY_H
#define RB_SHARED_MEMORY_H
#define RBCORE_SHM_NAME "RBCORE_SHARED_MEMORY"
#define MAX_JOINT 2
#define MAX_MC 29
#define MAX_FT 4
#define MAX_IMU 1
#define MAX_SP 1
#define MAX_OF 2
#define MAX_AL 20
#define MAX_MANUAL_CAN 30
#define MAX_COMMAND_DATA 20
#define MOTOR_1CH 1
#define MOTOR_2CH 2
#define COMMAND_CANID 0x01
#define SENSOR_REQUEST_CANID 0x03 //0x02
#define RT_TIMER_PERIOD_MS 5
#define RBCORE_PODO_NO 0
#define ENABLE 1
#define DISABLE 0
#define RBCORE_PI 3.141592f
#define MAX_LASER_DATA 1080
typedef enum{
MANUALCAN_NEW = 0,
MANUALCAN_EMPTY,
MANUALCAN_WRITING
} MANUALCAN_STATUS;
typedef struct _MANUAL_CAN_{
unsigned char channel;
unsigned int id;
unsigned char data[8];
unsigned char dlc;
MANUALCAN_STATUS status;
} MANUAL_CAN;
typedef struct _VISION2MOTION_
{
float pos[3];
float ori[4];
} VISION2MOTION, *pVISION2MOTION;
typedef union{
struct{
unsigned HIP:1; // Open loop(PWM) Control mode
unsigned RUN:1; // Control ON
unsigned MOD:1; // Control mode
unsigned LIM:1; // Limit sensor
unsigned HME:4; // Limit Sensor mode during Homing
unsigned JAM:1; // JAM error
unsigned PWM:1; // PWM saturation
unsigned BIG:1; // Big Position error
unsigned INP:1; // Big Input error
unsigned FLT:1; // FET Driver Fault 1= Fault
unsigned ENC:1; // encoder fail
unsigned CUR:1; // big current difference <<== used for CAN connection check
unsigned TMP:1; // Temperature warning
unsigned PS1:1; // Position Limit 1
unsigned PS2:1; // Position Limit 2
unsigned SWM:1; // switching mode (1:complementary, 0:non-complementary)
unsigned GOV:1; // gain override
unsigned FRC:1; // friction compensation
unsigned REF:1; // reference mode (1:incremental, 0:absolute)
unsigned CAN:1; // CAN has been recovered
unsigned RPL:1; // reply ok
}b;
unsigned char B[3];
}mSTAT;
typedef union{
struct{
unsigned onoff:1;
unsigned level:7;
}b;
unsigned char B;
}audioSTAT;
typedef struct _ENCODER_SENSOR_
{
int BoardConnection;
float CurrentReference;
float CurrentPosition;
float CurrentVelocity;
}ENCODER_SENSOR;
typedef struct _FT_SENSOR_
{
int BoardConnection;
float Mx;
float My;
float Mz;
float Fx;
float Fy;
float Fz;
float RollVel;
float PitchVel;
float Roll;
float Pitch;
}FT_SENSOR;
typedef struct _IMU_SENSOR_
{
int BoardConnection;
float Roll;
float Pitch;
float Yaw;
float RollVel;
float PitchVel;
float YawVel;
float AccX;
float AccY;
float AccZ;
float Roll_offset;
float Pitch_offset;
}IMU_SENSOR;
typedef struct _OF_SENSOR_
{
int BoardConnection;
int AccumX[2];
int AccumY[2];
int DeltaX[2];
int DeltaY[2];
float Xmea;
float Ymea;
float thmea;
float Pitmea;
}OF_SENSOR;
typedef struct _SMART_POWER_
{
int BoardConnection;
float Voltage;
float Current;
}SMART_POWER;
typedef struct _FOG_SENSOR_
{
float Roll;
float Pitch;
float Yaw;
float RollVel;
float PitchVel;
float YawVel;
int Warning;
}FOG_SENSOR;
typedef struct _COMMAND_STRUCT_
{
int USER_COMMAND;
char USER_PARA_CHAR[MAX_COMMAND_DATA];
int USER_PARA_INT[MAX_COMMAND_DATA];
float USER_PARA_FLOAT[MAX_COMMAND_DATA];
double USER_PARA_DOUBLE[MAX_COMMAND_DATA];
} COMMAND_STRUCT, *pCOMMAND_STRUCT;
typedef struct _USER_COMMAND_
{
int COMMAND_TARGET;
COMMAND_STRUCT COMMAND_DATA;
} USER_COMMAND, *pUSER_COMMAND;
//======================================
// Sensor Shared Memory <Read Only>
typedef struct _RBCORE_SHM_
{
// reference -------------------------
float JointReference[MAX_AL][MAX_MC][MOTOR_2CH];
float JointRef[34];
MANUAL_CAN ManualCAN[MAX_MANUAL_CAN];
// command ---------------------------
int SYNC_SIGNAL[MAX_AL];
int ACK_SIGNAL[MAX_MC][MOTOR_2CH];
int MotionOwner[MAX_MC][MOTOR_2CH];
COMMAND_STRUCT COMMAND[MAX_AL];
// sensor ----------------------------
char PODO_AL_WORKING[MAX_AL];
mSTAT MCStatus[MAX_MC][MOTOR_2CH];
float MCTemperature[MAX_MC];
float MotorTemperature[MAX_MC][MOTOR_2CH];
ENCODER_SENSOR ENCODER[MAX_MC][MOTOR_2CH];
FT_SENSOR FT[MAX_FT];
IMU_SENSOR IMU[MAX_IMU];
FOG_SENSOR FOG;
OF_SENSOR OF;
SMART_POWER SP[MAX_SP];
int CAN_Enabled;
int REF_Enabled;
int SEN_Enabled;
int ENC_Enabled;
int EXF_R_Enabled; // Extra Finger (R)
int EXF_L_Enabled; // Extra Finger (L)
float EXF_R_Modifier[5];
float EXF_L_Modifier[5];
int Sim_Time_sec;
int Sim_Time_nsec;
// State Machine Return Data ---------------
int STATE_COMMAND;
char STATE_PARA_CHAR[10];
int STATE_PARA_INT[10];
float STATE_PARA_FLOAT[10];
float HANDLE_ANGLE;
char ACC_STATE;
audioSTAT audioData;
int LaserDistanceData[MAX_LASER_DATA];
int LaserLength;
float CarRef[4];
//VisionData
VISION2MOTION V2M;
}RBCORE_SHM, *pRBCORE_SHM;
//======================================
typedef enum _COMMAND_SET_{
NO_ACT = 0,
// For process handle
DAEMON_PROCESS_CREATE,
DAEMON_PROCESS_KILL,
// For initialize
DAEMON_INIT_CHECK_DEVICE,
DAEMON_INIT_FIND_HOME,
DAEMON_INIT_FET_ONOFF,
DAEMON_INIT_CONTROL_ONOFF,
DAEMON_INIT_SET_FINGER_MODIFIER,
// For attribute
DAEMON_ATTR_SWITCHING_MODE,
DAEMON_ATTR_FRICTION_COMPENSATION,
DAEMON_ATTR_CONTROL_MODE,
// For sensor
DAEMON_SENSOR_ENCODER_RESET,
DAEMON_SENSOR_ENCODER_ONOFF,
DAEMON_SENSOR_SENSOR_ONOFF,
DAEMON_SENSOR_FT_NULL,
DAEMON_SENSOR_IMU_NULL,
DAEMON_SENSOR_IMU_OFFSET_SET,
DAEMON_SENSOR_FOG_NULL,
DAEMON_SENSOR_FOG_USB_RESET,
DAEMON_SENSOR_OF_NULL,
DAEMON_SENSOR_OF_LAMP_ONOFF,
// For motion
DAEMON_MOTION_REF_ONOFF,
DAEMON_MOTION_MOVE,
DAEMON_MOTION_GAIN_OVERRIDE,
DAEMON_MOTION_ERROR_CLEAR,
// For CAN
DAEMON_CAN_ENABLE_DISABLE,
//
POWER_CONTROL,
// DRC SPECIFIC
REQUEST_AL_NUM,
SENSOR_OPT_NULL,
SENSOR_OPT_LAMPON,
SENSOR_OPT_LAMPOFF,
FOG_USB_RESET
} COMMAND_SET;
#endif // RB_SHARED_MEMORY_H