Skip to content

Instantly share code, notes, and snippets.

Created June 16, 2016 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fb926ffddbfac24d19c9268c61de8f5c to your computer and use it in GitHub Desktop.
Save anonymous/fb926ffddbfac24d19c9268c61de8f5c to your computer and use it in GitHub Desktop.
// The main loop
void loop()
{
// Initialize previous time
std::chrono::high_resolution_clock::time_point previousTime = std::chrono::high_resolution_clock::now();
// While the program should run and has a connection with ROS
while (!shouldTerminate && io.ok())
{
// Check whether new data is available and stor the data
if (hasNewData())
{
// Detect all edges in sight
detectEdges();
// Update passed seconds
passedSeconds = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - previousTime).count() / 1000000000.0;
// Execute slam
slam();
// Update previous time
previousTime = std::chrono::high_resolution_clock::now();
// Communicate the availability of data to the GUI and the strategy module
communicate();
}
// Sleep for 1 microsecond to avoid hogging all processing power
usleep(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment