Skip to content

Commit f4e09db

Browse files
committed
Added notifications when no new messages have been received from the robot
1 parent c663703 commit f4e09db

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/ur_modern_driver/ros/controller.h

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ROSController : private hardware_interface::RobotHW, public URRTPacketCons
3838
ros::Time lastUpdate_;
3939
controller_manager::ControllerManager controller_;
4040
bool robot_state_received_;
41+
ros::Time most_recent_packet_time_;
4142

4243
// state interfaces
4344
JointInterface joint_interface_;

src/ros/controller.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,28 @@ void ROSController::read(RTShared& packet)
101101
joint_interface_.update(packet);
102102
wrench_interface_.update(packet);
103103
robot_state_received_ = true;
104+
most_recent_packet_time_ = ros::Time::now();
104105
}
105106

106107
bool ROSController::update()
107108
{
108109
// don't run controllers if we haven't received robot state yet
109110
if (!robot_state_received_)
111+
{
112+
ROS_INFO_THROTTLE(1.0, "No messages received from the robot so far.");
110113
return true;
114+
}
111115

112116
auto time = ros::Time::now();
113117
auto diff = time - lastUpdate_;
114118
lastUpdate_ = time;
115119

120+
if ((time - most_recent_packet_time_).toSec() > 0.01) // CB2 and 3 cycle times are 0.008, adding some margin
121+
{
122+
ROS_WARN_THROTTLE(1.0, "No new packets received from robot. If this message doesn't go away, connection was "
123+
"probably lost");
124+
}
125+
116126
controller_.update(time, diff, !service_enabled_);
117127

118128
// emergency stop and such should not kill the pipeline

0 commit comments

Comments
 (0)