Crazyflie compatibility

This commit is contained in:
Pascal Serrarens 2023-12-06 09:59:35 +01:00
parent a7020364d1
commit 733a09ce91
6 changed files with 33 additions and 6 deletions

View File

@ -3,6 +3,8 @@
#include "DistanceSensor.h"
#include "Switch.h"
#include <math.h>
Perception::Perception() {}
Perception::Perception(Placement* sensors, unsigned int sensorCount) {
@ -209,7 +211,8 @@ Sensor* Perception::GetSensor(float angle) {
for (unsigned int ix = 0; ix < this->sensorCount; ix++) {
Placement placement = this->sensorPlacements[ix];
if (abs(placement.horizontalDirection - angle) < 0.01F)
float delta = placement.horizontalDirection - angle;
if (delta > -0.01F && delta < 0.01F)
return (Sensor*)placement.thing;
}

View File

@ -2,8 +2,6 @@
#include "FloatSingle.h"
#include <Arduino.h>
Propulsion::Propulsion() {
this->placement = nullptr;
this->motorCount = 0;
@ -57,7 +55,9 @@ void Propulsion::Update(float currentTimeMs) {
}
void Propulsion::SetMaxSpeed(float maxSpeed) {
this->maxSpeed = abs(maxSpeed);
if (maxSpeed < 0)
maxSpeed = 0;
this->maxSpeed = maxSpeed;
}
void Propulsion::SetTwistSpeed(float forward, float yaw) {}

View File

@ -1,5 +1,4 @@
#include "Roboid.h"
#include <Arduino.h>
Roboid::Roboid() {}

7
Switch.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <Switch.h>
Switch::Switch() {}
bool Switch::IsOn() {
return false;
}

18
Switch.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
#include "Sensor.h"
namespace Passer {
namespace RoboidControl {
/// @brief A digital switch input
class Switch : public Sensor {
public:
/// @brief Default constructor
Switch();
virtual bool IsOn();
};
} // namespace RoboidControl
} // namespace Passer

@ -1 +1 @@
Subproject commit 006ea046e4bb57b033823ba5a3fad0dfc7f5dfba
Subproject commit 493a3f748907b4fb7e64177f94b7cb98a951af4c