Skip to content

Commit bd9ec89

Browse files
authored
Driver: reduce joint temperature spam (#3)
1 parent 539a659 commit bd9ec89

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

ur_robot_driver/include/ur_robot_driver/ros/hardware_interface.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,14 @@ class HardwareInterface : public hardware_interface::RobotHW
157157
*/
158158
bool shouldResetControllers();
159159

160+
/*!
161+
* \brief Mark next tick as logging tick
162+
*
163+
* \returns void
164+
*/
165+
void shouldLogTemperature(bool value);
166+
167+
160168
protected:
161169
/*!
162170
* \brief Transforms force-torque measurements reported from the robot from base to tool frame.
@@ -292,6 +300,8 @@ class HardwareInterface : public hardware_interface::RobotHW
292300

293301
std::string robot_ip_;
294302
std::string tf_prefix_;
303+
304+
bool enable_temperature_log_;
295305
};
296306

297307
} // namespace ur_driver

ur_robot_driver/src/ros/hardware_interface.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ void HardwareInterface::readBitsetData(const std::unique_ptr<rtde_interface::Dat
428428
}
429429
}
430430

431+
void HardwareInterface::shouldLogTemperature(bool value) {
432+
this->enable_temperature_log_ = value;
433+
}
434+
431435
void HardwareInterface::read(const ros::Time& time, const ros::Duration& period)
432436
{
433437
// set defaults
@@ -481,7 +485,9 @@ void HardwareInterface::read(const ros::Time& time, const ros::Duration& period)
481485
transformForceTorque();
482486
publishPose();
483487
publishRobotAndSafetyMode();
484-
publishJointTemperatures(time);
488+
if (this->enable_temperature_log_) {
489+
publishJointTemperatures(time);
490+
}
485491

486492
// pausing state follows runtime state when pausing
487493
if (runtime_state_ == static_cast<uint32_t>(rtde_interface::RUNTIME_STATE::PAUSED))

ur_robot_driver/src/ros/hardware_interface_node.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,20 @@ int main(int argc, char** argv)
129129

130130
double expected_cycle_time = 1.0 / (static_cast<double>(g_hw_interface->getControlFrequency()));
131131

132+
// Debug timing printout every 5 seconds
133+
const std::chrono::seconds debug_timing_period{5};
134+
std::chrono::steady_clock::time_point debug_timing_start = std::chrono::steady_clock::now();
135+
132136
// Run as fast as possible
133137
while (ros::ok())
134138
{
139+
const std::chrono::steady_clock::time_point debug_timing_now = std::chrono::steady_clock::now();
140+
const std::chrono::duration<double> elapsed_since_debug = debug_timing_now - debug_timing_start;
141+
// This is mostly used to track low-frequency information like joint temperature
142+
const bool trigger_low_frequency_logging = elapsed_since_debug > debug_timing_period;
143+
g_hw_interface->shouldLogTemperature(trigger_low_frequency_logging);
144+
if (trigger_low_frequency_logging) debug_timing_start = debug_timing_now;
145+
135146
// Receive current state from robot
136147
g_hw_interface->read(timestamp, period);
137148

0 commit comments

Comments
 (0)