Carlo Collodi / kangaroo

Dependencies:   QEI mbed

src/dynamics.cpp

Committer:
calamaridudeman
Date:
2013-11-24
Revision:
29:33c5c61f1068
Parent:
28:21773a6fb6df
Child:
30:18724a8fb2bf

File content as of revision 29:33c5c61f1068:

#include "mbed.h"
#include "include/dynamics.hpp"
#include "include/motor.hpp"

Kangaroo::Kangaroo(Motor &M1, Motor &M2, QEI &e1, QEI &e2):enc1(e1),enc2(e2),m1(M1),m2(M2){
    
}

void Kangaroo::zero(){
    m1.setVel(-.002);//wait for the legs to go to stopping points
    m2.setVel(-.002);
    wait(1);
    
    m1.zero();
    m2.zero();
    
    enc1.reset();
    enc2.reset();
    
    while((enc1.getRevolutions()==0)&&(enc2.getRevolutions()==0)){
        wait(0.1);
    }
    
    
}

void Kangaroo::testEncoders(Serial &pc){
    //pc.printf("hello world\n");
    
    //pc.printf("motor1:  %i\n",m1.getPos());
    pc.printf("clix1:  %i, rots1: %i\n",enc1.getPulses(), enc1.getRevolutions());
    
    //pc.printf("motor2:  %i\n",);
    pc.printf("clix2:  %i, rots2: %i\n",enc2.getPulses(), enc2.getRevolutions());
}