ugv_nav4d
PreComputedMotions.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "DiscreteTheta.hpp"
4#include "Mobility.hpp"
5#include <limits>
6#include <stdexcept>
7#include <vector>
8#include <base/Pose.hpp>
9#include <maps/grid/Index.hpp>
10#include <sbpl_spline_primitives/SbplSplineMotionPrimitives.hpp>
11
12namespace ugv_nav4d
13{
14
16{
17 base::Pose2D pose;
18 maps::grid::Index cell;
19};
20
22{
23 maps::grid::Index cell;
24 std::vector<base::Pose2D> poses;
25};
26
27
28class Motion
29{
30public:
31
34 static double costScaleFactor;
35
42
43 Motion(unsigned int numAngles = 0) : endTheta(0, numAngles),startTheta(0, numAngles), baseCost(0), id(std::numeric_limits<size_t>::max()) {};
44
45 static int calculateCost(double translationalDist, double angularDist, double translationVelocity, double angularVelocity, double costMultiplier);
46
47 int xDiff;
48 int yDiff;
51
53
59 std::vector<PoseWithCell> intermediateStepsTravMap;
60
69 std::vector<CellWithPoses> fullSplineSamples;
70
71 int baseCost; //time the robot needs to follow the primivite scaled by some factors
72 int costMultiplier;//is used to scale the baseCost (can be used to punish certain motions)
73 double translationlDist; //translational length of the motion
74 double angularDist; //angular length of the motion
75
76 size_t id;
77
78};
79
81{
82 //indexed by discrete start theta
83 std::vector<std::vector<Motion> > thetaToMotion;
84 std::vector<Motion> idToMotion;
85 sbpl_spline_primitives::SbplSplineMotionPrimitives primitives;
86 Mobility mobilityConfig;
87public:
92 PreComputedMotions(const sbpl_spline_primitives::SplinePrimitivesConfig& primitiveConfig,
93 const Mobility& mobilityConfig);
94
95 void readMotionPrimitives(const sbpl_spline_primitives::SbplSplineMotionPrimitives& primGen,
96 const Mobility& mobilityConfig, double travGridResolution);
97
98 void computeMotions(double travGridResolution);
99
100 void setMotionForTheta(const Motion &motion, const DiscreteTheta &theta);
101
102 void preComputeCost(Motion &motion);
103
104 const std::vector<Motion> &getMotionForStartTheta(const DiscreteTheta &theta) const;
105
106 const Motion &getMotion(std::size_t id) const;
107
108 const sbpl_spline_primitives::SbplSplineMotionPrimitives& getPrimitives() const;
109
111 static double calculateCurvatureFromRadius(const double r);
112private:
113
114 void sampleOnResolution(double gridResolution, base::geometry::Spline2 spline, std::vector< ugv_nav4d::PoseWithCell >& result, std::vector< ugv_nav4d::CellWithPoses >& fullResult);
115
116 base::Pose2D getPointClosestToCellMiddle(const ugv_nav4d::CellWithPoses& cwp, const double gridResolution);
117
118
119 void computeSplinePrimCost(const sbpl_spline_primitives::SplinePrimitive& prim,
120 const Mobility& mobilityConfig, Motion& outMotion) const;
121
122};
123
124
125}
Definition DiscreteTheta.hpp:7
Definition PreComputedMotions.hpp:29
int xDiff
Definition PreComputedMotions.hpp:47
Motion(unsigned int numAngles=0)
Definition PreComputedMotions.hpp:43
std::vector< PoseWithCell > intermediateStepsTravMap
Definition PreComputedMotions.hpp:59
Type type
Definition PreComputedMotions.hpp:52
Type
Definition PreComputedMotions.hpp:36
@ MOV_POINTTURN
Definition PreComputedMotions.hpp:39
@ MOV_BACKWARD
Definition PreComputedMotions.hpp:38
@ MOV_LATERAL
Definition PreComputedMotions.hpp:40
@ MOV_FORWARD
Definition PreComputedMotions.hpp:37
static double costScaleFactor
Definition PreComputedMotions.hpp:34
static int calculateCost(double translationalDist, double angularDist, double translationVelocity, double angularVelocity, double costMultiplier)
Definition PreComputedMotions.cpp:291
DiscreteTheta endTheta
Definition PreComputedMotions.hpp:49
std::vector< CellWithPoses > fullSplineSamples
Definition PreComputedMotions.hpp:69
int baseCost
Definition PreComputedMotions.hpp:71
DiscreteTheta startTheta
Definition PreComputedMotions.hpp:50
double translationlDist
Definition PreComputedMotions.hpp:73
int yDiff
Definition PreComputedMotions.hpp:48
double angularDist
Definition PreComputedMotions.hpp:74
size_t id
Definition PreComputedMotions.hpp:76
int costMultiplier
Definition PreComputedMotions.hpp:72
Definition PreComputedMotions.hpp:81
void computeMotions(double travGridResolution)
Definition PreComputedMotions.cpp:20
void setMotionForTheta(const Motion &motion, const DiscreteTheta &theta)
Definition PreComputedMotions.cpp:185
void readMotionPrimitives(const sbpl_spline_primitives::SbplSplineMotionPrimitives &primGen, const Mobility &mobilityConfig, double travGridResolution)
Definition PreComputedMotions.cpp:92
static double calculateCurvatureFromRadius(const double r)
Definition PreComputedMotions.cpp:324
void preComputeCost(Motion &motion)
const Motion & getMotion(std::size_t id) const
Definition PreComputedMotions.cpp:314
const sbpl_spline_primitives::SbplSplineMotionPrimitives & getPrimitives() const
Definition PreComputedMotions.cpp:319
const std::vector< Motion > & getMotionForStartTheta(const DiscreteTheta &theta) const
Definition PreComputedMotions.cpp:353
Definition Dijkstra.cpp:8
Definition PreComputedMotions.hpp:22
maps::grid::Index cell
Definition PreComputedMotions.hpp:23
std::vector< base::Pose2D > poses
Definition PreComputedMotions.hpp:24
Definition Mobility.hpp:12
Definition PreComputedMotions.hpp:16
maps::grid::Index cell
Definition PreComputedMotions.hpp:18
base::Pose2D pose
Definition PreComputedMotions.hpp:17