Skip to content

Commit

Permalink
Add the possibility to synchronize the advaceable runner in the centr…
Browse files Browse the repository at this point in the history
…oidal-mpc-controller
  • Loading branch information
GiulioRomualdi committed Sep 2, 2021
1 parent d9ff5bc commit 8c11834
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/centroidal-mpc-walking/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <BipedalLocomotion/ParametersHandler/YarpImplementation.h>
#include <BipedalLocomotion/System/AdvanceableRunner.h>
#include <BipedalLocomotion/System/Barrier.h>
#include <BipedalLocomotion/System/Clock.h>
#include <BipedalLocomotion/System/QuitHandler.h>
#include <BipedalLocomotion/System/SharedResource.h>
Expand Down Expand Up @@ -101,8 +102,21 @@ int main(int argc, char* argv[])
wholeBodyRunner.stop();
});

auto threadWBC = wholeBodyRunner.run();
auto threadMPC = centroidalMPCRunner.run();
// Run the threads
BipedalLocomotion::System::Barrier barrier(2);

auto threadWBC = wholeBodyRunner.run(barrier);
auto threadMPC = centroidalMPCRunner.run(barrier);

while (wholeBodyRunner.isRunning() && centroidalMPCRunner.isRunning())
{
using namespace std::chrono_literals;
constexpr auto delay = 200ms;
BipedalLocomotion::clock().sleepFor(delay);
}

centroidalMPCRunner.stop();
wholeBodyRunner.stop();

if (threadMPC.joinable())
{
Expand Down

0 comments on commit 8c11834

Please sign in to comment.