-
Notifications
You must be signed in to change notification settings - Fork 1
/
world.h
executable file
·179 lines (139 loc) · 4.86 KB
/
world.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#ifndef WORLD_H
#define WORLD_H
#include "eigenIncludes.h"
// include elastic rod class
#include "rod_mechanics/elasticRod.h"
#include <time.h>
// For throwing errors related to convergence.
#include <stdexcept>
// include force classes
#include "rod_mechanics/elasticStretchingForce.h"
#include "rod_mechanics/elasticBendingForce.h"
#include "rod_mechanics/externalGravityForce.h"
#include "rod_mechanics/inertialForce.h"
// include external force
#include "rod_mechanics/dampingForce.h"
#include "rod_mechanics/externalContactForce.h"
// include time stepper
#include "rod_mechanics/timeStepper.h"
// include input file and option
#include "initialization/setInput.h"
// SMAs for actuation model
#include "rod_mechanics/shapeMemoryAlloy.h"
#include "rod_mechanics/shapeMemoryAlloyCompression.h"
// Controller framework
#include "controllers/rodController.h"
#include "controllers/rodCOMSingleShotController.h"
class world
{
public:
world();
// Constructor can include an initial pose of the rod. Otherwise will be assumed zero.
world(setInput &m_inputData);
world(setInput &m_inputData, VectorXd m_rb_state_0);
// a helper to the constructor will take care of the SetInput initialization.
void worldConstructorHelper(setInput &m_inputData);
//
~world();
void setRodStepper();
void updateTimeStep();
int simulationRunning();
int numPoints();
Vector3d getScaledCoordinate(int i, int j);
Vector3d getScaledBendingCoordinate(int i, int j); // for plotting bending pairs also.
double getScaledBoundary(double x);
double getCurrentTime();
double getTotalTime();
bool isRender();
// Some helpers for interfacing with callers.
shared_ptr<elasticRod> getRodP();
int getTimeStep();
// Controller framework: must assign a rodController after instantiation.
// void setRodController(rodController* c_p);
void setRodController(shared_ptr<rodController> c_p);
// Some outward facing functions for the private variables.
int getNumLimbs();
// some getters for use with logging
double getLimbLength();
private:
// Physical parameters
double limbLength, RodLength;
double footLength;
double rodRadius;
int numVertices;
double youngM;
double Poisson;
double shearM;
double deltaTime;
double totalTime;
double density;
Vector3d gVector;
double viscositya;
double viscosityb;
double dropHeight;
double delta_l;
int numLimbs;
bool enableAutoDrop;
// Initial rigid body pose of the rod, passed through to the elasticRod constructor.
VectorXd rb_state_0;
double tol, stol;
int maxIter; // maximum number of iterations
double characteristicForce;
double forceTol;
// Geometry, passed in to rod
MatrixXd vertices;
// Rod
shared_ptr<elasticRod> rod = nullptr;
// set up the time stepper
// timeStepper* stepper;
shared_ptr<timeStepper> stepper = nullptr;
double* totalForce; // this is owned by the stepper, so the stepper delete[]s it.
double currentTime;
// declare the forces
unique_ptr<elasticStretchingForce> m_stretchForce = nullptr;
unique_ptr<elasticBendingForce> m_bendingForce = nullptr;
unique_ptr<inertialForce> m_inertialForce = nullptr;
unique_ptr<externalGravityForce> m_gravityForce = nullptr;
unique_ptr<dampingForce> m_dampingForce = nullptr;
unique_ptr<externalContactForce> m_externalContactForce = nullptr;
// int Nstep;
// count number of iterations.
int timeStep;
int iter;
void rodGeometryChain();
void rodGeometryWalker();
bool render; // should the OpenGL rendering be included?
bool updateTimeStep_singleRod();
void addRod();
// The SMAs are also added during setup. Note, must be AFTER rod!!
void addSMAs();
// Friction coefficients. NOTE that static isn't used...!
double dynamicFric;
void checkJacobian();
void computeReactionForce();
// double FN, Ff; // normal and friction force
// compute average velocity
// double initialX, finalX, avgVelocity;
Vector2d computeCenterMass();
// std::string actuationDirName;
// was simulation successful?
bool successfulSim;
int boundaryType; // type of boundary
int inputNv; // number of nodes per limb, counting inclusively (includes joints). From options file. Drew's notation: M
int nvEachLimb; // number of nodes per limb, counting only ONE of its two attached joint locations. = inputNv-1. Drew's notation: P
int nvEachLimbNoJoints; // number of nodes per limb, counting NEITHER joint. = inputNV-2. Drew's notation: unused I think...
double nTimeCurvature;
double nTimeStiffness;
double tau;
double Tinitial;
// For the compression SMA model
double compression_kB_max;
VectorXi ifAddDynamicFriction;
// Rod controller pointer, to be used (e.g.) in updateTimeStep
// rodController* ctlr_p = NULL;
shared_ptr<rodController> ctlr_p = nullptr;
// The world contains the SMA actuators. The SMAs are manipulated by the world, then
// their resulting kB, EI get passed to the rods for mechanics calculations.
std::vector<shared_ptr<shapeMemoryAlloy>> sma;
};
#endif