Skip to content

Commit db517ca

Browse files
committed
1.7.0 dev, update examples
1 parent f2dc90d commit db517ca

5 files changed

Lines changed: 75 additions & 67 deletions

File tree

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [1.7.0] - 2016-06-24
2+
3+
### Fix
4+
- Update examples Calibration.ino, movement.ino, Add new UArmTextControl2.0.ino
5+
- Update uarm_library.h make some protected value be public
6+
17
## [1.6.2] - 2016-06-24
28

39
### Fix

examples/Calibration/Calibration.ino

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ void loop() {
3030
if (readSerial == 'c') {
3131
calibration_start();
3232
delay(1000);
33-
uarm.moveTo(0,-15,6);
33+
uarm.move_to(0,-15,6);
3434
}
3535

3636
//---------------------------------- Test Function ------------------------------------
3737
if (readSerial == '1') {
38-
uarm.moveTo(15,-15,5);
38+
uarm.move_to(15,-15,5);
3939
delay(1000);
4040
}
4141

4242

4343
if (readSerial == '2') {
44-
uarm.moveTo(-15,-15,5);
44+
uarm.move_to(-15,-15,5);
4545
delay(1000);
4646
}
4747

@@ -53,17 +53,17 @@ void loop() {
5353
Serial.println(i);
5454
double a = 0.0f;
5555
double b = 0.0f;
56-
uarm.readLinearOffset(i,a,b);
56+
uarm.read_linear_offset(i,a,b);
5757
Serial.print("A: ");
5858
Serial.print(a);
5959
Serial.print(", B: ");
6060
Serial.println(b);
6161
Serial.print("Manual Offset: ");
62-
Serial.print(uarm.readServoOffset(i));
62+
Serial.print(uarm.read_servo_offset(i));
6363
Serial.println("");
6464
}
6565
delay(1000);
66-
}
66+
}
6767
}
6868
}
6969

@@ -72,7 +72,7 @@ void loop() {
7272
**/
7373
void calibration_start(){
7474

75-
cleanEEPROM();
75+
// cleanEEPROM();
7676

7777
for (int k = 0; k < 4; k++) {
7878

@@ -115,27 +115,27 @@ void linear_calibration_servo(byte servo_num)
115115
{
116116
case SERVO_ROT_NUM:
117117
l_analog_pin = SERVO_ROT_ANALOG_PIN;
118-
uarm.writeServoAngle(SERVO_ROT_NUM, angle, false);
119-
uarm.writeLeftRightServoAngle(60, 30, false);
118+
uarm.write_servo_angle(SERVO_ROT_NUM, angle, false);
119+
uarm.write_left_right_servo_angle(60, 30, false);
120120
break;
121121

122122
case SERVO_LEFT_NUM:
123123
l_analog_pin = SERVO_LEFT_ANALOG_PIN;
124-
uarm.writeServoAngle(SERVO_ROT_NUM, 90, false);
125-
uarm.writeLeftRightServoAngle(angle, 30, false);
124+
uarm.write_servo_angle(SERVO_ROT_NUM, 90, false);
125+
uarm.write_left_right_servo_angle(angle, 30, false);
126126
break;
127127

128128
case SERVO_RIGHT_NUM:
129129
l_analog_pin = SERVO_RIGHT_ANALOG_PIN;
130-
uarm.writeServoAngle(SERVO_ROT_NUM, 90, false);
131-
uarm.writeLeftRightServoAngle(30, angle, false);
130+
uarm.write_servo_angle(SERVO_ROT_NUM, 90, false);
131+
uarm.write_left_right_servo_angle(30, angle, false);
132132
break;
133133

134134
case SERVO_HAND_ROT_NUM:
135135
l_analog_pin = SERVO_HAND_ROT_ANALOG_PIN;
136-
uarm.writeServoAngle(SERVO_ROT_NUM, 90, false);
137-
uarm.writeLeftRightServoAngle(60, 30, false);
138-
uarm.writeServoAngle(SERVO_HAND_ROT_NUM, angle, false);
136+
uarm.write_servo_angle(SERVO_ROT_NUM, 90, false);
137+
uarm.write_left_right_servo_angle(60, 30, false);
138+
uarm.write_servo_angle(SERVO_HAND_ROT_NUM, angle, false);
139139
break;
140140
default:
141141

@@ -181,7 +181,7 @@ void manual_calibration_section()
181181
{
182182
int setLoop = 1;
183183

184-
uarm.detachAll();
184+
uarm.detach_all_servos();
185185

186186
Serial.println("Put uarm in calibration posture (servo 1 to 3: 45, 130, 20 degree respectively), then input 1");
187187
while (setLoop) {
@@ -192,9 +192,9 @@ void manual_calibration_section()
192192

193193
if (inputChar=='1')
194194
{
195-
double offsetRot = uarm.readAngle(SERVO_ROT_NUM,true) - 45;
196-
double offsetL = uarm.readAngle(SERVO_LEFT_NUM,true) - 130;
197-
double offsetR = uarm.readAngle(SERVO_RIGHT_NUM,true) - 20;
195+
double offsetRot = uarm.read_servo_angle(SERVO_ROT_NUM,true) - 45;
196+
double offsetL = uarm.read_servo_angle(SERVO_LEFT_NUM,true) - 130;
197+
double offsetR = uarm.read_servo_angle(SERVO_RIGHT_NUM,true) - 20;
198198

199199
Serial.print("Offsets for servo 1 to 3 are ");
200200
Serial.println(offsetRot);

examples/UArmTextControl2.0/UArmTextControl2.0.ino

100755100644
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ String runCommand(String cmnd){
157157
if(errorResponse.length() > 0) {return errorResponse;}
158158
float values[1];
159159
getCommandValues(cmnd, pumpParameters, 1, values);
160-
if(values[0] > 0){ uarm.pumpOn(); }else if(values[0] <= 0){ uarm.pumpOff(); }
160+
if(values[0] > 0){ uarm.pump_on(); }else if(values[0] <= 0){ uarm.pump_off(); }
161161
return ok + cmnd + endB;
162162
}
163163

@@ -224,7 +224,7 @@ String runCommand(String cmnd){
224224
if(cmnd.indexOf(F("gcoords")) >= 0){
225225
double x = 0; double y = 0; double z = 0;
226226
//uarm.getCalXYZ(x, y, z);
227-
uarm.getCalXYZ(uarm.readAngle(SERVO_ROT_NUM), uarm.readAngle(SERVO_LEFT_NUM), uarm.readAngle(SERVO_RIGHT_NUM), x, y, z);
227+
uarm.angle_to_coordinate(uarm.read_servo_angle(SERVO_ROT_NUM), uarm.read_servo_angle(SERVO_LEFT_NUM), uarm.read_servo_angle(SERVO_RIGHT_NUM), x, y, z);
228228
return "[coordsX" + String(x) + "Y" + String(y) + "Z" + String(z) + "]\n";
229229
}
230230

@@ -235,7 +235,7 @@ String runCommand(String cmnd){
235235
float values[1];
236236

237237
getCommandValues(cmnd, gServoParameters, 1, values);
238-
float angle = uarm.readAngle(values[0]);
238+
float angle = uarm.read_servo_angle(values[0]);
239239
return "[angleA" + String(angle) + endB;
240240
}
241241

@@ -373,19 +373,19 @@ void setMove(double x, double y, double z, double goalSpeed) {
373373
//double cur_rot = uarm.readAngle(SERVO_ROT_NUM);
374374
//double cur_right = uarm.readAngle(SERVO_RIGHT_NUM);
375375
//double cur_left = uarm.readAngle(SERVO_LEFT_NUM);
376-
double cur_rot = uarm.readAngle(SERVO_ROT_NUM);
377-
double cur_left = uarm.readAngle(SERVO_LEFT_NUM);
378-
double cur_right = uarm.readAngle(SERVO_RIGHT_NUM);
376+
double cur_rot = uarm.read_servo_angle(SERVO_ROT_NUM);
377+
double cur_left = uarm.read_servo_angle(SERVO_LEFT_NUM);
378+
double cur_right = uarm.read_servo_angle(SERVO_RIGHT_NUM);
379379

380380

381-
uarm.getCalXYZ(cur_rot, cur_left, cur_right, current_x, current_y, current_z);
381+
uarm.angle_to_coordinate(cur_rot, cur_left, cur_right, current_x, current_y, current_z);
382382

383383

384384
// find target angles
385385
double tgt_rot;
386386
double tgt_left;
387387
double tgt_right;
388-
uarm.calAngles(x, y, z, tgt_rot, tgt_left, tgt_right);
388+
uarm.coordinate_to_angle(x, y, z, tgt_rot, tgt_left, tgt_right);
389389

390390

391391
// calculate the length, to calculate the # of interpolations that will be necessary
@@ -457,17 +457,17 @@ void moveStep() {
457457
double rot,left, right;
458458

459459
// Find target angle for the step, and write it
460-
uarm.calAngles(x_array[currentStep], y_array[currentStep], z_array[currentStep], rot, left, right);
460+
uarm.coordinate_to_angle(x_array[currentStep], y_array[currentStep], z_array[currentStep], rot, left, right);
461461

462462

463-
uarm.writeAngle(rot, left, right, currentHand);
463+
uarm.write_servo_angle(rot, left, right, currentHand);
464464
currentStep += 1;
465465

466466

467467
if (currentStep == INTERP_INTVLS) {
468468
// Make the final move, to ensure arrival to the final destination.
469-
uarm.calAngles(x_array[INTERP_INTVLS], y_array[INTERP_INTVLS], z_array[INTERP_INTVLS], rot, left, right);
470-
uarm.writeAngle(rot, left, right, currentHand);
469+
uarm.coordinate_to_angle(x_array[INTERP_INTVLS], y_array[INTERP_INTVLS], z_array[INTERP_INTVLS], rot, left, right);
470+
uarm.write_servo_angle(rot, left, right, currentHand);
471471
currentStep = 255;
472472
}
473-
}
473+
}

examples/movement/movement.ino

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -152,82 +152,81 @@ void alert(byte beeps) {
152152
}
153153

154154
void move_home_position(float time) {
155-
uarm.moveToOpts(0, -21, 20, 90, F_ABSOLUTE, time, PATH_ANGLES, INTERP_EASE_INOUT);
155+
uarm.move_to(0, -21, 20, 90, F_ABSOLUTE, time, PATH_ANGLES, INTERP_EASE_INOUT,true);
156156
}
157157

158158
void many_xyz_start_points(bool recalc_servos) {
159159
// detaching the servos after each move forces the cache to be recalculated, generating the errors
160160
// this mimics the previous behavior where positions were always recalculated between moves
161161
if (recalc_servos) {
162-
uarm.detachAll();
162+
uarm.detach_all_servos();
163163
}
164-
uarm.moveToOpts(-14, -19, 20, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT);
164+
uarm.move_to(-14, -19, 20, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT, true);
165165
if (recalc_servos) {
166-
uarm.detachAll();
166+
uarm.detach_all_servos();
167167
}
168168
delay(500);
169-
uarm.moveToOpts(-7, -26, 14, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT);
169+
uarm.move_to(-7, -26, 14, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT,true);
170170
if (recalc_servos) {
171-
uarm.detachAll();
171+
uarm.detach_all_servos();
172172
}
173173
delay(500);
174-
uarm.moveToOpts(0, -19, 20, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT);
174+
uarm.move_to(0, -19, 20, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT,true);
175175
if (recalc_servos) {
176-
uarm.detachAll();
176+
uarm.detach_all_servos();
177177
}
178178
delay(500);
179-
uarm.moveToOpts(7, -26, 14, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT);
179+
uarm.move_to(7, -26, 14, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT,true);
180180
if (recalc_servos) {
181-
uarm.detachAll();
181+
uarm.detach_all_servos();
182182
}
183183
delay(500);
184-
uarm.moveToOpts(14, -19, 20, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT);
184+
uarm.move_to(14, -19, 20, 90, F_ABSOLUTE, .5, PATH_ANGLES, INTERP_EASE_INOUT,true);
185185
if (recalc_servos) {
186-
uarm.detachAll();
186+
uarm.detach_all_servos();
187187
}
188188
delay(500);
189189
}
190190

191191
void path_moves(byte path_type) {
192192
// PATH_LINEAR creates a linear path between the start end and point
193193
// PATH_ANGLES instead interpolates the start and ending servos positions
194-
uarm.moveToOpts(-7, -14, 10, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT);
194+
uarm.move_to(-7, -14, 10, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT,true);
195195
delay(500);
196-
uarm.moveToOpts(15, -26, 20, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT);
196+
uarm.move_to(15, -26, 20, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT,true);
197197
delay(500);
198-
uarm.moveToOpts(-15, -26, 20, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT);
198+
uarm.move_to(-15, -26, 20, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT,true);
199199
delay(500);
200-
uarm.moveToOpts(7, -14, 10, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT);
200+
uarm.move_to(7, -14, 10, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT,true);
201201
delay(500);
202-
uarm.moveToOpts(0, -21, 20, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT);
202+
uarm.move_to(0, -21, 20, 90, F_ABSOLUTE, 1, path_type, INTERP_EASE_INOUT,true);
203203
}
204204

205205
void ease_moves(byte ease_type) {
206-
uarm.moveToOpts(-10, -26, 15, 90, F_ABSOLUTE, 1, PATH_ANGLES, INTERP_EASE_INOUT);
206+
uarm.move_to(-10, -26, 15, 90, F_ABSOLUTE, 1, PATH_ANGLES, INTERP_EASE_INOUT,true);
207207
delay(750);
208-
uarm.moveToOpts(10, -26, 15, 90, F_ABSOLUTE, .75, PATH_ANGLES, ease_type);
208+
uarm.move_to(10, -26, 15, 90, F_ABSOLUTE, .75, PATH_ANGLES, ease_type,true);
209209
delay(500);
210-
uarm.moveToOpts(10, -14, 15, 90, F_ABSOLUTE, .75, PATH_ANGLES, ease_type);
210+
uarm.move_to(10, -14, 15, 90, F_ABSOLUTE, .75, PATH_ANGLES, ease_type,true);
211211
delay(500);
212-
uarm.moveToOpts(-10, -14, 15, 90, F_ABSOLUTE, .75, PATH_ANGLES, ease_type);
212+
uarm.move_to(-10, -14, 15, 90, F_ABSOLUTE, .75, PATH_ANGLES, ease_type,true);
213213
delay(500);
214-
uarm.moveToOpts(-10, -26, 15, 90, F_ABSOLUTE, .75, PATH_ANGLES, ease_type);
214+
uarm.move_to(-10, -26, 15, 90, F_ABSOLUTE, .75, PATH_ANGLES, ease_type,true);
215215
delay(750);
216-
uarm.moveToOpts(0, -21, 20, 90, F_ABSOLUTE, 1, PATH_ANGLES, INTERP_EASE_INOUT);
216+
uarm.move_to(0, -21, 20, 90, F_ABSOLUTE, 1, PATH_ANGLES, INTERP_EASE_INOUT,true);
217217
}
218218

219219
void hand_moves(byte relative) {
220220
// F_HAND_ROT_REL will keep the hand orientation contstant through a move
221-
uarm.moveToOpts(-15, -15, 12, relative ? 0 : 90, relative, 1, PATH_ANGLES, INTERP_EASE_INOUT);
221+
uarm.move_to(-15, -15, 12, relative ? 0 : 90, relative, 1, PATH_ANGLES, INTERP_EASE_INOUT,true);
222222
delay(500);
223-
uarm.moveToOpts(-15, -15, 8, relative ? 0 : 90, relative, .5, PATH_ANGLES, INTERP_EASE_INOUT);
223+
uarm.move_to(-15, -15, 8, relative ? 0 : 90, relative, .5, PATH_ANGLES, INTERP_EASE_INOUT,true);
224224
delay(500);
225-
uarm.moveToOpts(-15, -15, 17, relative ? 0 : 90, relative, .5, PATH_ANGLES, INTERP_EASE_INOUT);
225+
uarm.move_to(-15, -15, 17, relative ? 0 : 90, relative, .5, PATH_ANGLES, INTERP_EASE_INOUT,true);
226226
delay(500);
227-
uarm.moveToOpts(15, -15, 17, relative ? 0 : 90, relative, 2, PATH_ANGLES, INTERP_EASE_INOUT);
227+
uarm.move_to(15, -15, 17, relative ? 0 : 90, relative, 2, PATH_ANGLES, INTERP_EASE_INOUT,true);
228228
delay(500);
229-
uarm.moveToOpts(15, -15, 8, relative ? 0 : 90, relative, .5, PATH_ANGLES, INTERP_EASE_INOUT);
229+
uarm.move_to(15, -15, 8, relative ? 0 : 90, relative, .5, PATH_ANGLES, INTERP_EASE_INOUT,true);
230230
delay(500);
231-
uarm.moveToOpts(0, -21, 20, 90, F_ABSOLUTE, 1, PATH_ANGLES, INTERP_EASE_INOUT);
231+
uarm.move_to(0, -21, 20, 90, F_ABSOLUTE, 1, PATH_ANGLES, INTERP_EASE_INOUT,true);
232232
}
233-

uarm_library.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,16 @@ class uArmClass
183183
void pump_on();
184184
void pump_off();
185185

186+
int write_servo_angle(byte servo_rot_angle, byte servo_left_angle, byte servo_right_angle, byte servo_hand_rot_angle, byte trigger);
187+
int write_servo_angle(double servo_rot_angle, double servo_left_angle, double servo_right_angle, double servo_hand_rot_angle);
188+
int write_servo_angle(double servo_rot_angle, double servo_left_angle, double servo_right_angle);
189+
186190
Servo g_servo_rot;
187191
Servo g_servo_left;
188192
Servo g_servo_right;
189193
Servo g_servo_hand_rot;
190194
Servo g_servo_hand;
195+
unsigned int INTERP_INTVLS;
191196

192197
protected:
193198
double cur_rot;
@@ -201,11 +206,9 @@ class uArmClass
201206
double g_current_z;
202207

203208
boolean g_gripper_reset;
204-
unsigned int INTERP_INTVLS;
209+
205210
private:
206-
int write_servo_angle(byte servo_rot_angle, byte servo_left_angle, byte servo_right_angle, byte servo_hand_rot_angle, byte trigger);
207-
int write_servo_angle(double servo_rot_angle, double servo_left_angle, double servo_right_angle, double servo_hand_rot_angle);
208-
int write_servo_angle(double servo_rot_angle, double servo_left_angle, double servo_right_angle);
211+
209212
void attach_all();
210213
void attach_servo(byte servo_num);
211214
};

0 commit comments

Comments
 (0)