3
3
* @author Ugo Cupcic <ugo@shadowrobot.com>, Contact <contact@shadowrobot.com>
4
4
* @date Thu Apr 22 10:26:41 2010
7
* Copyright 2011 Shadow Robot Company Ltd.
9
* This program is free software: you can redistribute it and/or modify it
10
* under the terms of the GNU General Public License as published by the Free
11
* Software Foundation, either version 2 of the License, or (at your option)
14
* This program is distributed in the hope that it will be useful, but WITHOUT
15
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19
* You should have received a copy of the GNU General Public License along
20
* with this program. If not, see <http://www.gnu.org/licenses/>.
6
22
* @brief This class reads and publishes data concerning the
7
23
* shadowhand / shadowarm. To publish those data, just call the publish()
20
36
#include <boost/smart_ptr.hpp>
22
38
#include <ros/ros.h>
23
#include "sr_hand/hand/shadowhand.h"
39
#include "sr_hand/hand/sr_articulated_robot.h"
25
41
using namespace ros;
26
using namespace shadowhand;
42
using namespace shadowrobot;
28
namespace shadowhand_publisher{
30
47
* This class publishes data concerning the shadowhand /shadowarm, like position, targets, forces, ... on different
31
48
* topics. To publish those data, just call the publish() function.
35
52
* (a ROS package). This is useful to visualize the data in rviz (part of ROS). A third topic is
36
53
* \/prefix\/shadowhand_data. The messages published on this last topic are better formatted for our hardware.
38
class ShadowhandPublisher
42
* Constructor initializing the ROS node, and setting the topic to which it publishes.
43
* The frequency at which this node will publish data is set by a parameter, read from ROS parameter server.
45
* @param sh A Shadowhand or Shadowarm object, where the information to be published comes from.
47
ShadowhandPublisher(boost::shared_ptr<Shadowhand> sh);
50
~ShadowhandPublisher();
53
* The callback method which is called at a given frequency. Gets the data from the shadowhand/shadowarm object.
59
NodeHandle node, n_tilde;
60
///the rate at which the data will be published. This can be set by a parameter in the launch file.
63
///The shadowhand object (can be either an object connected to the real robot or a virtual hand).
64
boost::shared_ptr<Shadowhand> shadowhand;
66
///The publisher which publishes the data to the \/{prefix}\/position\/joint_states topic.
67
Publisher shadowhand_jointstate_pos_pub;
68
///The publisher which publishes the data to the \/{prefix}\/target\/joint_states topic.
69
Publisher shadowhand_jointstate_target_pub;
70
///The publisher which publishes the data to the \/{prefix}\/shadowhand_data topic.
71
Publisher shadowhand_pub;
74
* Convert an angle in degree to an angle in radians.
75
* @param deg the angle in degrees
76
* @return the value in rads.
78
inline double toRad(double deg)
80
return deg * 3.14159265 / 180.0;
59
* Constructor initializing the ROS node, and setting the topic to which it publishes.
60
* The frequency at which this node will publish data is set by a parameter, read from ROS parameter server.
62
* @param sh A Shadowhand or Shadowarm object, where the information to be published comes from.
64
SRPublisher( boost::shared_ptr<SRArticulatedRobot> sr_art_robot );
70
* The callback method which is called at a given frequency. Gets the data from the shadowhand/shadowarm object.
76
NodeHandle node, n_tilde;
77
///the rate at which the data will be published. This can be set by a parameter in the launch file.
80
///The shadowhand object (can be either an object connected to the real robot or a virtual hand).
81
boost::shared_ptr<SRArticulatedRobot> sr_articulated_robot;
83
///The publisher which publishes the data to the \/{prefix}\/position\/joint_states topic.
84
Publisher sr_jointstate_pos_pub;
85
///The publisher which publishes the data to the \/{prefix}\/target\/joint_states topic.
86
Publisher sr_jointstate_target_pub;
87
///The publisher which publishes the data to the \/{prefix}\/shadowhand_data topic.
91
* Convert an angle in degree to an angle in radians.
92
* @param deg the angle in degrees
93
* @return the value in rads.
95
inline double toRad( double deg )
97
return deg * 3.14159265 / 180.0;
82
99
}; // end class ShadowhandPublisher
84
101
} // end namespace