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 /* ROS includes */
00048 #include <geometry_msgs/Twist.h>
00049 #include <tf/transform_broadcaster.h>
00050 #include <nav_msgs/Odometry.h>
00051 #include <std_srvs/Empty.h>
00052 #include <diagnostic_msgs/DiagnosticStatus.h>
00053 #include <diagnostic_msgs/DiagnosticArray.h>
00054 #include <youbot_oodl/PowerBoardState.h>
00055 
00056 #include <trajectory_msgs/JointTrajectory.h>
00057 #include <sensor_msgs/JointState.h>
00058 
00059 #include <brics_actuator/JointPositions.h>
00060 #include <brics_actuator/JointVelocities.h>
00061 
00062 /* OODL includes */
00063 #include <youbot_oodl/YouBotConfiguration.h>
00064 #include <youbot_driver/youbot/JointTrajectoryController.hpp>
00065 #include <youbot_driver/youbot/DataTrace.hpp>
00066 
00067 //#include <control_msgs/FollowJointTrajectoryAction.h>
00068 //#include <actionlib/server/simple_action_server.h>
00069 
00070 //typedef actionlib::SimpleActionServer<control_msgs::FollowJointTrajectoryAction> Server;
00071 
00072 namespace youBot
00073 {
00074 
00078 class YouBotOODLWrapper
00079 {
00080 public:
00081 
00086   YouBotOODLWrapper(ros::NodeHandle n);
00087 
00091   virtual ~YouBotOODLWrapper();
00092 
00093   /* Coordination: */
00094 
00099   void initializeBase(std::string baseName);
00100 
00106   void initializeArm(std::string armName, bool enableStandardGripper = true);
00107 
00112   void stop();
00113 
00114   /* Communication: */
00115 
00120   void baseCommandCallback(const geometry_msgs::Twist& youbotBaseCommand);
00121 
00130   void armCommandCallback(const trajectory_msgs::JointTrajectory& youbotArmCommand);
00131 
00137   void armPositionsCommandCallback(const brics_actuator::JointPositionsConstPtr& youbotArmCommand, int armIndex);
00138 
00144   void armVelocitiesCommandCallback(const brics_actuator::JointVelocitiesConstPtr& youbotArmCommand, int armIndex);
00145 
00151   void armJointTrajectoryGoalCallback(
00152       actionlib::ActionServer<control_msgs::FollowJointTrajectoryAction>::GoalHandle youbotArmGoal,
00153       unsigned int armIndex);
00154 
00160   void armJointTrajectoryCancelCallback(
00161       actionlib::ActionServer<control_msgs::FollowJointTrajectoryAction>::GoalHandle youbotArmGoal,
00162       unsigned int armIndex);
00163 
00169   void gripperPositionsCommandCallback(const brics_actuator::JointPositionsConstPtr& youbotGripperCommand,
00170                                        int armIndex);
00171 
00178   void publishOODLSensorReadings();
00179 
00183   void publishArmAndBaseDiagnostics(double publish_rate_in_secs);
00184 
00185   /* Computation: */
00186 
00190   void computeOODLSensorReadings();
00191 
00192   bool switchOffBaseMotorsCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
00193 
00194   bool switchOnBaseMotorsCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
00195 
00196   bool switchOffArmMotorsCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response, int armIndex);
00197 
00198   bool switchOnArmMotorsCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response, int armIndex);
00199 
00200   bool calibrateArmCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response, int armIndex);
00201 
00202   bool reconnectCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
00203 
00204   /* Configuration: */
00205 
00207   YouBotConfiguration youBotConfiguration;
00208 
00209 private:
00210 
00211   YouBotOODLWrapper(); //forbid default constructor
00212 
00214   static const int youBotArmDoF = 5;
00215 
00217   static const int youBotNumberOfFingers = 2;
00218 
00220   static const int youBotNumberOfWheels = 4;
00221 
00222   std::string youBotChildFrameID;
00223   std::string youBotOdometryFrameID;
00224   std::string youBotOdometryChildFrameID;
00225   std::string youBotArmFrameID;
00226 
00228   ros::NodeHandle node;
00229 
00231   ros::Time currentTime;
00232 
00234   nav_msgs::Odometry odometryMessage;
00235 
00237   geometry_msgs::TransformStamped odometryTransform;
00238 
00240   geometry_msgs::Quaternion odometryQuaternion;
00241 
00243   sensor_msgs::JointState baseJointStateMessage;
00244 
00246   vector<sensor_msgs::JointState> armJointStateMessages;
00247 
00249   actionlib::ActionServer<control_msgs::FollowJointTrajectoryAction>::GoalHandle armActiveJointTrajectoryGoal;
00250 
00252   bool armHasActiveJointTrajectoryGoal;
00253 
00254   youbot::GripperSensedBarPosition gripperBar1Position;
00255   youbot::GripperSensedBarPosition gripperBar2Position;
00256   int gripperCycleCounter;
00257 
00258   //void executeActionServer(const control_msgs::FollowJointTrajectoryGoalConstPtr& goal,  int armIndex);
00259 
00260   //bool trajectoryActionServerEnable;
00261   //double trajectoryVelocityGain;
00262   //double trajectoryPositionGain;
00263   double youBotDriverCycleFrequencyInHz;
00264 
00266   ros::Time lastDiagnosticPublishTime;
00267 
00268   ros::Publisher dashboardMessagePublisher;
00269   youbot_oodl::PowerBoardState platformStateMessage;
00270 
00271   ros::Publisher diagnosticArrayPublisher;
00272   diagnostic_msgs::DiagnosticArray diagnosticArrayMessage;
00273   diagnostic_msgs::DiagnosticStatus diagnosticStatusMessage;
00274   std::string diagnosticNameArms;
00275   std::string diagnosticNameBase;
00276 
00277   bool areBaseMotorsSwitchedOn;
00278   bool areArmMotorsSwitchedOn;
00279 };
00280 
00281 } // namespace youBot
00282 
00283 #endif /* YOUBOTOODLWRAPPER_H_ */
00284 
00285 /* EOF */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


youbot_oodl
Author(s): Sebastian Blumenthal
autogenerated on Fri Jul 26 2013 12:00:42