Skip to content

Commit

Permalink
Keep the t variable monotonic in the simulation
Browse files Browse the repository at this point in the history
Otherwise it causes stopping sending MAVLink and other bugs
  • Loading branch information
okalachev committed Oct 23, 2024
1 parent eeb86b8 commit 74bcfdd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gazebo/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void delay(uint32_t ms) {
}

unsigned long __micros;
unsigned long __resetTime = 0;

unsigned long micros() {
return __micros;
return __micros + __resetTime; // keep the time monotonic
}
1 change: 1 addition & 0 deletions gazebo/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ModelFlix : public ModelPlugin {

void OnReset() {
attitude = Quaternion(); // reset estimated attitude
__resetTime += __micros;
gzmsg << "Flix plugin reset" << endl;
}

Expand Down

0 comments on commit 74bcfdd

Please sign in to comment.