Debian Codegraph @

libs/kinematics/src/CVehicleVelCmd.cpp

raw
1 /* +------------------------------------------------------------------------+
2 | Mobile Robot Programming Toolkit (MRPT) |
3 | https://www.mrpt.org/ |
4 | |
5 | Copyright (c) 2005-2026, Individual contributors, see AUTHORS file |
6 | See: https://www.mrpt.org/Authors - All rights reserved. |
7 | Released under BSD License. See: https://www.mrpt.org/License |
8 +------------------------------------------------------------------------+ */
9
10 #include "kinematics-precomp.h" // Precompiled header
11 //
12 #include <mrpt/kinematics/CVehicleVelCmd.h>
13 #include <mrpt/serialization/CArchive.h>
14
15 using namespace mrpt::kinematics;
16
17 IMPLEMENTS_VIRTUAL_SERIALIZABLE(CVehicleVelCmd, CSerializable, mrpt::kinematics)
18
19 CVehicleVelCmd::CVehicleVelCmd() = default;
20 CVehicleVelCmd::CVehicleVelCmd(const CVehicleVelCmd& other) { *this = other; }
21 CVehicleVelCmd::~CVehicleVelCmd() = default;
22 std::string mrpt::kinematics::CVehicleVelCmd::asString() const
23 {
24 std::string s;
25 s += "(";
26 for (size_t i = 0; i < getVelCmdLength(); i++)
27 {
28 s += mrpt::format("%s=%.03f ", getVelCmdDescription(i).c_str(), getVelCmdElement(i));
29 }
30 s += ")";
31 return s;
32 }
33
34 CVehicleVelCmd& CVehicleVelCmd::operator=(const CVehicleVelCmd& other)
35 {
36 const size_t nThis = this->getVelCmdLength();
37 ASSERTMSG_(typeid(*this) == typeid(other), "Trying to copy incompatible classes");
38 for (size_t i = 0; i < nThis; i++) this->setVelCmdElement(i, other.getVelCmdElement(i));
39 return *this;
40 }
41
42 void CVehicleVelCmd::TVelCmdParams::loadConfigFile(
43 const mrpt::config::CConfigFileBase& cfg, const std::string& section)
44 {
45 MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(robotMax_V_mps, double, cfg, section);
46 MRPT_LOAD_HERE_CONFIG_VAR_DEGREES_NO_DEFAULT(
47 robotMax_W_degps, double, robotMax_W_radps, cfg, section);
48 MRPT_LOAD_CONFIG_VAR(robotMinCurvRadius, double, cfg, section);
49 }
50
51 void CVehicleVelCmd::TVelCmdParams::saveToConfigFile(
52 mrpt::config::CConfigFileBase& c, const std::string& s) const
53 {
54 MRPT_SAVE_CONFIG_VAR_COMMENT(
55 robotMax_V_mps,
56 "Max. linear speed (m/s) [Default=-1 (not set), will raise exception "
57 "if needed and not set]");
58 MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT(
59 "robotMax_W_degps", robotMax_W_radps,
60 "Max. angular speed (deg/s) [Default=-1 (not set), will raise "
61 "exception if needed and not set]");
62 MRPT_SAVE_CONFIG_VAR_COMMENT(
63 robotMinCurvRadius,
64 "Min. radius of curvature of paths (m) [Default=-1 (not set), will "
65 "raise exception if needed and not set]");
66 }
67
68 CVehicleVelCmd::TVelCmdParams::TVelCmdParams() = default;