-
Notifications
You must be signed in to change notification settings - Fork 52
/
HrpsysSeqStateROSBridge.h
118 lines (98 loc) · 3.92 KB
/
HrpsysSeqStateROSBridge.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// -*- C++ -*-
/*!
* @file HrpsysSeqStateROSBridge.h * @brief hrpsys seq state - ros bridge * @date $Date$
*
* $Id$
*/
#ifndef HRPSYSSEQSTATEROSBRIDGE_H
#define HRPSYSSEQSTATEROSBRIDGE_H
#include "HrpsysSeqStateROSBridgeImpl.h"
// rtm
#include <rtm/CorbaNaming.h>
// ros
#include "ros/ros.h"
#include "rosgraph_msgs/Clock.h"
#include "std_msgs/Int32.h"
#include "sensor_msgs/JointState.h"
#include "nav_msgs/Odometry.h"
#include "geometry_msgs/WrenchStamped.h"
#include "actionlib/server/simple_action_server.h"
#include "control_msgs/FollowJointTrajectoryAction.h"
#ifdef USE_PR2_CONTROLLERS_MSGS
#include "pr2_controllers_msgs/JointTrajectoryAction.h"
#include "pr2_controllers_msgs/JointTrajectoryControllerState.h"
#else
#include "control_msgs/JointTrajectoryControllerState.h"
#endif
#include "dynamic_reconfigure/Reconfigure.h"
#include "hrpsys_ros_bridge/MotorStates.h"
#include "hrpsys_ros_bridge/ContactStatesStamped.h"
#include "diagnostic_msgs/DiagnosticArray.h"
#include "sensor_msgs/Imu.h"
#include "hrpsys_ros_bridge/SetSensorTransformation.h"
extern const char* hrpsysseqstaterosbridgeimpl_spec[];
class HrpsysSeqStateROSBridge : public HrpsysSeqStateROSBridgeImpl
{
public:
HrpsysSeqStateROSBridge(RTC::Manager* manager) ;
~HrpsysSeqStateROSBridge();
RTC::ReturnCode_t onInitialize();
RTC::ReturnCode_t onFinalize();
RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id);
void onJointTrajectory(trajectory_msgs::JointTrajectory trajectory);
#ifdef USE_PR2_CONTROLLERS_MSGS
void onJointTrajectoryActionGoal();
void onJointTrajectoryActionPreempt();
#endif
void onFollowJointTrajectoryActionGoal();
void onFollowJointTrajectoryActionPreempt();
void onTrajectoryCommandCB(const trajectory_msgs::JointTrajectoryConstPtr& msg);
bool sendMsg (dynamic_reconfigure::Reconfigure::Request &req,
dynamic_reconfigure::Reconfigure::Response &res);
bool setSensorTransformation(hrpsys_ros_bridge::SetSensorTransformation::Request& req,
hrpsys_ros_bridge::SetSensorTransformation::Response& res);
private:
ros::NodeHandle nh;
ros::Publisher joint_state_pub, joint_controller_state_pub, mot_states_pub, diagnostics_pub, clock_pub, zmp_pub, ref_cp_pub, act_cp_pub, odom_pub, imu_pub, em_mode_pub, ref_contact_states_pub, act_contact_states_pub;
ros::Subscriber trajectory_command_sub;
std::vector<ros::Publisher> fsensor_pub, cop_pub;
#ifdef USE_PR2_CONTROLLERS_MSGS
actionlib::SimpleActionServer<pr2_controllers_msgs::JointTrajectoryAction> joint_trajectory_server;
#endif
actionlib::SimpleActionServer<control_msgs::FollowJointTrajectoryAction> follow_joint_trajectory_server;
ros::ServiceServer sendmsg_srv;
ros::ServiceServer set_sensor_transformation_srv;
bool interpolationp, use_sim_time, use_hrpsys_time;
bool publish_sensor_transforms;
tf::TransformBroadcaster br;
coil::Mutex m_mutex;
coil::TimeMeasure tm;
sensor_msgs::JointState prev_joint_state;
std::string nameserver;
std::string rootlink_name;
ros::Subscriber clock_sub;
nav_msgs::Odometry prev_odom;
bool prev_odom_acquired;
hrp::Vector3 prev_rpy;
void clock_cb(const rosgraph_msgs::ClockPtr& str) {};
bool follow_action_initialized;
ros::Time traj_start_tm;
boost::mutex tf_mutex;
double tf_rate;
ros::Timer periodic_update_timer;
std::vector<geometry_msgs::TransformStamped> tf_transforms;
void periodicTimerCallback(const ros::TimerEvent& event);
// odometry relatives
void updateOdometry(const hrp::Vector3 &trans, const hrp::Matrix33 &R, const ros::Time &stamp);
// imu relatives
void updateImu(tf::Transform &base, bool is_base_valid, const ros::Time &stamp);
// sensor relatives
void updateSensorTransform(const ros::Time &stamp);
std::map<std::string, geometry_msgs::Transform> sensor_transformations;
boost::mutex sensor_transformation_mutex;
};
extern "C"
{
DLL_EXPORT void HrpsysSeqStateROSBridgeInit(RTC::Manager* manager);
};
#endif // HRPSYSSEQSTATEROSBRIDGE_H