31 if (INI_FILE !=
nullptr) initialize(*INI_FILE);
36 options.loadFromConfigFile(INI_FILE, getConfigFileSectionName());
40 options.saveToConfigFile(
c, getConfigFileSectionName());
48 const auto ptg = getAssociatedPTG();
49 const double ptg_ref_dist = ptg ? ptg->getRefDistance() : 1.0;
52 no.
logRecord = mrpt::make_aligned_shared<CLogFileRecord_VFF>();
60 const double inc_ang = 2 *
M_PI /
n;
61 double ang = -
M_PI + 0.5 * inc_ang;
62 for (
size_t i = 0; i <
n; i++, ang += inc_ang)
69 instantaneousForce.x = -cos(ang) * mod;
70 instantaneousForce.y = -sin(ang) * mod;
71 resultantForce += instantaneousForce;
75 const double obstcl_weight = 20.0 / ni.
obstacles.size();
76 resultantForce *= obstcl_weight;
78 const double obstacleNearnessFactor =
79 std::min(1.0, 6.0 / resultantForce.norm());
83 const auto trg = *ni.
targets.rbegin();
85 const double ang = atan2(trg.y, trg.x);
86 const double mod = options.TARGET_ATTRACTIVE_FORCE;
92 : atan2(resultantForce.y, resultantForce.x);
96 if (m_enableApproachTargetSlowDown)
98 const double targetNearnessFactor =
std::min(
100 (options.TARGET_SLOW_APPROACHING_DISTANCE / ptg_ref_dist));
103 std::min(obstacleNearnessFactor, targetNearnessFactor);
113 out << options.TARGET_ATTRACTIVE_FORCE
114 << options.TARGET_SLOW_APPROACHING_DISTANCE;
123 in >> options.TARGET_ATTRACTIVE_FORCE >>
124 options.TARGET_SLOW_APPROACHING_DISTANCE;
137 void CLogFileRecord_VFF::writeToStream(
168 CHolonomicVFF::TOptions::TOptions()
169 : TARGET_SLOW_APPROACHING_DISTANCE(0.10), TARGET_ATTRACTIVE_FORCE(20.0)
180 TARGET_SLOW_APPROACHING_DISTANCE,
double,
source, section);
192 TARGET_SLOW_APPROACHING_DISTANCE,
"For stopping gradually");
194 TARGET_ATTRACTIVE_FORCE,
195 "Dimension-less (may have to be tuned depending on the density of " 196 "obstacle sampling)");
A holonomic reactive navigation method, based on Virtual Force Fields (VFF).
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg, const std::string §ion) const override
This method saves the options to a ".ini"-like file or memory-stored string list. ...
A class for storing extra information about the execution of CHolonomicVFF navigation.
A base class for holonomic reactive navigation methods.
This class allows loading and storing values and vectors of different types from a configuration text...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
A base class for log records for different holonomic navigation methods.
double desiredDirection
The desired motion direction, in the range [-PI, PI].
CHolonomicLogFileRecord::Ptr logRecord
The navigation method will create a log record and store it here via a smart pointer.
GLsizei const GLchar ** string
IMPLEMENTS_SERIALIZABLE(CHolonomicVFF, CAbstractHolonomicReactiveMethod, mrpt::nav) CHolonomicVFF
double desiredSpeed
The desired motion speed in that direction, from 0 up to NavInput::maxRobotSpeed. ...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLsizei GLsizei GLchar * source
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
#define MRPT_LOAD_CONFIG_VAR( variableName, variableType, configFileObject, sectionNameStr)
An useful macro for loading variables stored in a INI-like file under a key with the same name that t...
Output for CAbstractHolonomicReactiveMethod::navigate()