ros-industrial / ur_modern_driver

(deprecated) ROS 1 driver for CB1 and CB2 controllers with UR5 or UR10 robots from Universal Robots
Apache License 2.0
301 stars 341 forks source link

Wrench not being published #342

Open danfergo opened 4 years ago

danfergo commented 4 years ago

Hi everyone,

I'm using the kinetic-devel branch with ROS melodic. I'm launching the driver by with

<include file="$(find ur_modern_driver)/launch/ur5_bringup.launch">
        <arg name="robot_ip" value="192.168.1.100"/>
</include>

I was trying to subscribe/echo'ing the /wrench topic but without success. After debugging the rt_publisher.cpp file, I found that the publisher was being called, but the messages weren't being published/received. So, I added "spinOnce" wasn't being called, so I updated the publish method.

Changed,

bool RTPublisher::publish(RTShared& packet)
{
  ... 
  return res && publishTool(packet, time) && publishTransform(packet, time) && publishTemperature(packet, time);
}

To.

bool RTPublisher::publish(RTShared& packet)
{
  ... 
  bool ret = res && publishTool(packet, time) && publishTransform(packet, time) && publishTemperature(packet, time);
  ros::spinOnce();
  return ret;
}

Don't know if this was the best way of solving the issue, but it worked in my case.

gavanderhoorn commented 4 years ago

Spinning should not be necessary for handling publications, only subscriptions require that in roscpp.

Not saying it didn't appear to resolve your issue, but it would seem like a deviation from how the API is to be used.

We also have a ros::spin() in the main node:

https://github.com/ros-industrial/ur_modern_driver/blob/fd2e38af745b9d471a4f9532be5f39e5d95fe405/src/ros_main.cpp#L245

that should take care of this as well.

Can you provide a little more information on your system, robot controller, versions of relevant components (ie: Polyscope, ur_modern_driver, etc)?