Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef YOUBOTOODLWRAPPER_H_
00041 #define YOUBOTOODLWRAPPER_H_
00042
00043
00044 #define mkstr2(X) #X
00045 #define mkstr(X) mkstr2(X)
00046
00047
00048 #include <boost/units/io.hpp>
00049
00050
00051 #include "geometry_msgs/Twist.h"
00052 #include "tf/transform_broadcaster.h"
00053 #include "nav_msgs/Odometry.h"
00054 #include "std_srvs/Empty.h"
00055 #include "diagnostic_msgs/DiagnosticStatus.h"
00056 #include <diagnostic_msgs/DiagnosticArray.h>
00057
00058 #include <pr2_msgs/PowerBoardState.h>
00059
00060 #include "trajectory_msgs/JointTrajectory.h"
00061 #include "sensor_msgs/JointState.h"
00062
00063 #include "brics_actuator/JointPositions.h"
00064 #include "brics_actuator/JointVelocities.h"
00065
00066
00067 #include "YouBotConfiguration.h"
00068 #include <youbot_driver/youbot/JointTrajectoryController.hpp>
00069 #include <youbot_driver/youbot/DataTrace.hpp>
00070
00071
00072
00073
00074
00075
00076 namespace youBot
00077 {
00078
00082 class YouBotOODLWrapper
00083 {
00084 public:
00085
00090 YouBotOODLWrapper(ros::NodeHandle n);
00091
00095 virtual ~YouBotOODLWrapper();
00096
00097
00098
00099
00104 void initializeBase(std::string baseName);
00105
00111 void initializeArm(std::string armName, bool enableStandardGripper = true);
00112
00117 void stop();
00118
00119
00120
00121
00126 void baseCommandCallback(const geometry_msgs::Twist& youbotBaseCommand);
00127
00136 void armCommandCallback(const trajectory_msgs::JointTrajectory& youbotArmCommand);
00137
00143 void armPositionsCommandCallback(const brics_actuator::JointPositionsConstPtr& youbotArmCommand, int armIndex);
00144
00150 void armVelocitiesCommandCallback(const brics_actuator::JointVelocitiesConstPtr& youbotArmCommand, int armIndex);
00151
00157 void armJointTrajectoryGoalCallback(actionlib::ActionServer<control_msgs::FollowJointTrajectoryAction>::GoalHandle youbotArmGoal, unsigned int armIndex);
00158
00164 void armJointTrajectoryCancelCallback(actionlib::ActionServer<control_msgs::FollowJointTrajectoryAction>::GoalHandle youbotArmGoal, unsigned int armIndex);
00165
00171 void gripperPositionsCommandCallback(const brics_actuator::JointPositionsConstPtr& youbotGripperCommand, int armIndex);
00172
00179 void publishOODLSensorReadings();
00180
00184 void publishArmAndBaseDiagnostics(double publish_rate_in_secs);
00185
00186
00187
00191 void computeOODLSensorReadings();
00192
00193 bool switchOffBaseMotorsCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
00194
00195 bool switchOnBaseMotorsCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
00196
00197 bool switchOffArmMotorsCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response, int armIndex);
00198
00199 bool switchOnArmMotorsCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response, int armIndex);
00200
00201 bool calibrateArmCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response, int armIndex);
00202
00203 bool reconnectCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
00204
00205
00206
00208 YouBotConfiguration youBotConfiguration;
00209
00210 private:
00211
00212 YouBotOODLWrapper();
00213
00214
00216 static const int youBotArmDoF = 5;
00217
00219 static const int youBotNumberOfFingers = 2;
00220
00222 static const int youBotNumberOfWheels = 4;
00223
00224
00225 std::string youBotChildFrameID;
00226 std::string youBotOdometryFrameID;
00227 std::string youBotOdometryChildFrameID;
00228 std::string youBotArmFrameID;
00229
00230
00232 ros::NodeHandle node;
00233
00235 ros::Time currentTime;
00236
00237
00239 nav_msgs::Odometry odometryMessage;
00240
00242 geometry_msgs::TransformStamped odometryTransform;
00243
00245 geometry_msgs::Quaternion odometryQuaternion;
00246
00248 sensor_msgs::JointState baseJointStateMessage;
00249
00251 vector<sensor_msgs::JointState> armJointStateMessages;
00252
00254 actionlib::ActionServer<control_msgs::FollowJointTrajectoryAction>::GoalHandle armActiveJointTrajectoryGoal;
00255
00257 bool armHasActiveJointTrajectoryGoal;
00258
00259 youbot::GripperSensedBarPosition gripperBar1Position;
00260 youbot::GripperSensedBarPosition gripperBar2Position;
00261 int gripperCycleCounter;
00262
00263
00264
00265
00266
00267
00268 double youBotDriverCycleFrequencyInHz;
00269
00271 ros::Time lastDiagnosticPublishTime;
00272
00273 ros::Publisher dashboardMessagePublisher;
00274 pr2_msgs::PowerBoardState platformStateMessage;
00275
00276 ros::Publisher diagnosticArrayPublisher;
00277 diagnostic_msgs::DiagnosticArray diagnosticArrayMessage;
00278 diagnostic_msgs::DiagnosticStatus diagnosticStatusMessage;
00279 std::string diagnosticNameArm;
00280 std::string diagnosticNameBase;
00281
00282 bool areBaseMotorsSwitchedOn;
00283 bool areArmMotorsSwitchedOn;
00284 };
00285
00286 }
00287
00288 #endif
00289
00290