]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blobdiff - incl/bcar.hh
Add inner/outer mirror radius computation
[hubacji1/bcar.git] / incl / bcar.hh
index e1a17ddad9e32bd5e7e8ef98680aa4ccd1668989..d6b764cb64e9814d43e8183e13874f44f0f0e6cb 100644 (file)
@@ -1,3 +1,9 @@
+/*
+ * SPDX-FileCopyrightText: 2021 Jiri Vlasak <jiri.vlasak.2@cvut.cz>
+ *
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
 /*! \file */
 #ifndef BCAR_BCAR_H
 #define BCAR_BCAR_H
@@ -15,8 +21,8 @@ class Line;
 
 class Point {
 private:
-       double x_ = 0.0;
-       double y_ = 0.0;
+       double _x = 0.0;
+       double _y = 0.0;
 public:
        Point();
        Point(double x, double y);
@@ -80,16 +86,19 @@ public:
        /*! Return Euclidean distance to `p`. */
        double edist(Point const& p) const;
 
+       /*! Generate output for plotting with gnuplot. */
+       void gen_gnuplot_to(std::ostream& out);
+
        bool operator==(Point const& p);
        friend std::ostream& operator<<(std::ostream& out, Point const& p);
 };
 
 class Line {
 private:
-       Point b_;
-       Point e_;
-       Point i1_;
-       Point i2_;
+       Point _b;
+       Point _e;
+       Point _i1;
+       Point _i2;
 public:
        Line(Point const& fp, Point const& lp);
 
@@ -141,7 +150,7 @@ public:
 /*! Store coordinates `x`, `y`, and heading `h`. */
 class Pose : public virtual Point {
 private:
-       double h_ = 0.0;
+       double _h = 0.0;
 public:
        using Point::Point;
        Pose(double x, double y, double h);
@@ -165,8 +174,8 @@ public:
 
 class PoseRange : public virtual Pose {
 private:
-       Pose bp_;
-       Pose ep_;
+       Pose _bp;
+       Pose _ep;
        void set_xyh();
 public:
        PoseRange(Pose bp, Pose ep);
@@ -190,15 +199,17 @@ public:
 
 /*! \brief Store car size.
  *
- * - Default is https://en.wikipedia.org/wiki/Fiat_Punto
+ * - The default is Renault ZOE (www.car.info)
  */
 class CarSize {
 private:
-       double curb_to_curb_ = 10.820;
-       double width_ = 1.625;
-       double wheelbase_ = 2.450;
-       double distance_to_front_ = 3.105;
-       double length_ = 3.760;
+       double _curb_to_curb = 10.802166641822163;
+       double _width_with_mirrors = 1.945;
+       double _width = 1.771;
+       double _wheelbase = 2.588;
+       double _distance_to_front = 3.427;
+       double _length = 4.084;
+       double _front_track = 1.511;
 public:
        /*! Get curb-to-curb distance. */
        double ctc() const;
@@ -218,6 +229,12 @@ public:
        /*! Set width. */
        void w(double w);
 
+       /*! Get width with mirrors. */
+       double wwm() const;
+
+       /*! Set width with mirrors. */
+       void wwm(double w);
+
        /*! Get length. */
        double len() const;
 
@@ -233,15 +250,21 @@ public:
        /*! Get distance from rear axle to rear. */
        double dr() const;
 
+       /*! Set front track. */
+       void ft(double ft);
+
+       /*! Get front track. */
+       double ft() const;
+
        /*! \brief Get minimum turning radius.
         *
         * Please, note that the method returns really _minimum turning radius_,
         * which is the distance from the rear axle center to the center of
         * left or right rotation given by the kinematics constrants, i.e.
-        * _wheelbase_ and _curb-to-curb_ distance.
+        * _wheelbase and _curb-to-curb_ distance.
         *
-        * Sometimes _minimum turning radius_ is not radius, not minimum, or not
-        * turning. In this method, _minimum turning radius_ is minimum turning
+        * Sometimes _minimum turning _radius is not radius, not minimum, or not
+        * turning. In this method, _minimum turning _radius is minimum turning
         * radius.
         */
        double mtr() const;
@@ -270,6 +293,20 @@ public:
         */
        double orradi() const;
 
+       /*! \brief Return inner mirror radius.
+        *
+        * The inner mirror radius is the distance from minimum turning radius
+        * circle center to the farther mirror (from the rear axle view).
+        */
+       double imradi() const;
+
+       /*! \brief Return outer mirror radius.
+        *
+        * The outer mirror radius is the distance from minimum turning radius
+        * circle center to the farther mirror (from the rear axle view).
+        */
+       double omradi() const;
+
        /*! \brief Return length of perfect parking slot.
         *
         * The width of the slot is the same as the width of the car.
@@ -283,8 +320,8 @@ public:
 /*! Store car motion. */
 class CarMove {
 private:
-       double speed_ = 0.0;
-       double steer_ = 0.0;
+       double _speed = 0.0;
+       double _steer = 0.0;
 public:
        /*! Get speed. */
        double sp() const;
@@ -368,17 +405,68 @@ public:
        /*! Get frame's front side. */
        Line front() const;
 
-       /*! Get rear axle's left x coordinate. */
-       double ralx() const;
+       /*! Get frame's left rear axle x coordinate. */
+       double lrax() const;
+
+       /*! Get frame's left rear axle y coordinate. */
+       double lray() const;
+
+       /*! Get frame's right rear axle x coordinate. */
+       double rrax() const;
 
-       /*! Get rear axle's left y coordinate. */
-       double raly() const;
+       /*! Get frame's right rear axle y coordinate. */
+       double rray() const;
 
-       /*! Get rear axle's right x coordinate. */
-       double rarx() const;
+       /*! Get frame's left rear axle point. */
+       Point lra() const;
 
-       /*! Get rear axle's right y coordinate. */
-       double rary() const;
+       /*! Get frame's right rear axle point. */
+       Point rra() const;
+
+       /*! Get frame's left front axle x coordinate. */
+       double lfax() const;
+
+       /*! Get frame's left front axle y coordinate. */
+       double lfay() const;
+
+       /*! Get frame's right front axle x coordinate. */
+       double rfax() const;
+
+       /*! Get frame's right front axle y coordinate. */
+       double rfay() const;
+
+       /*! Get iframe's left front axle point. */
+       Point lfa() const;
+
+       /*! Get frame's right front axle point. */
+       Point rfa() const;
+
+       /*! Get frame's left front mirror x coordinate. */
+       double lfmx() const;
+
+       /*! Get frame's left front mirror y coordinate. */
+       double lfmy() const;
+
+       /*! Get frame's right front mirror x coordinate. */
+       double rfmx() const;
+
+       /*! Get frame's right front mirror y coordinate. */
+       double rfmy() const;
+
+       /*! Get iframe's left front mirror point. */
+       Point lfm() const;
+
+       /*! Get frame's right front mirror point. */
+       Point rfm() const;
+
+       /*! Get frame's center front x coordinate. */
+       double cfx() const;
+
+       /*! Get frame's center front y coordinate. */
+       double cfy() const;
+
+       /*! Get frame's center front point. */
+       Point cf() const;
 
        /*! Min. turning radius circle center on left. */
        Point ccl() const;
@@ -388,6 +476,26 @@ public:
 
        /*! Next car position based on speed `sp` and steer `st`. */
        void next();
+
+       /*! Options for generating output for gnuplot. */
+       class GenPlotOpts {
+       public:
+               static bool LEFT;
+               static bool RIGHT;
+               static bool REAR;
+               static bool FRONT;
+               static bool FRAME;
+               static bool ARROW;
+               static bool CROSS;
+               static bool CAR;
+               static bool LEFT_MIRROR;
+               static bool RIGHT_MIRROR;
+               static bool MIRRORS;
+               static bool ALL;
+       };
+
+       /*! Generate output for plotting with gnuplot. */
+       void gen_gnuplot_to(std::ostream& out, GenPlotOpts const& opts);
 };
 
 } // namespace bcar