38 lines
731 B
C++
38 lines
731 B
C++
#include <iostream>
|
|
|
|
#include "Thing.h"
|
|
#include "Things/DifferentialDrive.h"
|
|
#include "Things/TouchSensor.h"
|
|
|
|
using namespace RoboidControl;
|
|
|
|
void CollisionSteering();
|
|
|
|
DifferentialDrive* bb2b = nullptr;
|
|
TouchSensor* touchLeft = nullptr;
|
|
TouchSensor* touchRight = nullptr;
|
|
|
|
int main() {
|
|
bb2b = new DifferentialDrive();
|
|
|
|
touchLeft = new TouchSensor(bb2b);
|
|
touchRight = new TouchSensor(bb2b);
|
|
|
|
while (true) {
|
|
CollisionSteering();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void CollisionSteering() {
|
|
if (touchLeft->touchedSomething)
|
|
bb2b->SetRightWheelVelocity(-0.5f);
|
|
else
|
|
bb2b->SetRightWheelVelocity(0.5f);
|
|
|
|
if (touchRight->touchedSomething)
|
|
bb2b->SetLeftWheelVelocity(-0.5f);
|
|
else
|
|
bb2b->SetLeftWheelVelocity(0.5f);
|
|
} |