Skip to content

Commit 61dc85e

Browse files
committed
merge a4b64ac
2 parents de04c61 + a4b64ac commit 61dc85e

3 files changed

Lines changed: 38 additions & 67 deletions

File tree

examples/GetXYZ/GetXYZ.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ void loop() {
2222
uarm.detachAll();
2323
// assign robot coordinate to x,y,z.
2424
// unit is in centimeter
25+
uarm.calXYZ();
2526
x = uarm.getCalX(); // assign robot x - axis coordinate to value x
2627
y = uarm.getCalY();
2728
z = uarm.getCalZ();

uarm_library.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ void uArmClass::calXYZ(double theta_1, double theta_2, double theta_3)
357357
void uArmClass::calXYZ()
358358
{
359359
calXYZ(
360-
uarm.readToAngle(analogRead(2),1,0),
361-
uarm.readToAngle(analogRead(0),2,0),
362-
uarm.readToAngle(analogRead(1),3,0));
360+
uarm.readToAngle(analogRead(SERVO_ROT_ANALOG_PIN),SERVO_ROT_NUM,ABSOLUTE),
361+
uarm.readToAngle(analogRead(SERVO_LEFT_ANALOG_PIN),SERVO_LEFT_NUM,ABSOLUTE),
362+
uarm.readToAngle(analogRead(SERVO_RIGHT_ANALOG_PIN),SERVO_RIGHT_NUM,ABSOLUTE));
363363
}
364364

365365
void uArmClass::interpolate(double start_val, double end_val, double (&interp_vals)[INTERP_INTVLS], byte ease_type) {

uarm_library.h

Lines changed: 34 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ class uArmClass
102102
// void writeAngle(byte servo_rot_angle, byte servo_left_angle, byte servo_right_angle);
103103
double readAngle(byte servo_num, byte trigger);
104104

105-
// const byte kAddrOffset = 90;
106-
// const byte kAddrServo = 60;
107-
// const byte kServoRotReadPin = 2;
108-
// const byte kServoLeftReadPin = 0;
109-
// const byte kServoRightReadPin = 1;
110-
// const byte kServoHandRotReadPin = 3;
111-
112105
// Action control start
113106
void moveToOpts(double x, double y, double z, double hand_angle, byte relative_flags, double time, byte path_type, byte ease_type);
114107
void moveTo(double x, double y,double z) {moveToOpts(x, y, z, 0, F_HAND_RELATIVE, 2.0, PATH_LINEAR, INTERP_EASE_INOUT_CUBIC); }
@@ -117,70 +110,47 @@ class uArmClass
117110
void moveTo(double x, double y, double z, int relative, double time, int servo_4_relative, double servo_4_angle) { moveToOpts(x, y, z, servo_4_angle, (relative ? F_POSN_RELATIVE : 0) | (servo_4_relative ? F_HAND_RELATIVE : 0), time, PATH_LINEAR, INTERP_EASE_INOUT_CUBIC); }
118111
void moveToAtOnce(double x, double y, double z, int relative, double servo_4_angle) { moveToOpts(x, y, z, servo_4_angle, relative ? F_POSN_RELATIVE : 0, 0.0, PATH_LINEAR, INTERP_LINEAR); }
119112

120-
void drawCur(double length_1,double length_2,int angle, double time_spend);
121-
void drawRec(double length_1,double length_2,double time_spend_per_length);
113+
void drawCur(double length_1,double length_2,int angle, double time_spend);
114+
void drawRec(double length_1,double length_2,double time_spend_per_length);
122115

123-
double getTheta1() const {return g_theta_1;}
124-
double getTheta2() const {return g_theta_2;}
125-
double getTheta3() const {return g_theta_3;}
116+
double getTheta1() const {return g_theta_1;}
117+
double getTheta2() const {return g_theta_2;}
118+
double getTheta3() const {return g_theta_3;}
126119

127-
double getCalX() {calXYZ(); return g_cal_x;}
128-
double getCalY() {calXYZ(); return g_cal_y;}
129-
double getCalZ() {calXYZ(); return g_cal_z;}
130-
void getCalXYZ(double& x, double& y, double &z) {calXYZ(); x = g_cal_x; y = g_cal_y; z = g_cal_z;}
131-
void getCalXYZ(double theta_1, double theta_2, double theta_3, double& x, double& y, double &z) {calXYZ(theta_1, theta_2, theta_3); x = g_cal_x; y = g_cal_y; z = g_cal_z;}
120+
double getCalX() {return g_cal_x;}
121+
double getCalY() {return g_cal_y;}
122+
double getCalZ() {return g_cal_z;}
123+
void getCalXYZ(double& x, double& y, double &z) {calXYZ(); x = g_cal_x; y = g_cal_y; z = g_cal_z;}
124+
void getCalXYZ(double theta_1, double theta_2, double theta_3, double& x, double& y, double &z) {calXYZ(theta_1, theta_2, theta_3); x = g_cal_x; y = g_cal_y; z = g_cal_z;}
132125

133-
void calAngles(double x, double y, double z);
134-
void getCalAngles(double x, double y, double z, double& theta_1, double& theta_2, double& theta_3) {calAngles(x, y, z); theta_1 = g_theta_1; theta_2 = g_theta_2; theta_3 = g_theta_3;}
126+
void calAngles(double x, double y, double z);
127+
void getCalAngles(double x, double y, double z, double& theta_1, double& theta_2, double& theta_3) {calAngles(x, y, z); theta_1 = g_theta_1; theta_2 = g_theta_2; theta_3 = g_theta_3;}
135128

136-
void calXYZ(double theta_1, double theta_2, double theta_3);
137-
void calXYZ();
129+
void calXYZ(double theta_1, double theta_2, double theta_3);
130+
void calXYZ();
138131

139-
void gripperCatch();
140-
void gripperRelease();
141-
void interpolation(double init_val, double final_val, double (&interpol_val_array)[INTERP_INTVLS]);
142-
void interpolate(double start_val, double end_val, double (&interp_vals)[INTERP_INTVLS], byte ease_type);
143-
void pumpOn();
144-
void pumpOff();
132+
void gripperCatch();
133+
void gripperRelease();
134+
void interpolate(double start_val, double end_val, double (&interp_vals)[INTERP_INTVLS], byte ease_type);
135+
void pumpOn();
136+
void pumpOff();
145137
protected:
146-
double cur_rot;
147-
double cur_left;
148-
double cur_right;
149-
double cur_hand;
150-
// double getInterPolValueArray(int num) const {return g_interpol_val_arr[10];}
151-
double calYonly(double theta_1, double theta_2, double theta_3);
152-
153-
// double g_x_in;
154-
// double g_y_in;
155-
// double g_z_in;
156-
// double g_right_all;
157-
// double g_sqrt_z_y;
158-
double g_theta_1;
159-
double g_theta_2;
160-
double g_theta_3;
161-
// double g_phi;
162-
// double g_right_all_2;
163-
// double g_sqrt_z_x;
164-
double g_cal_x;
165-
double g_cal_y;
166-
double g_cal_z;
167-
168-
// double g_l3_1_2;
169-
// double g_l4_1_2;
170-
// double g_l5_2;
171-
172-
// double g_current_x;
173-
// double g_current_y;
174-
// double g_current_z;
175-
176-
177-
178-
// double g_l3_1;
179-
// double g_l4_1;
180-
// double g_l5;
181-
138+
double cur_rot;
139+
double cur_left;
140+
double cur_right;
141+
double cur_hand;
142+
// double getInterPolValueArray(int num) const {return g_interpol_val_arr[10];}
143+
double calYonly(double theta_1, double theta_2, double theta_3);
144+
145+
double g_theta_1;
146+
double g_theta_2;
147+
double g_theta_3;
148+
149+
double g_cal_x;
150+
double g_cal_y;
151+
double g_cal_z;
182152

183-
boolean g_gripper_reset;
153+
boolean g_gripper_reset;
184154
// action control end
185155
private:
186156
/***************** Define variables *****************/

0 commit comments

Comments
 (0)