-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathrobot_status.js
156 lines (139 loc) · 6.24 KB
/
robot_status.js
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
/*issues
measured_angles now returns array of 5. But might we want array of 6 or 7?
proposal takes 1 arg, # of angles to return. Default=5, but could be 6 or 7 (or 1 thru 4)
*/
//Robot Status Class (as distinguished from the robot_status 1D array of 60 elts.
var RobotStatus = class RobotStatus{
constructor({robot_status="required"}){
this.robot_status = robot_status
}
job_id() { return this.robot_status[Dexter.JOB_ID] }
instruction_id() { return this.robot_status[Dexter.INSTRUCTION_ID]}
start_time() { return this.robot_status[Dexter.START_TIME]}
stop_time() { return this.robot_status[Dexter.STOP_TIME]}
instruction_type() { return this.robot_status[Dexter.INSTRUCTION_TYPE]}
error_code() { return this.robot_status[Dexter.ERROR_CODE]}
job_id_of_current_instruction() { return this.robot_status[Dexter.JOB_ID_OF_CURRENT_INSTRUCTION]}
current_instruction_id() { return this.robot_status[Dexter.CURRENT_INSTRUCTION_ID]}
//unused "RECORD_BLOCK_SIZE", //same name 8 //unused
end_effector_in() { return this.robot_status[Dexter.END_EFFECTOR_IN]}
angle(joint_number){
let label = "Dexter.J" + joint_number + "_ANGLE"
let index = value_of_path(label)
let result = this.robot_status[index]
if(typeof(result) == "number") { return result}
else {
inspect(this.robot_status)
dde_error("RobotStatus.angle passed joint_number: " + joint_number +
"<br/> but the value of that is: " + result +
"<br/> when it should be a number." +
"<br/>The whole robot status is: " + this.robot_status)
}
}
angles(joint_count=5){
let result = []
for(let j_number = 1; j_number <= joint_count; j_number++){
result.push(this.angle(j_number))
}
return result
}
delta(joint_number){
let label = "Dexter.J" + joint_number + "_DELTA"
let index = value_of_path(label)
let result = this.robot_status[index]
if(typeof(result) == "number") { return result}
else { dde_error("RobotStatus.delta passed joint_number: " + joint_number + " which isn't valid.") }
}
deltas(joint_count=5){
let result = []
for(let j_number = 1; j_number <= joint_count; j_number++){
result.push(this.delta(j_number))
}
return result
}
pid_delta(joint_number){
let label = "Dexter.J" + joint_number + "_PID_DELTA"
let index = value_of_path(label)
let result = this.robot_status[index]
if(typeof(result) == "number") { return result}
else { dde_error("RobotStatus.pid_delta passed joint_number: " + joint_number + " which isn't valid.") }
}
pid_deltas(joint_count=5){
let result = []
for(let j_number = 1; j_number <= joint_count; j_number++){
result.push(this.pid_delta(j_number))
}
return result
}
/*force_calc_angle(joint_number){
let result = this.robot_status["J" + joint_number + "_FORCE_CALC_ANGLE"]
if(typeof(result) == "number") { return result}
else { dde_error("RobotStatus.force_calc_angle passed joint_number: " + joint_number + " which isn't valid.") }
}
force_calc_angles(joint_count=5){
let result = []
for(let j_number = 1; j_number <= joint_count; j_number++){
result.push(this.force_calc_angle(j_number))
}
return result
}*/
a2d_sin(joint_number){
let label = "Dexter.J" + joint_number + "_A2D_SIN"
let index = value_of_path(label)
let result = this.robot_status[index]
if(typeof(result) == "number") { return result}
else { dde_error("RobotStatus.a2d_sin passed joint_number: " + joint_number + " which isn't valid.") }
}
a2d_sins(joint_count=5){
let result = []
for(let j_number = 1; j_number <= joint_count; j_number++){
result.push(this.a2d_sin(j_number))
}
return result
}
a2d_cos(joint_number){
let label = "Dexter.J" + joint_number + "_A2D_COS"
let index = value_of_path(label)
let result = this.robot_status[index]
if(typeof(result) == "number") { return result}
else { dde_error("RobotStatus.a2d_cos passed joint_number: " + joint_number + " which isn't valid.") }
}
a2d_coses(joint_count=5){
let result = []
for(let j_number = 1; j_number <= joint_count; j_number++){
result.push(this.a2d_cos(j_number))
}
return result
}
measured_angle(joint_number) {
if (joint_number == 1) { return this.robot_status[Dexter.J1_MEASURED_ANGLE] }
else if (joint_number == 2) { return this.robot_status[Dexter.J2_MEASURED_ANGLE] }
else if (joint_number == 3) { return this.robot_status[Dexter.J3_MEASURED_ANGLE] }
else if (joint_number == 4) { return this.robot_status[Dexter.J4_MEASURED_ANGLE] }
else if (joint_number == 5) { return this.robot_status[Dexter.J5_MEASURED_ANGLE] }
else if (joint_number == 6) { return this.robot_status[Dexter.J6_MEASURED_ANGLE] }
else if (joint_number == 7) { return this.robot_status[Dexter.J7_MEASURED_ANGLE] }
else { dde_error("RobotStatus.measured_angle passed joint_number: " + joint_number + " which isn't valid.") }
}
measured_angles(joint_count=5){
let result = []
for(let j_number = 1; j_number <= joint_count; j_number++){
result.push(this.measured_angle(j_number))
}
return result
}
sent(joint_number){
let label = "Dexter.J" + joint_number + "_SENT"
let index = value_of_path(label)
let result = this.robot_status[index]
if(typeof(result) == "number") { return result}
else { dde_error("RobotStatus.sent passed joint_number: " + joint_number + " which isn't valid.") }
}
sents(joint_count=5){
let result = []
for(let j_number = 1; j_number <= joint_count; j_number++){
result.push(this.sent(j_number))
}
return result
}
}