diff --git a/beacon.cc b/beacon.cc index 653eb7f..bd6f1a9 100644 --- a/beacon.cc +++ b/beacon.cc @@ -6,17 +6,20 @@ #include "random.hh" #include "vec_3d.hh" +using namespace std; + // Authors: Anastasios Zochios, Pavlos Tziranis -beacon::beacon(std::string name, vec_3d location, double localError = 0.05, - double rangeError) - : name(name), - location(location), - localError(localError), - rangeError(rangeError) {} +beacon::beacon(string name, double x, double y, double z) + : name(name), location(vec_3d(x, y, z)) {} + +// outputs the estimated location of the beacon updated with a normally +// distrubuted error with mean=0 & std.dev = 2 +void beacon::estimate_loc() { + vec_3d error(N(0, 2), N(0, 2), N(0, 2)); + estlocation = location + error; +} -// beacon::double detect_object(double power); -/* Adding a scalar to a vector; vec_3d operator+ needs to initialize a scalar as - * vector */ -friend ostream& operator<<(ostream& s, beacon a) { - return s << a.name << a.location + a.localError; \ No newline at end of file +ostream& operator<<(ostream& s, beacon a) { + return s << a.name << a.location + a.localError; +} \ No newline at end of file diff --git a/beacon.hh b/beacon.hh index cd0bf0f..1815dc1 100644 --- a/beacon.hh +++ b/beacon.hh @@ -3,19 +3,22 @@ #include #include +#include "random.hh" #include "vec_3d.hh" class beacon { private: std::string name; - vec_3d location; // the real location of the beacon in the simulation (ground truth) - vec_3d estlocation; // the location the beacon believes it is in (with error, as in real life) - double localError; - double rangeError; + vec_3d location; // the real location of the beacon in the simulation (ground + // truth) + vec_3d estlocation; // the location the beacon believes it is in (with error, + // as in real life) + // double localError; + // double rangeError; + void estimate_loc(); public: - beacon(std::string name, vec_3d location, double localError, - double rangeError); + beacon(std::string name, vec_3d location); friend std::ostream& operator<<(std::ostream& s, beacon a); }; diff --git a/quadcopter.cc b/quadcopter.cc new file mode 100644 index 0000000..5b46c07 --- /dev/null +++ b/quadcopter.cc @@ -0,0 +1,31 @@ +#include "quadcopter.cc" + +class quadcopter : public robot { + public: + quadcopter(double x = 0, + double y = 0, double z = 0, double hvar, double vvar, double hdg, double speed, double battlife) + : robot(vec_3d(x, y, z), hvar, vvar, hdg, speed, battlife) {}; + + void loc_change(double dx, double dy, double dz); + + void setThrottle(double h); + + void setRaw(double r); + + void setPitch(double p); + + void setYaw(double w); + + void setAirSpeed(double s); + + void update(double dt); + + friend ostream& operator <<(ostream& s, const quadcopter& a); + + private: + double throttle; + double raw; + double pitch; + double yaw; + double airSpeed; +}; diff --git a/quadcopter.hh b/quadcopter.hh index cec5044..225b8aa 100644 --- a/quadcopter.hh +++ b/quadcopter.hh @@ -4,26 +4,31 @@ #include #include "robot.hh" -using namespace std; class quadcopter : public robot { public: - quadcopter(const string& name, double x, double y, double z) : name(name), x(x), y(y), z(z) {} -class quadcopter{ - public: - quadcopter(const string& name, double x = 0, double y = 0, double z = 0) {} + quadcopter(double x, double y, double z, double hvar, double vvar, double hdg, double speed, double battlife); + void loc_change(double dx, double dy, double dz); + void setThrottle(double h); + void setRaw(double r); + void setPitch(double p); + void setYaw(double w); + void setAirSpeed(double s); + void update(double dt); friend ostream& operator <<(ostream& s, const quadcopter& a); -} + private: - string name; - double x, y, z; - double throttle, raw, pitch, yaw, airSpeed; + double throttle; + double raw; + double pitch; + double yaw; + double airSpeed; };