YouBotOODLWrapper.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (c) 2011
00003  * Locomotec
00004  *
00005  * Author:
00006  * Sebastian Blumenthal
00007  *
00008  *
00009  * This software is published under a dual-license: GNU Lesser General Public
00010  * License LGPL 2.1 and BSD license. The dual-license implies that users of this
00011  * code may choose which terms they prefer.
00012  *
00013  * Redistribution and use in source and binary forms, with or without
00014  * modification, are permitted provided that the following conditions are met:
00015  *
00016  * * Redistributions of source code must retain the above copyright
00017  * notice, this list of conditions and the following disclaimer.
00018  * * Redistributions in binary form must reproduce the above copyright
00019  * notice, this list of conditions and the following disclaimer in the
00020  * documentation and/or other materials provided with the distribution.
00021  * * Neither the name of Locomotec nor the names of its
00022  * contributors may be used to endorse or promote products derived from
00023  * this software without specific prior written permission.
00024  *
00025  * This program is free software: you can redistribute it and/or modify
00026  * it under the terms of the GNU Lesser General Public License LGPL as
00027  * published by the Free Software Foundation, either version 2.1 of the
00028  * License, or (at your option) any later version or the BSD license.
00029  *
00030  * This program is distributed in the hope that it will be useful,
00031  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00033  * GNU Lesser General Public License LGPL and the BSD license for more details.
00034  *
00035  * You should have received a copy of the GNU Lesser General Public
00036  * License LGPL and BSD license along with this program.
00037  *
00038  ******************************************************************************/
00039 
00040 #ifndef YOUBOTOODLWRAPPER_H_
00041 #define YOUBOTOODLWRAPPER_H_
00042 
00043 /* Stringification helper macros */
00044 #define mkstr2(X) #X
00045 #define mkstr(X) mkstr2(X)
00046 
00047 /* BOOST includes */
00048 #include <boost/units/io.hpp>
00049 
00050 /* ROS includes */
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 /* OODL includes */
00067 #include "YouBotConfiguration.h"
00068 #include <youbot_driver/youbot/JointTrajectoryController.hpp>
00069 #include <youbot_driver/youbot/DataTrace.hpp>
00070 
00071 //#include <control_msgs/FollowJointTrajectoryAction.h>
00072 //#include <actionlib/server/simple_action_server.h>
00073 
00074 //typedef actionlib::SimpleActionServer<control_msgs::FollowJointTrajectoryAction> Server;
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     /* Coordination: */
00099 
00104     void initializeBase(std::string baseName);
00105 
00111     void initializeArm(std::string armName, bool enableStandardGripper = true);
00112 
00117     void stop();
00118 
00119 
00120     /* Communication: */
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     /* Computation: */
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     /* Configuration: */
00206 
00208     YouBotConfiguration youBotConfiguration;
00209 
00210 private:
00211 
00212     YouBotOODLWrapper(); //forbid default constructor
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     //void executeActionServer(const control_msgs::FollowJointTrajectoryGoalConstPtr& goal,  int armIndex);
00264     
00265     //bool trajectoryActionServerEnable;
00266     //double trajectoryVelocityGain;
00267     //double trajectoryPositionGain;
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 } // namespace youBot
00287 
00288 #endif /* YOUBOTOODLWRAPPER_H_ */
00289 
00290 /* EOF */


youbot_driver_ros_interface
Author(s): Sebastian Blumenthal
autogenerated on Thu Jun 6 2019 20:43:35