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.
Dependents: kinematics_controlv4 kinematics_control_copyfds Robot_control
Revision 0:9c61094ffaac, committed 2017-10-31
- Comitter:
- peterknoben
- Date:
- Tue Oct 31 14:34:37 2017 +0000
- Child:
- 1:03e2651b4a24
- Commit message:
- fsdaf
Changed in this revision
| Movement.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Movement.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Movement.cpp Tue Oct 31 14:34:37 2017 +0000
@@ -0,0 +1,138 @@
+#include "Movement.h"
+#include "mbed.h"
+
+float movement;
+
+Movement::Movement(void)
+{
+
+}
+
+int * Movement::getdirection(int mode){
+//int *getdirection(int direction[2]){
+ static int direction[2];
+ if(mode==1){
+ direction[0]=1;
+ direction[1]=1;
+ }
+ else if(mode==2){
+ direction[0]=1;
+ direction[1]=-1;
+ }
+ else if(mode==3){
+ //servo
+ }
+ else if(mode==4){
+ direction[0]=-1;
+ direction[1]=-1;
+ }
+ else if(mode==5){
+ direction[0]=-1;
+ direction[1]=1;
+ }
+ else if(mode==6){
+ //servo
+ }
+ else{
+ //Error, unavailable mode
+ }
+ return direction;
+}
+
+
+float Movement::getposition(int SignalNumber, int mode, int side, float max_range){
+ static float position; //Define a position array
+ int *direction_math; //Define a useable direction array in this function
+ direction_math = getdirection(mode); //Fill the useable direction array
+ float position_math;
+ switch(SignalNumber){
+ case 1: //Move slowest
+ movement = direction_math[side] *1;
+ position_math = position + movement;
+ if (position_math >= max_range && position_math <=0){
+ position = position;
+ }
+ else{
+ position += movement;
+ }
+ break;
+ case 2: //Move slow
+ movement = direction_math[side] *2;
+ position_math = position + movement;
+ if (position_math >= max_range && position_math <=0){
+ position = position;
+ }
+ else{
+ position += movement;
+ }
+ break;
+ case 3: //Move fast
+ movement = direction_math[side] *5;
+ position_math = position + movement;
+ if (position_math >= max_range && position_math <=0){
+ position = position;
+ }
+ else{
+ position += movement;
+ }
+ break;
+ case 4: //Move fastest
+ movement = direction_math[side] *10;
+ position_math = position + movement;
+ if (position_math >= max_range && position_math <=0){
+ position = position;
+ }
+ else{
+ position += movement;
+ }
+ break;
+ default : //if something is wrong or no muscles are flexed, standstill
+ position = position;
+ break;
+ }
+ return position;
+}
+
+
+
+
+
+/*
+float *Movement::getposition(int SignalNumber, int mode){
+ static float position[2]; //Define a position array
+ int *direction_math; //Define a useable direction array in this function
+ direction_math = getdirection(mode); //Fill the useable direction array
+ switch(SignalNumber){
+ case 1: //Move slowest
+ xmovement = direction_math[0] * 1; //mm
+ ymovement = direction_math[1] * 1; //mm
+ position[0] += xmovement;
+ position[1] += ymovement;
+ break;
+ case 2: //Move slow
+ xmovement = direction_math[0] * 2; //mm
+ ymovement = direction_math[1] * 2; //mm
+ position[0] += xmovement;
+ position[1] += ymovement;
+ break;
+ case 3: //Move fast
+ xmovement = direction_math[0] * 5; //mm
+ ymovement = direction_math[1] * 5; //mm
+ position[0] += xmovement;
+ position[1] += ymovement;
+ break;
+ case 4: //Move fastest
+ xmovement = direction_math[0] * 10; //mm
+ ymovement = direction_math[1] * 10; //mm
+ position[0] += xmovement;
+ position[1] += ymovement;
+ break;
+ default : //if something is wrong or no muscles are flexed, standstill
+ position[0] = position[0];
+ position[1] = position[1];
+ break;
+ }
+ return position;
+}
+*/
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Movement.h Tue Oct 31 14:34:37 2017 +0000
@@ -0,0 +1,21 @@
+#ifndef _MOVEMENT_H_INCLUDED_
+#define _MOVEMENT_H_INCLUDED_
+
+#include "mbed.h"
+
+class Movement
+{
+public:
+ /**
+ *Constructor
+ */
+ Movement(void);
+
+ int *getdirection(int mode);
+
+ float getposition(int SignalNumber, int mode, int side, float max_range);
+
+private:
+
+};
+#endif
\ No newline at end of file