Skip to content

Commit 539a659

Browse files
authored
📈 🎉 Pub joint temps (#1)
* Add `ur_rtde_msgs` package; include msg for joint temps * First pass at publishing joint temps * Fix bad vector assignment when creating joint temp msg * Add newline to end of Joint Temps msg * Rename `ur_rtde_msgs`->`ur_extra_msgs`
1 parent 936ff8d commit 539a659

File tree

8 files changed

+90
-0
lines changed

8 files changed

+90
-0
lines changed

ur_extra_msgs/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(ur_extra_msgs)
3+
4+
set(MESSAGE_DEPENDENCIES
5+
std_msgs
6+
)
7+
8+
## Find catkin macros and libraries
9+
find_package(catkin REQUIRED
10+
COMPONENTS
11+
message_generation
12+
${MESSAGE_DEPENDENCIES}
13+
)
14+
15+
add_message_files(
16+
DIRECTORY msg/
17+
)
18+
19+
generate_messages(
20+
DEPENDENCIES
21+
${MESSAGE_DEPENDENCIES}
22+
)
23+
24+
## The catkin_package macro generates cmake config files for your package
25+
## Declare things to be passed to dependent projects
26+
catkin_package(
27+
CATKIN_DEPENDS
28+
message_runtime
29+
${MESSAGE_DEPENDENCIES}
30+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This message holds data to describe the temperatures of all robot joints.
2+
Header header
3+
4+
string[] joint_names
5+
float64[] temperatures

ur_extra_msgs/package.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<package format="2">
3+
<name>ur_extra_msgs</name>
4+
<version>0.0.0</version>
5+
<description>Supplemental messages to ur_msgs, maintained by Chef</description>
6+
7+
<maintainer email="[email protected]">Chef Robotics</maintainer>
8+
<license>proprietary</license>
9+
<url type="website">https://github.com/chef-robotics/Universal_Robots_ROS_Driver</url>
10+
11+
<buildtool_depend>catkin</buildtool_depend>
12+
13+
<!-- Core dependencies -->
14+
<build_depend>message_generation</build_depend>
15+
<exec_depend>message_runtime</exec_depend>
16+
17+
<!-- Message dependencies should be declared with `depend` -->
18+
<depend>std_msgs</depend>
19+
20+
</package>

ur_robot_driver/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ find_package(catkin REQUIRED
2727
ur_controllers
2828
ur_dashboard_msgs
2929
ur_msgs
30+
ur_extra_msgs
3031
)
3132
find_package(Boost REQUIRED)
3233

@@ -52,6 +53,7 @@ catkin_package(
5253
ur_controllers
5354
ur_dashboard_msgs
5455
ur_msgs
56+
ur_extra_msgs
5557
std_srvs
5658
DEPENDS
5759
Boost

ur_robot_driver/include/ur_robot_driver/ros/hardware_interface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
#include <ur_msgs/SetIO.h>
4646
#include "ur_msgs/SetSpeedSliderFraction.h"
4747

48+
#include <ur_extra_msgs/JointTemperatures.h>
49+
4850
#include <ur_controllers/speed_scaling_interface.h>
4951
#include <ur_controllers/scaled_joint_command_interface.h>
5052

@@ -180,6 +182,7 @@ class HardwareInterface : public hardware_interface::RobotHW
180182
void publishIOData();
181183
void publishToolData();
182184
void publishRobotAndSafetyMode();
185+
void publishJointTemperatures(const ros::Time& timestamp);
183186

184187
/*!
185188
* \brief Read and evaluate data in order to set robot status properties for industrial
@@ -229,6 +232,7 @@ class HardwareInterface : public hardware_interface::RobotHW
229232
vector6d_t joint_positions_;
230233
vector6d_t joint_velocities_;
231234
vector6d_t joint_efforts_;
235+
vector6d_t joint_temperatures_;
232236
vector6d_t fts_measurements_;
233237
vector6d_t tcp_pose_;
234238
std::bitset<18> actual_dig_out_bits_;
@@ -259,6 +263,7 @@ class HardwareInterface : public hardware_interface::RobotHW
259263
std::unique_ptr<realtime_tools::RealtimePublisher<ur_msgs::ToolDataMsg>> tool_data_pub_;
260264
std::unique_ptr<realtime_tools::RealtimePublisher<ur_dashboard_msgs::RobotMode>> robot_mode_pub_;
261265
std::unique_ptr<realtime_tools::RealtimePublisher<ur_dashboard_msgs::SafetyMode>> safety_mode_pub_;
266+
std::unique_ptr<realtime_tools::RealtimePublisher<ur_extra_msgs::JointTemperatures>> joint_temperatures_pub_;
262267

263268
ros::ServiceServer set_speed_slider_srv_;
264269
ros::ServiceServer set_io_srv_;

ur_robot_driver/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<depend>ur_controllers</depend>
3939
<depend>ur_dashboard_msgs</depend>
4040
<depend>ur_msgs</depend>
41+
<depend>ur_extra_msgs</depend>
4142
<depend>std_srvs</depend>
4243

4344
<exec_depend>controller_stopper</exec_depend>

ur_robot_driver/resources/rtde_output_recipe.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ safety_mode
2525
robot_status_bits
2626
safety_status_bits
2727
actual_current
28+
joint_temperatures

ur_robot_driver/src/ros/hardware_interface.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ HardwareInterface::HardwareInterface()
5353
, joint_positions_{ { 0, 0, 0, 0, 0, 0 } }
5454
, joint_velocities_{ { 0, 0, 0, 0, 0, 0 } }
5555
, joint_efforts_{ { 0, 0, 0, 0, 0, 0 } }
56+
, joint_temperatures_{ { 0, 0, 0, 0, 0, 0 } }
5657
, standard_analog_input_{ { 0, 0 } }
5758
, standard_analog_output_{ { 0, 0 } }
5859
, joint_names_(6)
@@ -358,6 +359,8 @@ bool HardwareInterface::init(ros::NodeHandle& root_nh, ros::NodeHandle& robot_hw
358359
new realtime_tools::RealtimePublisher<ur_dashboard_msgs::RobotMode>(robot_hw_nh, "robot_mode", 1, true));
359360
safety_mode_pub_.reset(
360361
new realtime_tools::RealtimePublisher<ur_dashboard_msgs::SafetyMode>(robot_hw_nh, "safety_mode", 1, true));
362+
joint_temperatures_pub_.reset(
363+
new realtime_tools::RealtimePublisher<ur_extra_msgs::JointTemperatures>(robot_hw_nh, "joint_temperatures", 1));
361364

362365
// Set the speed slider fraction used by the robot's execution. Values should be between 0 and 1.
363366
// Only set this smaller than 1 if you are using the scaled controllers (as by default) or you know what you're
@@ -466,6 +469,7 @@ void HardwareInterface::read(const ros::Time& time, const ros::Duration& period)
466469
readBitsetData<uint64_t>(data_pkg, "actual_digital_output_bits", actual_dig_out_bits_);
467470
readBitsetData<uint32_t>(data_pkg, "analog_io_types", analog_io_types_);
468471
readBitsetData<uint32_t>(data_pkg, "tool_analog_input_types", tool_analog_input_types_);
472+
readData(data_pkg, "joint_temperatures", joint_temperatures_);
469473

470474
extractRobotStatus();
471475

@@ -477,6 +481,7 @@ void HardwareInterface::read(const ros::Time& time, const ros::Duration& period)
477481
transformForceTorque();
478482
publishPose();
479483
publishRobotAndSafetyMode();
484+
publishJointTemperatures(time);
480485

481486
// pausing state follows runtime state when pausing
482487
if (runtime_state_ == static_cast<uint32_t>(rtde_interface::RUNTIME_STATE::PAUSED))
@@ -713,6 +718,27 @@ void HardwareInterface::publishPose()
713718
}
714719
}
715720

721+
void HardwareInterface::publishJointTemperatures(const ros::Time& timestamp)
722+
{
723+
if (joint_temperatures_pub_)
724+
{
725+
if (joint_temperatures_pub_->trylock())
726+
{
727+
joint_temperatures_pub_->msg_.header.stamp = timestamp;
728+
joint_temperatures_pub_->msg_.joint_names.clear();
729+
joint_temperatures_pub_->msg_.temperatures.clear();
730+
731+
for (size_t i = 0; i < joint_names_.size(); i++)
732+
{
733+
joint_temperatures_pub_->msg_.joint_names.push_back(joint_names_[i]);
734+
joint_temperatures_pub_->msg_.temperatures.push_back(joint_temperatures_[i]);
735+
}
736+
737+
joint_temperatures_pub_->unlockAndPublish();
738+
}
739+
}
740+
}
741+
716742
void HardwareInterface::extractRobotStatus()
717743
{
718744
using namespace rtde_interface;

0 commit comments

Comments
 (0)