Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MeArm_Lab2_Task1 by
Revision 3:13f56160c56e, committed 2017-07-04
- Comitter:
- eencae
- Date:
- Tue Jul 04 18:11:30 2017 +0000
- Parent:
- 2:2494cdc6977a
- Commit message:
- Initial commit
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jul 04 16:44:47 2017 +0000
+++ b/main.cpp Tue Jul 04 18:11:30 2017 +0000
@@ -1,4 +1,4 @@
-/* MeArm Lab 2 Task 1
+/* MeArm Lab 3 Task 1
(c) Dr Craig A. Evans, University of Leeds
@@ -12,8 +12,6 @@
// create MeArm object - middle, left, right, claw
MeArm arm(p21,p22,p23,p24);
-AnalogIn m_pot(p17);
-
int main()
{
// open , closed
@@ -23,21 +21,42 @@
arm.set_right_calibration_values(2000,1000);
arm.set_left_calibration_values(1870,850);
-
+ // x stays constant
+ float x = 140.0;
+
+ // arrays to store values in trajectory
+ float y[20];
+ float z[20];
+
+ // loop through points in array
+ for(int i = 0; i < 20; i++) {
+ // this will create values in the range -100 to 100
+ y[i] = -100.0 + (200.0*i)/(20-1);
+ // scaled parabola - z = (y/10)^2 + 50
+ z[i] = pow(y[i]/10.0,2.0)+50;
+ // print to Cool Term to check - can plot in Excel
+ printf("%f , %f\n",y[i],z[i]);
+ }
+
while(1) {
+
+ // loop through each point from y=-100 to 100
+ // and move the arm to each point
+ for(int i = 0; i < 20; i++) {
+ arm.goto_xyz(x,y[i],z[i]);
+ // small delay before moving to next point
+ wait_ms(50);
+ }
- // create x value in range 100 to 200 mm
- float x = 100.0 + 100.0*m_pot.read();
- float y = 0.0;
- float z = 100.0;
- float claw_val = 1.0; // 0.0 to 1.0
+ // then loop back in the opposite direction
+ for(int i = 18; i > 0; i--) {
+ arm.goto_xyz(x,y[i],z[i]);
+ // small delay before moving to next point
+ wait_ms(50);
+ }
- arm.set_claw(claw_val);
- // move to co-ordinate
- arm.goto_xyz(x,y,z);
-
- wait(0.2);
+ // the loop then restarts so the arm will go back and forth along the trajectory
}
-
+
}
\ No newline at end of file
