diff --git a/Perception.cpp b/Perception.cpp index 3ddc5d2..d0ac6d0 100644 --- a/Perception.cpp +++ b/Perception.cpp @@ -131,7 +131,7 @@ float Perception::GetDistance(float fromAngle, float toAngle) { if (thing->type == Thing::DistanceSensorType) { DistanceSensor* distanceSensor = (DistanceSensor*)thing; - if (distanceSensor != nullptr && distanceSensor->IsOn()) + if (distanceSensor != nullptr && distanceSensor->ObjectNearby()) minDistance = fmin(minDistance, distanceSensor->GetDistance()); } } @@ -161,7 +161,7 @@ float Perception::GetDistance(float fromHorizontalAngle, if (thing->type == Thing::DistanceSensorType) { DistanceSensor* distanceSensor = (DistanceSensor*)thing; - if (distanceSensor != nullptr && distanceSensor->IsOn()) + if (distanceSensor != nullptr && distanceSensor->ObjectNearby()) minDistance = fmin(minDistance, distanceSensor->GetDistance()); } } @@ -194,4 +194,3 @@ bool Perception::ObjectNearby(float fromAngle, float toAngle) { } return false; } - diff --git a/Quadcopter.cpp b/Quadcopter.cpp new file mode 100644 index 0000000..af04794 --- /dev/null +++ b/Quadcopter.cpp @@ -0,0 +1,38 @@ +#include "Quadcopter.h" + +Quadcopter::Quadcopter() {} + +void Quadcopter::SetTwistSpeed(float forward, float yaw) { + this->velocity = Vector3::forward * forward; + this->yawSpeed = yaw; +} + +void Quadcopter::SetTwistSpeed(Vector2 linear, float yaw) { + this->velocity = Vector3(linear.x, 0.0F, linear.y); + this->yawSpeed = yaw; +} + +void Quadcopter::SetTwistSpeed(Vector3 velocity, + float yaw, + float pitch, + float roll) { + this->velocity = velocity; + this->yawSpeed = yaw; + this->rollSpeed = roll; + this->pitchSpeed = pitch; +} + +Vector3 Quadcopter::GetTargetVelocity() { + return this->velocity; +} + +float Quadcopter::GetPitchSpeed() { + return this->pitchSpeed; +} + +float Quadcopter::GetYawSpeed() { + return this->yawSpeed; +} +float Quadcopter::GetRollSpeed() { + return this->rollSpeed; +} diff --git a/Quadcopter.h b/Quadcopter.h new file mode 100644 index 0000000..6c7b212 --- /dev/null +++ b/Quadcopter.h @@ -0,0 +1,37 @@ +#pragma once + +#include "Propulsion.h" +#include "Thing.h" +#include "Vector3.h" + +namespace Passer { +namespace RoboidControl { + +/// @brief Support for Quadcopter as a propulsion method +class Quadcopter : public Propulsion { + public: + /// @brief Default constuctor + Quadcopter(); + + virtual void SetTwistSpeed(float forward, float yaw = 0.0F) override; + virtual void SetTwistSpeed(Vector2 linear, float yaw = 0.0F) override; + virtual void SetTwistSpeed(Vector3 linear, + float yaw = 0.0F, + float pitch = 0.0F, + float roll = 0.0F) override; + + Vector3 GetTargetVelocity(); + float GetYawSpeed(); + float GetPitchSpeed(); + float GetRollSpeed(); + + protected: + Vector3 velocity = Vector3::zero; + float pitchSpeed = 0.0F; + float yawSpeed = 0.0F; + float rollSpeed = 0.0F; +}; + +} // namespace RoboidControl +} // namespace Passer +using namespace Passer::RoboidControl; \ No newline at end of file