29 AppMultiTerrain_Tetra::AppMultiTerrain_Tetra(
int argc,
char** argv)
33 add_controller =
true;
37 timestep_physics = 1.0f/1000.0f;
38 timestep_graphics = 1.0f/60.0f;
51 handleOptions(argc, argv);
57 world = createWorld();
61 view = createGraphicsView(world);
63 view = createView(world);
77 const int segmentSpan = 3;
78 const int numMuscles = 6;
79 const int numParams = 2;
80 const int segNumber = 0;
81 const double controlTime = .01;
82 const double lowPhase = -1 * M_PI;
83 const double highPhase = M_PI;
84 const double lowAmplitude = 0.0;
85 const double highAmplitude = 300.0;
86 const double kt = 0.0;
87 const double kp = 1000.0;
88 const double kv = 200.0;
89 const bool def =
true;
92 const double cl = 10.0;
93 const double lf = 0.0;
94 const double hf = 30.0;
97 const double ffMin = -0.5;
98 const double ffMax = 10.0;
99 const double afMin = 0.0;
100 const double afMax = 200.0;
101 const double pfMin = -0.5;
102 const double pfMax = 6.28;
132 myModel->
attach(myControl);
140 tgModel* blockField = getBlocks();
148 void AppMultiTerrain_Tetra::handleOptions(
int argc,
char **argv)
151 po::options_description desc(
"Allowed options");
153 (
"help,h",
"produce help message")
154 (
"graphics,G", po::value<bool>(&use_graphics),
"Test using graphical view")
155 (
"controller,c", po::value<bool>(&add_controller),
"Attach the controller to the model.")
156 (
"blocks,b", po::value<bool>(&add_blocks)->implicit_value(
false),
"Add a block field as obstacles.")
157 (
"hills,H", po::value<bool>(&add_hills)->implicit_value(
false),
"Use hilly terrain.")
158 (
"all_terrain,A", po::value<bool>(&all_terrain)->implicit_value(
false),
"Alternate through terrain types. Only works with graphics off")
159 (
"phys_time,p", po::value<double>(),
"Physics timestep value (Hz). Default=1000")
160 (
"graph_time,g", po::value<double>(),
"Graphics timestep value a.k.a. render rate (Hz). Default = 60")
161 (
"episodes,e", po::value<int>(&nEpisodes),
"Number of episodes to run. Default=1")
162 (
"steps,s", po::value<int>(&nSteps),
"Number of steps per episode to run. Default=60K (60 seconds)")
163 (
"segments,S", po::value<int>(&nSegments),
"Number of segments in the tensegrity spine. Default=6")
164 (
"start_x,x", po::value<double>(&startX),
"X Coordinate of starting position for robot. Default = 0")
165 (
"start_y,y", po::value<double>(&startY),
"Y Coordinate of starting position for robot. Default = 20")
166 (
"start_z,z", po::value<double>(&startZ),
"Z Coordinate of starting position for robot. Default = 0")
167 (
"angle,a", po::value<double>(&startAngle),
"Angle of starting rotation for robot. Degrees. Default = 0")
168 (
"learning_controller,l", po::value<std::string>(&suffix),
"Which learned controller to write to or use. Default = default")
171 po::variables_map vm;
172 po::store(po::parse_command_line(argc, argv, desc), vm);
174 if (vm.count(
"help"))
176 std::cout << desc <<
"\n";
182 if (vm.count(
"phys_time"))
184 timestep_physics = 1/vm[
"phys_time"].as<
double>();
185 std::cout <<
"Physics timestep set to: " << timestep_physics <<
" seconds.\n";
188 if (vm.count(
"graph_time"))
190 timestep_graphics = 1/vm[
"graph_time"].as<
double>();
191 std::cout <<
"Graphics timestep set to: " << timestep_graphics <<
" seconds.\n";
197 btVector3 eulerAngles = btVector3(0.0, 0.0, 0.0);
198 btScalar friction = 0.5;
199 btScalar restitution = 0.0;
201 btVector3 size = btVector3(0.0, 0.1, 0.0);
202 btVector3 origin = btVector3(0.0, 0.0, 0.0);
206 double triangleSize = 4.0;
207 double waveHeight = 2.0;
210 size, origin, nx, ny, margin, triangleSize,
212 return hillGroundConfig;
217 const double yaw = 0.0;
218 const double pitch = 0.0;
219 const double roll = 0.0;
225 tgModel* AppMultiTerrain_Tetra::getBlocks()
232 tgWorld* AppMultiTerrain_Tetra::createWorld()
251 return new tgWorld(config, ground);
261 return new tgSimView(*world, timestep_physics, timestep_graphics);
279 simulate(simulation);
290 void AppMultiTerrain_Tetra::simulate(
tgSimulation *simulation)
292 for (
int i=0; i<nEpisodes; i++) {
293 fprintf(stderr,
"Episode %d\n", i);
296 simulation->
run(nSteps);
298 catch (std::runtime_error e)
304 if (all_terrain && i != nEpisodes - 1)
312 simulation->
reset(ground);
315 else if (i % nTypes == 1)
319 simulation->
reset(ground);
322 else if (i % nTypes == 2)
325 tgModel* obstacle = getBlocks();
342 int main(
int argc,
char** argv)
344 std::cout <<
"AppMultiTerrain_Tetra" << std::endl;
void addObstacle(tgModel *pObstacle)
Contains the definition function main() for the Multiple terrains app.
void addModel(tgModel *pModel)
int main(int argc, char **argv)
void attach(tgObserver< T > *pObserver)