30 if (INI_FILE !=
nullptr) initialize(*INI_FILE);
35 options.loadFromConfigFile(INI_FILE, getConfigFileSectionName());
39 options.saveToConfigFile(
c, getConfigFileSectionName());
47 const auto ptg = getAssociatedPTG();
48 const double ptg_ref_dist = ptg ? ptg->getRefDistance() : 1.0;
51 no.
logRecord = std::make_shared<CLogFileRecord_VFF>();
59 const double inc_ang = 2 *
M_PI /
n;
60 double ang = -
M_PI + 0.5 * inc_ang;
61 for (
size_t i = 0; i <
n; i++, ang += inc_ang)
68 instantaneousForce.x = -cos(ang) * mod;
69 instantaneousForce.y = -sin(ang) * mod;
70 resultantForce += instantaneousForce;
74 const double obstcl_weight = 20.0 / ni.
obstacles.size();
75 resultantForce *= obstcl_weight;
77 const double obstacleNearnessFactor =
78 std::min(1.0, 6.0 / resultantForce.norm());
82 const auto trg = *ni.
targets.rbegin();
84 const double ang = atan2(trg.y, trg.x);
85 const double mod = options.TARGET_ATTRACTIVE_FORCE;
91 : atan2(resultantForce.y, resultantForce.x);
95 if (m_enableApproachTargetSlowDown)
97 const double targetNearnessFactor =
std::min(
99 (options.TARGET_SLOW_APPROACHING_DISTANCE / ptg_ref_dist));
102 std::min(obstacleNearnessFactor, targetNearnessFactor);
106 uint8_t CHolonomicVFF::serializeGetVersion()
const {
return 0; }
109 out << options.TARGET_ATTRACTIVE_FORCE
110 << options.TARGET_SLOW_APPROACHING_DISTANCE;
112 void CHolonomicVFF::serializeFrom(
119 in >> options.TARGET_ATTRACTIVE_FORCE >>
120 options.TARGET_SLOW_APPROACHING_DISTANCE;
128 uint8_t CLogFileRecord_VFF::serializeGetVersion()
const {
return 0; }
133 void CLogFileRecord_VFF::serializeFrom(
151 CHolonomicVFF::TOptions::TOptions()
155 void CHolonomicVFF::TOptions::loadFromConfigFile(
162 TARGET_SLOW_APPROACHING_DISTANCE,
double,
source, section);
168 void CHolonomicVFF::TOptions::saveToConfigFile(
174 TARGET_SLOW_APPROACHING_DISTANCE,
"For stopping gradually");
176 TARGET_ATTRACTIVE_FORCE,
177 "Dimension-less (may have to be tuned depending on the density of " 178 "obstacle sampling)");
A holonomic reactive navigation method, based on Virtual Force Fields (VFF).
A class for storing extra information about the execution of CHolonomicVFF navigation.
A base class for holonomic reactive navigation methods.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define ASSERT_(f)
Defines an assertion mechanism.
This class allows loading and storing values and vectors of different types from a configuration text...
A base class for log records for different holonomic navigation methods.
double desiredDirection
The desired motion direction, in the range [-PI, PI].
mrpt::config::CConfigFileBase CConfigFileBase
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. ...
#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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
GLsizei GLsizei GLchar * source
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
Output for CAbstractHolonomicReactiveMethod::navigate()
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.