From 723373ed4fd8e39bca855a6322fa871faa6a44f0 Mon Sep 17 00:00:00 2001 From: Jiri Vlasak Date: Tue, 13 Jul 2021 16:30:06 +0200 Subject: [PATCH] Move methods from bicycle car to car size --- incl/bcar.hh | 66 +++++++++++++++++++++++++------------------------- src/bcar.cc | 68 ++++++++++++++++++++++++++-------------------------- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/incl/bcar.hh b/incl/bcar.hh index e35f964..9f7a369 100644 --- a/incl/bcar.hh +++ b/incl/bcar.hh @@ -216,6 +216,39 @@ public: * radius. */ double mtr() const; + + /*! \brief Return inner radius. + * + * The inner radius is the distance from minimum turning radius circle + * center to the nearest point on the car. In this case, the nearest + * points on the car are rear axle endpoints. + */ + double iradi() const; + + /*! \brief Return outer front radius. + * + * The outer front radius is the distance from minimum turning radius + * circle center to the farthest point on the front (from the rear axle + * view) part of the car. + */ + double ofradi() const; + + /*! \brief Return outer rear radius. + * + * The outer rear radius is the distance from minimum turning radius + * circle center to the farthest point on the rear (from the rear axle + * view) part of the car. + */ + double orradi() const; + + /*! \brief Return length of perfect parking slot. + * + * The width of the slot is the same as the width of the car. + * + * \see Simon R. Blackburn *The Geometry of Perfect Parking* + * \see https://www.ma.rhul.ac.uk/SRBparking + */ + double perfect_parking_slot_len() const; }; /*! Store car motion. */ @@ -254,39 +287,6 @@ public: bool drivable(PoseRange const& p) const; bool drivable(Pose const& p) const; - /*! \brief Return inner radius. - * - * The inner radius is the distance from minimum turning radius circle - * center to the nearest point on the car. In this case, the nearest - * points on the car are rear axle endpoints. - */ - double iradi() const; - - /*! \brief Return outer front radius. - * - * The outer front radius is the distance from minimum turning radius - * circle center to the farthest point on the front (from the rear axle - * view) part of the car. - */ - double ofradi() const; - - /*! \brief Return outer rear radius. - * - * The outer rear radius is the distance from minimum turning radius - * circle center to the farthest point on the rear (from the rear axle - * view) part of the car. - */ - double orradi() const; - - /*! \brief Return length of perfect parking slot. - * - * The width of the slot is the same as the width of the car. - * - * \see Simon R. Blackburn *The Geometry of Perfect Parking* - * \see https://www.ma.rhul.ac.uk/SRBparking - */ - double perfect_parking_slot_len() const; - /*! Set maximum steering angle. */ void set_max_steer(); diff --git a/src/bcar.cc b/src/bcar.cc index 6b264c9..ef7300e 100644 --- a/src/bcar.cc +++ b/src/bcar.cc @@ -373,6 +373,40 @@ CarSize::mtr() const return sqrt(ctc2 - wb2) - this->w() / 2.0; } +double +CarSize::iradi() const +{ + return this->mtr() - this->w() / 2; +} + +double +CarSize::ofradi() const +{ + auto mtrw2 = pow(this->mtr() + this->w() / 2.0, 2.0); + auto df2 = pow(this->df(), 2.0); + return sqrt(mtrw2 + df2); +} + +double +CarSize::orradi() const +{ + auto mtrw2 = pow(this->mtr() + this->w() / 2.0, 2.0); + auto dr2 = pow(this->dr(), 2.0); + return sqrt(mtrw2 + dr2); +} + +double +CarSize::perfect_parking_slot_len() const +{ + auto r = this->ctc() / 2.0; + auto l = this->wb(); + auto k = this->df() - this->wb(); + auto w = this->w(); + auto r2l2 = r * r - l * l; + auto s = r2l2 + pow(l + k, 2.0) - pow(sqrt(r2l2) - w, 2.0); + return this->len() + sqrt(s) - l - k; +} + double CarMove::sp() const { @@ -493,40 +527,6 @@ BicycleCar::drivable(PoseRange const& p) const return false; } -double -BicycleCar::iradi() const -{ - return this->mtr() - this->w() / 2; -} - -double -BicycleCar::ofradi() const -{ - auto mtrw2 = pow(this->mtr() + this->w() / 2.0, 2.0); - auto df2 = pow(this->df(), 2.0); - return sqrt(mtrw2 + df2); -} - -double -BicycleCar::orradi() const -{ - auto mtrw2 = pow(this->mtr() + this->w() / 2.0, 2.0); - auto dr2 = pow(this->dr(), 2.0); - return sqrt(mtrw2 + dr2); -} - -double -BicycleCar::perfect_parking_slot_len() const -{ - auto r = this->ctc() / 2.0; - auto l = this->wb(); - auto k = this->df() - this->wb(); - auto w = this->w(); - auto r2l2 = r * r - l * l; - auto s = r2l2 + pow(l + k, 2.0) - pow(sqrt(r2l2) - w, 2.0); - return this->len() + sqrt(s) - l - k; -} - void BicycleCar::set_max_steer() { -- 2.39.2