-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WheelController and allow compilation on Windows
- Loading branch information
Showing
8 changed files
with
121 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/raspberry_pi/src/car/system/movement/controller/AbstractWheelController.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef ABSTRACTWHEELCONTROLLER_CXX | ||
#define ABSTRACTWHEELCONTROLLER_CXX | ||
|
||
#pragma once | ||
|
||
#include "../../messaging/commands/MoveCommand.cxx" | ||
#include "../../messaging/commands/TurnCommand.cxx" | ||
|
||
using namespace car::system::messaging::commands; | ||
|
||
namespace car::system::movement::controller | ||
{ | ||
class AbstractWheelController | ||
{ | ||
public: | ||
virtual void initialize() = 0; | ||
|
||
virtual void move(const MoveCommand &move_command) = 0; | ||
virtual void turn(const TurnCommand &turn_command) = 0; | ||
|
||
private: | ||
}; | ||
} // namespace car::system::movement::controller | ||
|
||
#endif |
51 changes: 51 additions & 0 deletions
51
app/raspberry_pi/src/car/system/movement/controller/CarWheelController.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifdef __linux__ | ||
#ifndef CARWHEELCONTROLLER_CXX | ||
#define CARWHEELCONTROLLER_CXX | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <thread> | ||
#include <chrono> | ||
|
||
#include <PCA9685.h> | ||
|
||
#include "AbstractWheelController.cxx" | ||
|
||
#include "../wheels/FrontWheel.cxx" | ||
#include "../wheels/RearWheel.cxx" | ||
|
||
namespace car::system::movement::controller | ||
{ | ||
constexpr int MIN_PULSE_WIDTH = 900; | ||
constexpr int MAX_PULSE_WIDTH = 2100; | ||
constexpr int FREQUENCY = 50; | ||
class CarWheelController : public AbstractWheelController | ||
{ | ||
public: | ||
CarWheelController() {}; | ||
~CarWheelController() {}; | ||
|
||
void initialize() override { | ||
this->pwm->init(1, 0x40); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
this->pwm->setPWMFreq(FREQUENCY); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); | ||
} | ||
|
||
void move(const MoveCommand& move_command) override { | ||
|
||
} | ||
|
||
void turn(const TurnCommand& turn_command) override { | ||
|
||
} | ||
|
||
private: | ||
std::unique_ptr<PCA9685> pwm; | ||
|
||
}; | ||
} // namespace car::system::movement::controller | ||
|
||
#endif | ||
#endif // __linux__ |
22 changes: 22 additions & 0 deletions
22
app/raspberry_pi/src/car/system/movement/controller/DummyWheelController.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef DUMMYWHEELCONTROLLER_CXX | ||
#define DUMMYWHEELCONTROLLER_CXX | ||
|
||
#pragma once | ||
|
||
#include "AbstractWheelController.cxx" | ||
|
||
namespace car::system::movement::controller | ||
{ | ||
class DummyWheelController : public AbstractWheelController | ||
{ | ||
public: | ||
void initialize(){}; | ||
|
||
void move(const MoveCommand &move_command){}; | ||
void turn(const TurnCommand &turn_command){}; | ||
|
||
private: | ||
}; | ||
} // namespace car::system::movement::controller | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters