-
-
Save anonymous/fb926ffddbfac24d19c9268c61de8f5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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