romeo.h
Go to the documentation of this file.
1 
23 #ifndef ROMEO_DCM_DRIVER_ROMEO_H
24 #define ROMEO_DCM_DRIVER_ROMEO_H
25 
26 // Boost Headers
27 #include <boost/shared_ptr.hpp>
28 #include <boost/assign.hpp>
29 #include <boost/lexical_cast.hpp>
30 
31 // NAOqi Headers
32 #include <alcommon/almodule.h>
33 #include <alcommon/alproxy.h>
34 #include <alproxies/almotionproxy.h>
35 #include <alproxies/almemoryproxy.h>
36 #include <alproxies/dcmproxy.h>
37 #include <qi/os.hpp>
38 
39 // ROS Headers
40 #include <ros/ros.h>
41 
42 /*
43 #include <geometry_msgs/Twist.h>
44 #include <sensor_msgs/Imu.h>
45 #include <sensor_msgs/Range.h>
46 */
47 #include <nav_msgs/Odometry.h>
48 #include <sensor_msgs/JointState.h>
49 
50 #include <romeo_dcm_msgs/BoolService.h>
51 /*#include <romeo_dcm_msgs/FSRs.h>
52 #include <romeo_dcm_msgs/Bumper.h>
53 #include <romeo_dcm_msgs/Tactile.h> */
54 #include <std_msgs/Float32.h>
55 
57 #include <tf/transform_listener.h>
58 #include <tf/transform_datatypes.h>
59 
63 
65 
66 #include <diagnostic_updater/diagnostic_updater.h>
67 
68 using std::string;
69 using std::vector;
70 
71 namespace AL
72 {
73 class ALBroker;
74 }
75 
76 // Helper definition
77 template<typename T, size_t N>
78 T * end(T (&ra)[N]) {
79  return ra + N;
80 }
81 
82 class Romeo : public AL::ALModule, public hardware_interface::RobotHW
83 {
84 private:
85  // ROS Standard Variables
87 
88  // ROS Topics/Messages
90 
93 
94  //Stiffness and joint states
95  std_msgs::Float32 stiffness_;
96  sensor_msgs::JointState m_jointState;
98 
100 
101  // ROS Diagnostics
102  diagnostic_updater::Updater diagnostic_;
103 
104  // Member Variables
105  AL::ALValue commands_;
106 
107  // Helper
109 
110  // Robot Parameters
111  string version_, body_type_;
114  string prefix_, odom_frame_;
115  double low_freq_, high_freq_, controller_freq_, joint_precision_;
116 
117  // AL Proxies
118  AL::ALMemoryProxy memory_proxy_;
121 
122  // Joints
123  vector<string> joints_names_;
124 
125  // Joint States
128 
130  vector<string> joint_names_;
131  vector<double> joint_commands_;
132  vector<double> joint_angles_;
133  vector<double> joint_velocities_;
134  vector<double> joint_efforts_;
135 public:
136  // Constructor/Destructor
137  Romeo(boost::shared_ptr<AL::ALBroker> broker, const std::string& name);
138  ~Romeo();
139 
140  bool initialize();
141  bool initializeControllers(controller_manager::ControllerManager& cm);
142 
143  // Connect/Disconnet to ALProxies
144  bool connect(const ros::NodeHandle nh);
145  void disconnect();
146 
147  // Subscribe/Advertise to ROS Topics/Services
148  void subscribe();
149 
150  // Parameter Server
151  void loadParams();
152 
153  // Helper
154  void brokerDisconnected(const string& event_name, const string &broker_name, const string& subscriber_identifier);
155 
156  // DCMProxy Wrapper Methods
157  void DCMTimedCommand(const string& key, const AL::ALValue& value, const int& timeOffset,
158  const string& type="Merge");
159  void DCMAliasTimedCommand(const string& alias, const vector<float>& values, const vector<int>& timeOffsets,
160  const string& type="Merge", const string& type2="time-mixed");
161 
162  // ALMemoryProxy Wrapper Methods
163  void insertDataToMemory(const string& key, const AL::ALValue& value);
164  AL::ALValue getDataFromMemory(const string& key);
165  void subscribeToEvent(const std::string& name, const std::string& callback_module,
166  const std::string& callback_method);
167  void subscribeToMicroEvent(const std::string& name, const std::string& callback_module,
168  const std::string& callback_method, const string& callback_message="");
169  void unsubscribeFromEvent(const string& name, const string& callback_module);
170  void unsubscribeFromMicroEvent(const string& name, const string& callback_module);
171  void raiseEvent(const string& name, const AL::ALValue& value);
172  void raiseMicroEvent(const string& name, const AL::ALValue& value);
173  void declareEvent(const string& name);
174 
175  // General Methods
176  void controllerLoop();
177  void lowCommunicationLoop();
178  void highCommunicationLoop();
179 
180  bool connected();
181 
182  // ROS Callbacks/Related Methods
183  void commandVelocity(const geometry_msgs::TwistConstPtr &msg);
184  bool switchStiffnesses(romeo_dcm_msgs::BoolService::Request &req, romeo_dcm_msgs::BoolService::Response &res);
185  void readJoints();
186  void publishJointStateFromAlMotion();
187 
188  void writeJoints();
189  void run();
190 
191 };
192 
193 #endif // ROMEO_H
vector< string > joint_names_
Definition: romeo.h:130
hardware_interface::JointStateInterface jnt_state_interface_
Definition: romeo.h:126
controller_manager::ControllerManager * manager_
Definition: romeo.h:99
double low_freq_
Definition: romeo.h:115
boost::shared_ptr< AL::ALProxy > dcm_proxy_
Definition: romeo.h:119
ros::Publisher stiffness_pub_
Definition: romeo.h:91
ROSCONSOLE_DECL void initialize()
Definition: romeo.h:71
vector< double > joint_efforts_
Definition: romeo.h:134
hardware_interface::PositionJointInterface jnt_pos_interface_
Definition: romeo.h:127
void subscribe()
sensor_msgs::JointState m_jointState
Definition: romeo.h:96
AL::ALMemoryProxy memory_proxy_
Definition: romeo.h:118
vector< double > joint_commands_
Definition: romeo.h:131
ros::ServiceServer stiffness_switch_
Definition: romeo.h:97
boost::shared_ptr< AL::ALMotionProxy > m_motionProxy
Definition: romeo.h:120
std_msgs::Float32 stiffness_
Definition: romeo.h:95
vector< double > joint_angles_
Definition: romeo.h:132
ros::Subscriber cmd_vel_sub_
Definition: romeo.h:89
void run(class_loader::ClassLoader *loader)
diagnostic_updater::Updater diagnostic_
Definition: romeo.h:102
vector< double > joint_velocities_
Definition: romeo.h:133
int topic_queue_
Definition: romeo.h:113
bool is_connected_
Definition: romeo.h:108
T * end(T(&ra)[N])
Definition: romeo.h:78
bool stiffnesses_enabled_
Definition: romeo.h:112
ros::Publisher m_jointStatePub
Definition: romeo.h:92
string prefix_
Definition: romeo.h:114
int number_of_joints_
Definition: romeo.h:129
AL::ALValue commands_
Definition: romeo.h:105
string version_
Definition: romeo.h:111
ros::NodeHandle node_handle_
Definition: romeo.h:86
Definition: romeo.h:82
vector< string > joints_names_
Definition: romeo.h:123


romeo_dcm_driver
Author(s): Konstantinos Chatzilygeroudis , Ha Dang
autogenerated on Sun Jul 3 2016 04:02:28