Hello,
I want to have current time in every loop of simulation in SR1WalkpatternController.cpp and I want to use it in Control() function.(I can have the current time with io>currentTime(); in the Initialize() function however initialize function runs just one time at the start of simulation but I want the updated current time at each moment)
Thanks in advance for your help.
I solved the problem by defining a pointer for example ( SimpleControllerIO* ioG) and passing the io pointer to it in the initialize() function.
Yes. You can also do something like this way:
class SampleController : public SimpleController
{
double starttime;
double dt;
int count; // may be better to use long int
public:
virtual bool initialize(SimpleControllerIO* io) override
{
start = io->currentTime();
dt = io->timeStep();
count = 0;
(...snip...)
return true;
}
virtual bool control() override
{
double currenttime = starttime + dt * count;
count++;
(...snip...)
return true;
}
};
1 Like