Main MRPT website > C++ reference for MRPT 1.9.9
CPTG_RobotShape_Circular.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "nav-precomp.h" // Precomp header
11 
15 #include <mrpt/core/round.h>
17 
18 using namespace mrpt::nav;
19 
22 void CPTG_RobotShape_Circular::setRobotShapeRadius(const double robot_radius)
23 {
24  m_robotRadius = robot_radius;
26 }
27 
30  const mrpt::config::CConfigFileBase& cfg, const std::string& sSection)
31 {
32  const double old_R = m_robotRadius;
34  robot_radius, double, m_robotRadius, cfg, sSection);
35 
37 }
39  mrpt::config::CConfigFileBase& cfg, const std::string& sSection) const
40 {
41  const int WN = 25, WV = 30;
42 
43  cfg.write(
44  sSection, "robot_radius", m_robotRadius, WN, WV, "Robot radius [m].");
45 }
46 
48  mrpt::opengl::CSetOfLines& gl_shape,
49  const mrpt::poses::CPose2D& origin) const
50 {
51  const double R = m_robotRadius;
52  const int N = 17;
53  // Transform coordinates:
54  mrpt::math::CVectorDouble shap_x(N), shap_y(N), shap_z(N);
55  for (int i = 0; i < N; i++)
56  {
57  origin.composePoint(
58  R * cos(i * 2 * M_PI / (N - 1)), R * sin(i * 2 * M_PI / (N - 1)), 0,
59  shap_x[i], shap_y[i], shap_z[i]);
60  }
61  // Draw a "radius" to identify the "forward" orientation (phi=0)
62  gl_shape.appendLine(
63  origin.x(), origin.y(), .0, shap_x[0], shap_y[0], shap_z[0]);
64  for (int i = 1; i <= shap_x.size(); i++)
65  {
66  const int idx = i % shap_x.size();
67  gl_shape.appendLineStrip(shap_x[idx], shap_y[idx], shap_z[idx]);
68  }
69  // Draw a "cross" to identify the robot center
70  gl_shape.appendLine(
71  origin.x() - R * 0.02, origin.y(), .0, origin.x() + R * 0.02,
72  origin.y(), .0);
73  gl_shape.appendLine(
74  origin.x(), origin.y() - R * 0.02, .0, origin.x(),
75  origin.y() + R * 0.02, .0);
76 }
77 
80 {
81  uint8_t version;
82  in >> version;
83 
84  switch (version)
85  {
86  case 0:
87  in >> m_robotRadius;
88  break;
89  default:
91  }
92 }
93 
96 {
97  uint8_t version = 0;
98  out << version;
99 
100  out << m_robotRadius;
101 }
102 
104 {
105  return m_robotRadius;
106 }
107 
109  const double x, const double y) const
110 {
111  return mrpt::hypot_fast(x, y) < m_robotRadius;
112 }
113 
115  const double ox, const double oy) const
116 {
117  return mrpt::hypot_fast(ox, oy) - m_robotRadius;
118 }
CSetOfLines.h
nav-precomp.h
CParameterizedTrajectoryGenerator.h
mrpt::nav::CPTG_RobotShape_Circular::m_robotRadius
double m_robotRadius
Definition: CParameterizedTrajectoryGenerator.h:573
mrpt::hypot_fast
T hypot_fast(const T x, const T y)
Faster version of std::hypot(), to use when overflow is not an issue and we prefer fast code.
Definition: core/include/mrpt/core/bits_math.h:26
mrpt::config::CConfigFileBase::write
void write(const std::string &section, const std::string &name, enum_t value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string())
Definition: config/CConfigFileBase.h:85
mrpt::nav::CPTG_RobotShape_Circular::evalClearanceToRobotShape
virtual double evalClearanceToRobotShape(const double ox, const double oy) const override
Evals the clearance from an obstacle (ox,oy) in coordinates relative to the robot center.
Definition: CPTG_RobotShape_Circular.cpp:114
mrpt::nav::CPTG_RobotShape_Circular::loadShapeFromConfigFile
void loadShapeFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string &section)
Definition: CPTG_RobotShape_Circular.cpp:29
mrpt::math::dynamic_vector
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
Definition: eigen_frwds.h:44
mrpt::nav::CPTG_RobotShape_Circular::setRobotShapeRadius
void setRobotShapeRadius(const double robot_radius)
Robot shape must be set before initialization, either from ctor params or via this method.
Definition: CPTG_RobotShape_Circular.cpp:22
mrpt::nav::CPTG_RobotShape_Circular::~CPTG_RobotShape_Circular
virtual ~CPTG_RobotShape_Circular()
Definition: CPTG_RobotShape_Circular.cpp:21
mrpt::opengl::CSetOfLines
A set of independent lines (or segments), one line with its own start and end positions (X,...
Definition: CSetOfLines.h:33
mrpt::nav::CPTG_RobotShape_Circular::internal_processNewRobotShape
virtual void internal_processNewRobotShape()=0
Will be called whenever the robot shape is set / updated.
mrpt::nav
Definition: CAbstractHolonomicReactiveMethod.h:23
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
R
const float R
Definition: CKinematicChain.cpp:138
mrpt::poses::CPose2D::composePoint
void composePoint(double lx, double ly, double &gx, double &gy) const
An alternative, slightly more efficient way of doing with G and L being 2D points and P this 2D pose...
Definition: CPose2D.cpp:175
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::nav::CPTG_RobotShape_Circular::saveToConfigFile
void saveToConfigFile(mrpt::config::CConfigFileBase &cfg, const std::string &sSection) const override
This method saves the options to a ".ini"-like file or memory-stored string list.
Definition: CPTG_RobotShape_Circular.cpp:38
M_PI
#define M_PI
Definition: core/include/mrpt/core/bits_math.h:38
mrpt::opengl::CSetOfLines::appendLine
void appendLine(const mrpt::math::TSegment3D &sgm)
Appends a line to the set.
Definition: CSetOfLines.h:70
mrpt::opengl::CSetOfLines::appendLineStrip
void appendLineStrip(float x, float y, float z)
Appends a line whose starting point is the end point of the last line (similar to OpenGL's GL_LINE_ST...
Definition: CSetOfLines.h:90
MRPT_LOAD_HERE_CONFIG_VAR
#define MRPT_LOAD_HERE_CONFIG_VAR( variableName, variableType, targetVariable, configFileObject, sectionNameStr)
Definition: config/CConfigFileBase.h:324
mrpt::poses::CPoseOrPoint::y
double y() const
Definition: CPoseOrPoint.h:144
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::poses::CPose2D
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:40
mrpt::poses::CPoseOrPoint::x
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:140
round.h
mrpt::nav::CPTG_RobotShape_Circular::loadDefaultParams
void loadDefaultParams() override
Loads a set of default parameters; provided exclusively for the PTG-configurator tool.
Definition: CPTG_RobotShape_Circular.cpp:28
mrpt::nav::CPTG_RobotShape_Circular::isPointInsideRobotShape
bool isPointInsideRobotShape(const double x, const double y) const override
Returns true if the point lies within the robot shape.
Definition: CPTG_RobotShape_Circular.cpp:108
mrpt::nav::CPTG_RobotShape_Circular::getMaxRobotRadius
double getMaxRobotRadius() const override
Returns an approximation of the robot radius.
Definition: CPTG_RobotShape_Circular.cpp:103
mrpt::nav::CPTG_RobotShape_Circular::internal_shape_saveToStream
void internal_shape_saveToStream(mrpt::serialization::CArchive &out) const
Definition: CPTG_RobotShape_Circular.cpp:94
mrpt::nav::CPTG_RobotShape_Circular::add_robotShape_to_setOfLines
void add_robotShape_to_setOfLines(mrpt::opengl::CSetOfLines &gl_shape, const mrpt::poses::CPose2D &origin=mrpt::poses::CPose2D()) const override
Auxiliary function for rendering.
Definition: CPTG_RobotShape_Circular.cpp:47
mrpt::nav::CPTG_RobotShape_Circular::CPTG_RobotShape_Circular
CPTG_RobotShape_Circular()
Definition: CPTG_RobotShape_Circular.cpp:20
in
GLuint in
Definition: glext.h:7274
string
GLsizei const GLchar ** string
Definition: glext.h:4101
CArchive.h
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
mrpt::nav::CPTG_RobotShape_Circular::internal_shape_loadFromStream
void internal_shape_loadFromStream(mrpt::serialization::CArchive &in)
Definition: CPTG_RobotShape_Circular.cpp:78
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST