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 = mrpt::make_aligned_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()
152 : TARGET_SLOW_APPROACHING_DISTANCE(0.10), TARGET_ATTRACTIVE_FORCE(20.0)
163 TARGET_SLOW_APPROACHING_DISTANCE,
double,
source, section);
175 TARGET_SLOW_APPROACHING_DISTANCE,
"For stopping gradually");
177 TARGET_ATTRACTIVE_FORCE,
178 "Dimension-less (may have to be tuned depending on the density of "
179 "obstacle sampling)");