![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
These are the core files for the Robot at Team conception.
Brobot.cpp
- Committer:
- obrie829
- Date:
- 2017-05-29
- Revision:
- 8:351b0b7b05b2
- Parent:
- 0:eba74e7a229b
- Child:
- 11:05d5539141c8
- Child:
- 15:4efc66de795a
File content as of revision 8:351b0b7b05b2:
/* * BROBOT.cpp * */ #include <cmath> #include "Brobot.h" #include "SpeedControl.h" SpeedControl speedctrl(PwmOut* pwmLeft, PwmOut* pwmRight, EncoderCounter* counterLeft, EncoderCounter* counterRight); Brobot::Brobot(SpeedControl* speedctrl, int number) { this->number = number; //this->speedctrl = speedctrl; } void Brobot::rotate( float phi) { if(phi>0.5f || phi<-0.5f) { phi=0; } *pwmL = 0.5f + phi; *pwmR = 0.5f + phi; } /* void Brobot::setWheelSpeeds( float wheelL, float wheelR) { SpeedCtrl.setDesiredSpeed( wheelL, wheelR); } */ void Brobot::forward() { //*pwmL=0.65f; // asterisk is dereferencing the pointer so //*pwmR=0.36f; // you can access the variable at the pointers address // also another way to dereference the pointer is: pwmR->write(0.xx) speedctrl->setDesiredSpeed(0.65f, 0.35f); } void Brobot::slow(float scale) { if(scale>0.5f || scale<-0.5f) { scale=0; } *pwmL = *pwmL - scale; *pwmR = *pwmR + scale; } void Brobot::turnleft() { speedctrl->setDesiredSpeed(0.48f, 0.31f); wait(0.1); } void Brobot::turnright() { speedctrl->setDesiredSpeed(0.69f, 0.52f); wait(0.1); } void Brobot::back() { speedctrl->setDesiredSpeed(0.65f, 0.35f); } void Brobot::stop() { speedctrl->setDesiredSpeed(0.5f, 0.5f); }