Skip to content
Snippets Groups Projects
Commit f76aeb55 authored by thomas's avatar thomas
Browse files

add spin Time

parent 49a8a423
No related branches found
No related tags found
No related merge requests found
ros-msgs-mbed-lib @ 681b30a1
Subproject commit 681b30a1deded7a2c277cf861fea4b22d5adb463
......@@ -44,7 +44,6 @@ void Communication::update(double dt)
publishOdometry();
publishMotorsCurrent();
publishStatus();
m_nodeHandle.spinOnce();
}
void Communication::publishOdometry()
......
......@@ -67,10 +67,12 @@ void MccdNode::start()
int elapsedTime = 0;
int dtLogic = 0; // delta time (in ms) for logic update (pid + odometry)
int dtCom = 0; // delta time (in ms) for communication update (send
int dtSpin = 0; // delta time (in ms) for spin update (send
// odometry + transform + ...)
// Interval in ms at which the logic is updated
int logicUpdateInterval = 10;
int spinUpdateInterval = 50;
// Interval in ms at which the communication updates (publish messages and execute callbacks for subscribers)
// It can be modified via rosparam (for pid calibration which requires higher sampling rate, for example)
......@@ -189,6 +191,7 @@ void MccdNode::start()
dtLogic += elapsedTime;
dtCom += elapsedTime;
dtSpin += elapsedTime;
if (dtCom >= communicationUpdateInterval)
{
......@@ -209,6 +212,17 @@ void MccdNode::start()
}
dtLogic = 0;
}
if (dtSpin >= spinUpdateInterval)
{
m_nodeHandle.spinOnce();
dtSpin = 0;
}
}
}
\ No newline at end of file
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment