]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blobdiff - incl/bcar.hh
Add front track, refine mtr computation
[hubacji1/bcar.git] / incl / bcar.hh
index 1ca3a7a0306dd52791546bee5c21abbe651e5351..c24334fc52585090614381ef0c9684466daee0cb 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
@@ -58,6 +64,12 @@ public:
         */
        bool on_right_side_of(Line const& li) const;
 
+       /*! \brief Translate self.
+        *
+        * \param p `Point` offset to translate by.
+        */
+       void translate(Point const& p);
+
        /*! \brief Rotate self around the point.
 
        \param c Rotation center `Point`.
@@ -65,9 +77,16 @@ public:
        */
        void rotate(Point const& c, double const angl);
 
+       /*! \brief Compute reflection of `this` around the `Line`.
+        *
+        * \param li The plane to reflect around is given by `li`.
+        */
+       void reflect(Line const& li);
+
        /*! Return Euclidean distance to `p`. */
        double edist(Point const& p) const;
 
+       bool operator==(Point const& p);
        friend std::ostream& operator<<(std::ostream& out, Point const& p);
 };
 
@@ -86,6 +105,9 @@ public:
        /*! Get end point. */
        Point e() const&;
 
+       /*! Get middle point. */
+       Point m() const;
+
        /*! Get intersection point. */
        Point i1() const&;
 
@@ -117,6 +139,8 @@ public:
 
        double len() const;
 
+       double h() const;
+
        friend std::ostream& operator<<(std::ostream& out, Line const& li);
 };
 
@@ -139,27 +163,33 @@ public:
 
        void rotate(Point const& c, double const angl);
 
+       void reflect(Line const& li);
+
+       bool operator==(Pose const& p);
        friend std::ostream& operator<<(std::ostream& out, Pose const& p);
 };
 
 class PoseRange : public virtual Pose {
 private:
-       double e_ = 0.0;
-       using Pose::h;
+       Pose bp_;
+       Pose ep_;
+       void set_xyh();
 public:
+       PoseRange(Pose bp, Pose ep);
+       PoseRange(double x, double y, double b, double e);
+
+       Pose bp() const;
+       Pose ep() const;
+
        /*! Get heading's begin in the interval [-pi, +pi] radians. */
        double b() const;
 
-       /*! Set heading's begin in radians. It's recomputed to [-pi, +pi]. */
-       void b(double b);
-
        /*! Get heading's end in the interval [-pi, +pi] radians. */
        double e() const;
 
-       /*! Set heading's end in radians. It's recomputed to [-pi, +pi]. */
-       void e(double e);
-
+       void translate(Point const& p);
        void rotate(Point const& c, double const angl);
+       void reflect(Line const& li);
 
        friend std::ostream& operator<<(std::ostream& out, PoseRange const& p);
 };
@@ -175,6 +205,7 @@ private:
        double wheelbase_ = 2.450;
        double distance_to_front_ = 3.105;
        double length_ = 3.760;
+       double _front_track = 1.625;
 public:
        /*! Get curb-to-curb distance. */
        double ctc() const;
@@ -209,6 +240,12 @@ 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_,
@@ -283,10 +320,10 @@ class BicycleCar : public virtual Pose, public virtual CarSize,
                public virtual CarMove {
 private:
 public:
-       /*! \brief Return `false` if `bc` is not achievable.
+       /*! \brief Return `true` if `this` can drive to `p` trivially.
         *
-        * When `false` is returned the `bc` may still be drivable, but not
-        * trivially, i.e. by "line segment - circle arc - line segment".
+        * Trivially means that `this` can drive to `p` by line segment - circle
+        * arc - line segment.
         *
         * \param p `PoseRange` (resp. `Pose`) to achieve.
         */