steer_to_path.hpp
Go to the documentation of this file.
1 //=============================================================================
2 // Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3 // Author: Gonzalo Mier
4 // BSD-3 License
5 //=============================================================================
6 
7 #pragma once
8 #ifndef FIELDS2COVER_PATH_PLANNING_STEER_TO_PATH_HPP_
9 #define FIELDS2COVER_PATH_PLANNING_STEER_TO_PATH_HPP_
10 
11 #include <vector>
12 #include "steering_functions/steering_functions.hpp"
13 #include "fields2cover/types.h"
14 
15 
16 namespace f2c::pp {
17 
18 
22  const std::vector<steer::State>& curve, double const_vel) {
24  auto compute_dist = [&curve](int i) {
25  return ((i + 1 < curve.size()) ?
26  F2CPoint(curve[i].x, curve[i].y).distance(
27  F2CPoint(curve[i + 1].x, curve[i + 1].y)) : 0);
28  };
29  for (size_t i = 0; i < curve.size(); ++i) {
31  state.point = F2CPoint(curve[i].x, curve[i].y);
32  state.angle = curve[i].theta;
33  state.velocity = const_vel;
34  state.len = compute_dist(i);
35  state.dir = static_cast<types::PathDirection>(curve[i].d);
37  path.addState(state);
38  }
39  return path;
40 }
41 
42 // Function loop_detected contributed by Phact (https://phact.nl/) company
43 inline bool loop_detected(const std::vector<steer::Control>& controls) {
44  double drTotal = 0;
45  double drAbsTotal = 0;
46  for (auto&& c : controls) {
47  if (c.kappa != 0) {
48  double dr = 0.5 * c.delta_s * c.kappa / M_PI;
49  if (fabs(dr) > 0.9) {
50  return true;
51  }
52  drTotal += dr;
53  drAbsTotal += fabs(dr);
54  }
55  }
56  return (fabs(drTotal) > 0.9) || (drAbsTotal > 1.5);
57 }
58 // Function loop_detected contributed by Phact (https://phact.nl/) company
59 
60 
61 
62 } // namespace f2c::pp
63 
64 #endif // FIELDS2COVER_PATH_PLANNING_STEER_TO_PATH_HPP_
f2c::types::PathDirection
PathDirection
Definition: PathState.h:21
f2c::pp::steerStatesToPath
types::Path steerStatesToPath(const std::vector< steer::State > &curve, double const_vel)
Definition: steer_to_path.hpp:21
f2c::pp
Path planning algorithms' namespace.
Definition: dubins_curves.h:14
types.h
2_objective_functions.path
path
Definition: 2_objective_functions.py:88
f2c::types::PathState::point
Point point
Definition: PathState.h:28
f2c::types::PathState::type
PathSectionType type
Definition: PathState.h:32
f2c::types::PathState::dir
PathDirection dir
Definition: PathState.h:31
f2c::types::PathState
Definition: PathState.h:27
f2c::types::Path
Definition: Path.h:23
f2c::pp::loop_detected
bool loop_detected(const std::vector< steer::Control > &controls)
Definition: steer_to_path.hpp:43
f2c::types::PathSectionType::TURN
@ TURN
f2c::types::Geometry::distance
double distance(const Geometry< T2, R2 > &p) const
Compute shortest distance between this and another geometry.
Definition: Geometry_impl.hpp:139
f2c::types::PathState::len
double len
Definition: PathState.h:30
f2c::types::PathState::angle
double angle
Definition: PathState.h:29
f2c::types::PathState::velocity
double velocity
Definition: PathState.h:33
F2CPoint
f2c::types::Point F2CPoint
Definition: types.h:38


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31