Fixed quadcopter support
This commit is contained in:
parent
938bd7ceda
commit
2d5b3998d7
@ -131,7 +131,7 @@ float Perception::GetDistance(float fromAngle, float toAngle) {
|
|||||||
|
|
||||||
if (thing->type == Thing::DistanceSensorType) {
|
if (thing->type == Thing::DistanceSensorType) {
|
||||||
DistanceSensor* distanceSensor = (DistanceSensor*)thing;
|
DistanceSensor* distanceSensor = (DistanceSensor*)thing;
|
||||||
if (distanceSensor != nullptr && distanceSensor->IsOn())
|
if (distanceSensor != nullptr && distanceSensor->ObjectNearby())
|
||||||
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ float Perception::GetDistance(float fromHorizontalAngle,
|
|||||||
|
|
||||||
if (thing->type == Thing::DistanceSensorType) {
|
if (thing->type == Thing::DistanceSensorType) {
|
||||||
DistanceSensor* distanceSensor = (DistanceSensor*)thing;
|
DistanceSensor* distanceSensor = (DistanceSensor*)thing;
|
||||||
if (distanceSensor != nullptr && distanceSensor->IsOn())
|
if (distanceSensor != nullptr && distanceSensor->ObjectNearby())
|
||||||
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
minDistance = fmin(minDistance, distanceSensor->GetDistance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,4 +194,3 @@ bool Perception::ObjectNearby(float fromAngle, float toAngle) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
Quadcopter.cpp
Normal file
38
Quadcopter.cpp
Normal file
@ -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;
|
||||||
|
}
|
37
Quadcopter.h
Normal file
37
Quadcopter.h
Normal file
@ -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;
|
Loading…
x
Reference in New Issue
Block a user