26 #include "AppGoalOnline.h"
28 AppGoalOnline::AppGoalOnline(
int argc,
char** argv)
32 add_controller =
true;
36 timestep_physics = 1.0f/1000.0f;
37 timestep_graphics = 1.0f/60.0f;
50 handleOptions(argc, argv);
56 world = createWorld();
60 view = createGraphicsView(world);
62 view = createView(world);
77 const int segmentSpan = 3;
78 const int numMuscles = 8;
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;
103 const double tensionFeedback = 1000.0;
106 const double feedbackTime = 3.0;
136 new SpineOnlineControl(control_config, suffix,
"bmirletz/TetrahedralComplex_Online/");
138 myModel->
attach(myControl);
146 tgModel* blockField = getBlocks();
154 void AppGoalOnline::handleOptions(
int argc,
char **argv)
157 po::options_description desc(
"Allowed options");
159 (
"help,h",
"produce help message")
160 (
"graphics,G", po::value<bool>(&use_graphics),
"Test using graphical view")
161 (
"controller,c", po::value<bool>(&add_controller),
"Attach the controller to the model.")
162 (
"blocks,b", po::value<bool>(&add_blocks)->implicit_value(
false),
"Add a block field as obstacles.")
163 (
"hills,H", po::value<bool>(&add_hills)->implicit_value(
false),
"Use hilly terrain.")
164 (
"all_terrain,A", po::value<bool>(&all_terrain)->implicit_value(
false),
"Alternate through terrain types. Only works with graphics off")
165 (
"phys_time,p", po::value<double>(),
"Physics timestep value (Hz). Default=1000")
166 (
"graph_time,g", po::value<double>(),
"Graphics timestep value a.k.a. render rate (Hz). Default = 60")
167 (
"episodes,e", po::value<int>(&nEpisodes),
"Number of episodes to run. Default=1")
168 (
"steps,s", po::value<int>(&nSteps),
"Number of steps per episode to run. Default=60K (60 seconds)")
169 (
"segments,S", po::value<int>(&nSegments),
"Number of segments in the tensegrity spine. Default=6")
170 (
"start_x,x", po::value<double>(&startX),
"X Coordinate of starting position for robot. Default = 0")
171 (
"start_y,y", po::value<double>(&startY),
"Y Coordinate of starting position for robot. Default = 20")
172 (
"start_z,z", po::value<double>(&startZ),
"Z Coordinate of starting position for robot. Default = 0")
173 (
"angle,a", po::value<double>(&startAngle),
"Angle of starting rotation for robot. Degrees. Default = 0")
174 (
"learning_controller,l", po::value<std::string>(&suffix),
"Which learned controller to write to or use. Default = default")
177 po::variables_map vm;
178 po::store(po::parse_command_line(argc, argv, desc), vm);
180 if (vm.count(
"help"))
182 std::cout << desc <<
"\n";
188 if (vm.count(
"phys_time"))
190 timestep_physics = 1/vm[
"phys_time"].as<
double>();
191 std::cout <<
"Physics timestep set to: " << timestep_physics <<
" seconds.\n";
194 if (vm.count(
"graph_time"))
196 timestep_graphics = 1/vm[
"graph_time"].as<
double>();
197 std::cout <<
"Graphics timestep set to: " << timestep_graphics <<
" seconds.\n";
203 btVector3 eulerAngles = btVector3(0.0, 0.0, 0.0);
204 btScalar friction = 0.5;
205 btScalar restitution = 0.0;
207 btVector3 size = btVector3(0.0, 0.1, 0.0);
208 btVector3 origin = btVector3(0.0, 0.0, 0.0);
212 double triangleSize = 4.0;
213 double waveHeight = 2.0;
216 size, origin, nx, ny, margin, triangleSize,
218 return hillGroundConfig;
223 const double yaw = 0.0;
224 const double pitch = 0.0;
225 const double roll = 0.0;
226 const double friction = 0.5;
227 const double restitution = 0.0;
228 const btVector3 size(1000.0, 1.5, 1000.0);
238 tgModel* AppGoalOnline::getBlocks()
245 tgWorld* AppGoalOnline::createWorld()
264 return new tgWorld(config, ground);
274 return new tgSimView(*world, timestep_physics, timestep_graphics);
292 simulate(simulation);
305 for (
int i=0; i<nEpisodes; i++) {
306 fprintf(stderr,
"Episode %d\n", i);
309 simulation->
run(nSteps);
311 catch (std::runtime_error e)
317 if (all_terrain && i != nEpisodes - 1)
325 simulation->
reset(ground);
328 else if (i % nTypes == 1)
332 simulation->
reset(ground);
335 else if (i % nTypes == 2)
338 tgModel* obstacle = getBlocks();
355 int main(
int argc,
char** argv)
357 std::cout <<
"AppGoalOnline" << std::endl;
void addObstacle(tgModel *pObstacle)
void addModel(tgModel *pModel)
void attach(tgObserver< T > *pObserver)
int main(int argc, char **argv)