Robot.cpp
Go to the documentation of this file.
1 //=============================================================================
2 // Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3 // Author: Gonzalo Mier
4 // BSD-3 License
5 //=============================================================================
6 
7 
9 
10 namespace f2c::types {
11 
12 Robot::Robot(double width, double cov_width,
13  double max_curv, double max_diff_curv) :
14  width_(width), cov_width_(cov_width),
15  max_icc_(max_curv), linear_curv_change_(max_diff_curv) {
16  if (width <= 0.0 || cov_width < 0.0) {
17  throw std::out_of_range("Robot widths have to be greater than 0.");
18  }
19  if (cov_width == 0.0) {
20  this->cov_width_ = this->width_;
21  }
22 }
23 
24 Robot::Robot() = default;
25 Robot::~Robot() = default;
26 Robot::Robot(const Robot&) = default;
27 Robot::Robot(Robot &&) = default;
28 Robot& Robot::operator=(const Robot&) = default;
29 Robot& Robot::operator=(Robot&&) = default;
30 
31 
32 
33 std::string Robot::getName() const {
34  return this->name_;
35 }
36 
37 void Robot::setName(const std::string& str) {
38  this->name_ = str;
39 }
40 
41 double Robot::getWidth() const {
42  return this->width_;
43 }
44 
45 void Robot::setWidth(double w) {
46  this->width_ = w;
47 }
48 
49 double Robot::getCovWidth() const {
50  return this->cov_width_;
51 }
52 
53 void Robot::setCovWidth(double w) {
54  this->cov_width_ = w;
55 }
56 
57 double Robot::getCruiseVel() const {
58  return this->cruise_speed_;
59 }
60 
61 void Robot::setCruiseVel(double v) {
62  this->cruise_speed_ = v;
63 }
64 
65 double Robot::getTurnVel() const {
66  return this->turn_vel_ ? *this->turn_vel_ : this->cruise_speed_;
67 }
68 
69 void Robot::setTurnVel(double v) {
70  this->turn_vel_ = v;
71 }
72 
74  return 1. / (this->max_icc_ + 1e-7);
75 }
76 
77 void Robot::setMinTurningRadius(double rad) {
78  this->max_icc_ = 1.0 / (fabs(rad) + 1e-7);
79 }
80 
81 double Robot::getMaxCurv() const {
82  return this->max_icc_;
83 }
84 
85 void Robot::setMaxCurv(double c) {
86  this->max_icc_ = fabs(c);
87 }
88 
89 double Robot::getMaxDiffCurv() const {
90  return this->linear_curv_change_;
91 }
92 
93 void Robot::setMaxDiffCurv(double dc) {
94  this->linear_curv_change_ = fabs(dc);
95 }
96 
97 } // namespace f2c::types
98 
Robot.h
f2c::types
Types used by fields2cover library.
Definition: Cell.h:20
f2c::types::Robot::getName
std::string getName() const
Definition: Robot.cpp:33
f2c::types::Robot::getMaxDiffCurv
double getMaxDiffCurv() const
Definition: Robot.cpp:89
f2c::types::Robot::getCovWidth
double getCovWidth() const
Definition: Robot.cpp:49
f2c::types::Robot::setName
void setName(const std::string &str)
Definition: Robot.cpp:37
f2c::types::Robot::Robot
Robot()
f2c::types::Robot::setMaxCurv
void setMaxCurv(double)
Definition: Robot.cpp:85
f2c::types::Robot::cov_width_
double cov_width_
Width of the coverage area of the robot.
Definition: Robot.h:66
f2c::types::Robot::getTurnVel
double getTurnVel() const
Definition: Robot.cpp:65
f2c::types::Robot::~Robot
~Robot()
f2c::types::Robot::setWidth
void setWidth(double)
Definition: Robot.cpp:45
f2c::types::Robot::cruise_speed_
double cruise_speed_
Velocity of the robot when not doing turns.
Definition: Robot.h:69
f2c::types::Robot::linear_curv_change_
double linear_curv_change_
Maximum linear curvature change.
Definition: Robot.h:75
2_objective_functions.width
float width
Definition: 2_objective_functions.py:29
f2c::types::Robot::getMaxCurv
double getMaxCurv() const
Definition: Robot.cpp:81
f2c::types::Robot::operator=
Robot & operator=(const Robot &)
f2c::types::Robot::getMinTurningRadius
double getMinTurningRadius() const
Definition: Robot.cpp:73
f2c::types::Robot::turn_vel_
std::optional< double > turn_vel_
Velocity of the robot when doing turns. If not set, cruise_speed_ is used.
Definition: Robot.h:78
f2c::types::Robot::setMaxDiffCurv
void setMaxDiffCurv(double)
Definition: Robot.cpp:93
f2c::types::Robot::width_
double width_
Width of the robot.
Definition: Robot.h:64
f2c::types::Robot::setMinTurningRadius
void setMinTurningRadius(double rad)
Definition: Robot.cpp:77
f2c::types::Robot::setCovWidth
void setCovWidth(double)
Definition: Robot.cpp:53
f2c::types::Robot
Definition: Robot.h:25
f2c::types::Robot::setCruiseVel
void setCruiseVel(double)
Definition: Robot.cpp:61
f2c::types::Robot::setTurnVel
void setTurnVel(double)
Definition: Robot.cpp:69
f2c::types::Robot::getCruiseVel
double getCruiseVel() const
Definition: Robot.cpp:57
f2c::types::Robot::getWidth
double getWidth() const
Definition: Robot.cpp:41
f2c::types::Robot::max_icc_
double max_icc_
Maximum instantaneous curvature change.
Definition: Robot.h:72
f2c::types::Robot::name_
std::string name_
Definition: Robot.h:61


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31