I have a method:
void move_robot(const vector<vector<double> > &map) {
// accumulate the footprint while the robot moves
// Iterate through the path
//std::unique_lock<std::mutex> lck(mtx);
for (unsigned int i=1; i < map.size(); i++) {
while (distance(position , map[i]) > DISTANCE_TOLERANCE ) {
this->direction = unitary_vector(map[i], this->position);
this->next_step();
lck.unlock();
this_thread::sleep_for(chrono::milliseconds(10)); // sleep for 500 ms
lck.lock();
}
std::cout << "New position is x:" << this->position[0] << " and y:" << this->position[1] << std::endl;
}
this->moving = false;
// notify to end
}
When the sleep and locks are included I get:
ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 143
Killed - processing time exceeded
Nevertheless, if I comment all the locks and this_thread::sleep_for
it works as expected.
I need the locks because I am dealing with other threads. The complete code is this one: https://godbolt.org/z/7ErjrG
I am quite stacked because the otput does not provide much information