Carlo Collodi / kangaroo

Dependencies:   QEI mbed

Committer:
calamaridudeman
Date:
Sun Nov 24 19:04:01 2013 +0000
Revision:
28:21773a6fb6df
Parent:
26:53b793b7a82f
Child:
29:33c5c61f1068
Child:
35:a4e89e78d034
Motor class is wrong, but motor encoders work so far

Who changed what in which revision?

UserRevisionLine numberNew contents of line
calamaridudeman 21:a9569c7b4379 1 #include "mbed.h"
calamaridudeman 23:112c0be5a7f3 2 #include "include/dynamics.hpp"
calamaridudeman 25:8a34b8d6cc6e 3 #include "include/motor.hpp"
calamaridudeman 16:c21df8c0c458 4
calamaridudeman 28:21773a6fb6df 5 Kangaroo::Kangaroo(Motor &M1, Motor &M2, QEI &e1, QEI &e2):enc1(e1),enc2(e2),m1(M1),m2(M2){
calamaridudeman 25:8a34b8d6cc6e 6
calamaridudeman 25:8a34b8d6cc6e 7 }
calamaridudeman 25:8a34b8d6cc6e 8
calamaridudeman 26:53b793b7a82f 9 void Kangaroo::zero(){
calamaridudeman 25:8a34b8d6cc6e 10 m1.setVel(-.002);//wait for the legs to go to stopping points
calamaridudeman 25:8a34b8d6cc6e 11 m2.setVel(-.002);
calamaridudeman 25:8a34b8d6cc6e 12 wait(1);
calamaridudeman 25:8a34b8d6cc6e 13
calamaridudeman 25:8a34b8d6cc6e 14 m1.zero();
calamaridudeman 25:8a34b8d6cc6e 15 m2.zero();
calamaridudeman 25:8a34b8d6cc6e 16
calamaridudeman 25:8a34b8d6cc6e 17 enc1.reset();
calamaridudeman 25:8a34b8d6cc6e 18 enc2.reset();
calamaridudeman 25:8a34b8d6cc6e 19
calamaridudeman 25:8a34b8d6cc6e 20 while((enc1.getRevolutions()==0)&&(enc2.getRevolutions()==0)){
calamaridudeman 25:8a34b8d6cc6e 21 wait(0.1);
calamaridudeman 25:8a34b8d6cc6e 22 }
calamaridudeman 25:8a34b8d6cc6e 23
calamaridudeman 25:8a34b8d6cc6e 24
calamaridudeman 26:53b793b7a82f 25 }
calamaridudeman 26:53b793b7a82f 26
calamaridudeman 28:21773a6fb6df 27 void Kangaroo::testEncoders(Serial &pc){
calamaridudeman 28:21773a6fb6df 28 //pc.printf("hello world\n");
calamaridudeman 26:53b793b7a82f 29
calamaridudeman 28:21773a6fb6df 30 pc.printf("motor1: %i\n",m1.getPos());
calamaridudeman 28:21773a6fb6df 31 pc.printf("clix1: %i, rots1: %i\n",enc1.getPulses(), enc1.getRevolutions());
calamaridudeman 28:21773a6fb6df 32
calamaridudeman 28:21773a6fb6df 33 pc.printf("motor2: %i\n",m2.getPos());
calamaridudeman 28:21773a6fb6df 34 pc.printf("clix2: %i, rots2: %i\n",enc2.getPulses(), enc2.getRevolutions());
calamaridudeman 25:8a34b8d6cc6e 35 }