AGXDynamics
2.35.0.3
TrajectoryCalculator.h
Go to the documentation of this file.
1
/*
2
Copyright 2007-2022. Algoryx Simulation AB.
3
4
All AGX source code, intellectual property, documentation, sample code,
5
tutorials, scene files and technical white papers, are copyrighted, proprietary
6
and confidential material of Algoryx Simulation AB. You may not download, read,
7
store, distribute, publish, copy or otherwise disseminate, use or expose this
8
material unless having a written signed agreement with Algoryx Simulation AB, or
9
having been advised so by Algoryx Simulation AB for a time limited evaluation,
10
or having purchased a valid commercial license from Algoryx Simulation AB.
11
12
Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13
from using this software, unless otherwise stated in written agreements with
14
Algoryx Simulation AB.
15
*/
16
17
#ifndef AGXTERRAIN_TRAJECTORYCALCULATOR_H
18
#define AGXTERRAIN_TRAJECTORYCALCULATOR_H
19
20
#include <queue>
21
#include <numeric>
22
23
#include <
agxTerrain/export.h
>
24
25
#include <
agx/agx_vector_types.h
>
26
#include <
agxData/agxData.h
>
27
28
#include <
agxCollide/HeightField.h
>
29
#include <
agxCollide/Geometry.h
>
30
#include <
agxCollide/Line.h
>
31
#include <
agxCollide/Contacts.h
>
32
#include <
agxCollide/BasicPrimitiveTests.h
>
33
34
namespace
agxTerrain
35
{
36
struct
TrajectorySettings
37
{
38
agx::Real
cutDepth
;
39
agx::Real
cutAngle
;
40
agx::Real
bladeSpeed
;
41
agx::Real
goalHeight
;
42
agx::Real
resolution
;
43
agx::Real
timestep
;
44
};
45
46
class
AGXTERRAIN_EXPORT
TrajectoryCalculator
47
{
48
public
:
49
TrajectoryCalculator
();
50
TrajectoryCalculator
(
agxCollide::HeightField
* heightField,
const
TrajectorySettings
& settings);
51
52
void
setTrajectorySettings(
const
TrajectorySettings
& settings);
53
void
setHeightField(
agxCollide::HeightField
* heightField);
54
void
setCutDepth(
agx::Real
cutDepth);
55
void
setCutAngle(
agx::Real
cutAngle);
56
void
setBladeSpeed(
agx::Real
bladeSpeed);
57
void
setGoalHeight(
agx::Real
goalHeight);
58
void
setResolution(
agx::Real
resolution);
59
void
setTimestep(
agx::Real
timestep);
60
61
TrajectorySettings
getTrajectorySettings()
const
;
62
agx::Real
getCutDepth()
const
;
63
agx::Real
getCutAngle()
const
;
64
agx::Real
getBladeSpeed()
const
;
65
agx::Real
getGoalHeight()
const
;
66
agx::Real
getResolution()
const
;
67
agx::Real
getTimestep()
const
;
68
69
agx::Bool
hasHeightField()
const
;
70
agx::Bool
isValid()
const
;
71
72
void
createTrajectory(
const
agx::Vec2
& startPoint,
const
agx::Vec2
& endPoint);
73
agx::Vec3Vector
getTrajectory();
74
agx::Vec3
getInitialPosition();
75
agx::Vec3
getVelocity();
76
void
discardTrajectory();
77
78
// Debug rendering methods
79
void
DEBUG_drawHeightCurve();
80
void
DEBUG_drawTrajectory();
81
void
DEBUG_drawVelocities();
82
83
private
:
84
agx::RealVector
applyFilters(
const
agx::RealVector
& heightCurve);
85
void
computeHeightCurve(
const
agx::Vec2
& startPoint,
const
agx::Vec2
& endPoint);
86
void
computeTrajectory(
const
agx::RealVector
& heightCurve);
87
void
computeVelocities();
88
89
agx::RealVector
movingAverageStddev(
const
agx::RealVector
& data,
const
size_t
range);
90
agx::RealVector
movingAverageFilter(
const
agx::RealVector
& data,
const
size_t
range);
91
agx::RealVector
movingAverageFilterLowSlope(
const
agx::RealVector
& data,
size_t
range,
const
agx::Real
threshold);
92
agx::Real
interpolate(
agx::Real
x,
const
agx::RealVector
& xDiscrete,
const
agx::RealVector
& yDiscrete);
93
agx::RealVector
computeArcLength(
const
agx::RealVector
& x,
const
agx::RealVector
& y);
94
agx::Real
computeInverseArcLength(
agx::Real
distance,
const
agx::RealVector
& x,
const
agx::RealVector
& arcLength);
95
96
// Heightfield and resulting 2D heightcurve
97
agxCollide::HeightFieldRef
m_heightField;
98
agx::RealVector
m_heightCurve;
99
agx::RealVector
m_x;
100
101
// Settings
102
TrajectorySettings
m_settings;
103
104
// Start and endpoint in xy-plane along with rotation matrix for velocities
105
agx::Vec2
m_startPoint;
106
agx::Vec2
m_endPoint;
107
agx::Matrix4x4
m_rotateMatrix;
108
109
// Resulting trajectory and velocities
110
agx::RealVector
m_trajectory;
111
std::queue<agx::Vec3> m_velocities;
112
113
// Boolean for valid trajectory
114
agx::Bool
m_validTrajectory;
115
};
116
}
117
118
#endif
HeightField.h
agx::Real
double Real
Definition:
Real.h:42
agxTerrain::TrajectoryCalculator
Definition:
TrajectoryCalculator.h:46
agxTerrain
The agxTerrain namespace contains a 3D model for a dynamic deformable Terrain and related classes.
Definition:
Geometry.h:59
Geometry.h
agxTerrain::TrajectorySettings::cutAngle
agx::Real cutAngle
Definition:
TrajectoryCalculator.h:39
agxCollide::HeightField
A HeightField is a collision shape that can be created from a grid structure, like an image.
Definition:
agxCollide/HeightField.h:51
agxTerrain::TrajectorySettings
Definition:
TrajectoryCalculator.h:36
agxTerrain::TrajectorySettings::resolution
agx::Real resolution
Definition:
TrajectoryCalculator.h:42
agx::VectorPOD< Vec3 >
export.h
BasicPrimitiveTests.h
agx::Matrix4x4T< Real >
agx::ref_ptr< HeightField >
agxTerrain::TrajectorySettings::bladeSpeed
agx::Real bladeSpeed
Definition:
TrajectoryCalculator.h:40
Line.h
agxData.h
agx::Vec2T
Definition:
Vec2Template.h:30
agxTerrain::TrajectorySettings::goalHeight
agx::Real goalHeight
Definition:
TrajectoryCalculator.h:41
AGXTERRAIN_EXPORT
#define AGXTERRAIN_EXPORT
Definition:
agxTerrain/export.h:41
agx::Bool
bool Bool
Definition:
Integer.h:48
Contacts.h
agxTerrain::TrajectorySettings::cutDepth
agx::Real cutDepth
Definition:
TrajectoryCalculator.h:38
agxTerrain::TrajectorySettings::timestep
agx::Real timestep
Definition:
TrajectoryCalculator.h:43
agx::Vec3T< Real >
agx_vector_types.h
include
agxTerrain
TrajectoryCalculator.h
Generated on Fri Feb 10 2023 14:06:19 for AGXDynamics by
1.8.17