Skip to content

Commit

Permalink
[Engine] add stop function
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Jan 21, 2025
1 parent c68c27d commit fccc93c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/overworld/Engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace owds {
{
public:
Engine(const std::string& name, Window* window) : world(compat::owds_ros::getShareDirectory("overworld")),
name_(name), window_(window)
name_(name), window_(window), run_(true)
{}

WorldEngine world;
Expand Down Expand Up @@ -66,9 +66,14 @@ namespace owds {
world.setTimeStep(fps);
}

void stop()
{
run_ = false;
}

void run(bool simulate = false)
{
while(!window_->isCloseRequested())
while(!window_->isCloseRequested() && run_)
{
window_->doPollEvents(renderer_);
if(simulate)
Expand All @@ -86,6 +91,7 @@ namespace owds {
Renderer renderer_;
std::string name_;
Window* window_;
std::atomic<bool> run_;
};

} // namespace owds
Expand Down
1 change: 1 addition & 0 deletions src/SituationAssessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ namespace owds {
{
callback_queue_.callAvailable(ros::WallDuration(0.1));
}
engine_->stop();
}

void SituationAssessor::run()
Expand Down

0 comments on commit fccc93c

Please sign in to comment.