hekateros_control.h
Go to the documentation of this file.
00001 
00002 //
00003 // Package:   RoadNarrows Robotics Hekateros Robotiic Manipulator ROS Package
00004 //
00005 // Link:      https://github.com/roadnarrows-robotics/hekateros
00006 //
00007 // ROS Node:  hekateros_control
00008 //
00009 // File:      hekateros_control.h
00010 //
00026 /*
00027  * @EulaBegin@
00028  * 
00029  * Permission is hereby granted, without written agreement and without
00030  * license or royalty fees, to use, copy, modify, and distribute this
00031  * software and its documentation for any purpose, provided that
00032  * (1) The above copyright notice and the following two paragraphs
00033  * appear in all copies of the source code and (2) redistributions
00034  * including binaries reproduces these notices in the supporting
00035  * documentation.   Substantial modifications to this software may be
00036  * copyrighted by their authors and need not follow the licensing terms
00037  * described here, provided that the new terms are clearly indicated in
00038  * all files where they apply.
00039  * 
00040  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
00041  * OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
00042  * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
00043  * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
00044  * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
00045  * THE POSSIBILITY OF SUCH DAMAGE.
00046  * 
00047  * THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
00048  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
00049  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
00050  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
00051  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
00052  * 
00053  * @EulaEnd@
00054  */
00056 
00057 #ifndef _HEKATEROS_CONTROL_H
00058 #define _HEKATEROS_CONTROL_H
00059 
00060 //
00061 // System
00062 //
00063 #include <string>
00064 #include <map>
00065 
00066 //
00067 // Boost libraries
00068 //
00069 #include <boost/bind.hpp>
00070 
00071 //
00072 // ROS
00073 //
00074 #include "ros/ros.h"
00075 #include "actionlib/server/simple_action_server.h"
00076 #include "control_msgs/FollowJointTrajectoryAction.h"
00077 
00078 //
00079 // ROS generated core, industrial, and hekateros messages.
00080 //
00081 #include "trajectory_msgs/JointTrajectory.h"
00082 #include "sensor_msgs/JointState.h"
00083 #include "industrial_msgs/RobotStatus.h"
00084 #include "hekateros_control/HekJointStateExtended.h"
00085 #include "hekateros_control/HekRobotStatusExtended.h"
00086 
00087 //
00088 // ROS generatated hekateros services.
00089 //
00090 #include "hekateros_control/Calibrate.h"
00091 #include "hekateros_control/ClearAlarms.h"
00092 #include "hekateros_control/CloseGripper.h"
00093 #include "hekateros_control/EStop.h"
00094 #include "hekateros_control/Freeze.h"
00095 #include "hekateros_control/GetProductInfo.h"
00096 #include "hekateros_control/GotoBalancedPos.h"
00097 #include "hekateros_control/GotoParkedPos.h"
00098 #include "hekateros_control/GotoZeroPt.h"
00099 #include "hekateros_control/IsAlarmed.h"
00100 #include "hekateros_control/IsCalibrated.h"
00101 #include "hekateros_control/IsDescLoaded.h"
00102 #include "hekateros_control/OpenGripper.h"
00103 #include "hekateros_control/Release.h"
00104 #include "hekateros_control/ResetEStop.h"
00105 #include "hekateros_control/SetRobotMode.h"
00106 #include "hekateros_control/Stop.h"
00107 
00108 //
00109 // ROS generated action servers.
00110 //
00111 #include "hekateros_control/CalibrateAction.h"
00112 
00113 //
00114 // RoadNarrows
00115 //
00116 #include "rnr/rnrconfig.h"
00117 #include "rnr/log.h"
00118 
00119 //
00120 // RoadNarrows embedded hekateros library.
00121 //
00122 #include "Hekateros/hekateros.h"
00123 #include "Hekateros/hekXmlCfg.h"
00124 #include "Hekateros/hekRobot.h"
00125 
00126 //
00127 // Node headers.
00128 //
00129 #include "hekateros_control.h"
00130 
00131 
00132 namespace hekateros_control
00133 {
00137   class HekaterosControl
00138   {
00139   public:
00141     typedef std::map<std::string, ros::ServiceServer> MapServices;
00142 
00144     typedef std::map<std::string, ros::ServiceClient> MapClientServices;
00145     
00147     typedef std::map<std::string, ros::Publisher> MapPublishers;
00148 
00150     typedef std::map<std::string, ros::Subscriber> MapSubscriptions;
00151 
00158     HekaterosControl(ros::NodeHandle &nh, double hz);
00159 
00163     virtual ~HekaterosControl();
00164 
00172     virtual int configure(const std::string &strCfgFile);
00173 
00184     int connect(const std::string &strDevDynabus,
00185                 int                nBaudRateDynabus,
00186                 const std::string &strDevArduino,
00187                 int                nBaudRateArduino)
00188     {
00189       m_robot.connect(strDevDynabus, nBaudRateDynabus,
00190                       strDevArduino, nBaudRateArduino);
00191     }
00192 
00198     int disconnect()
00199     {
00200       m_robot.disconnect();
00201     }
00202 
00206     virtual void advertiseServices();
00207 
00211     virtual void clientServices()
00212     {
00213       // No client services
00214     }
00215 
00221     virtual void advertisePublishers(int nQueueDepth=10);
00222 
00228     virtual void subscribeToTopics(int nQueueDepth=10);
00229 
00235     virtual void publish();
00236 
00242     ros::NodeHandle &getNodeHandle()
00243     {
00244       return m_nh;
00245     }
00246 
00252     hekateros::HekRobot &getRobot()
00253     {
00254       return m_robot;
00255     }
00256 
00263     void updateJointStateMsg(hekateros::HekJointStatePoint &state,
00264                              sensor_msgs::JointState       &msg);
00265 
00273     void updateExtendedJointStateMsg(hekateros::HekJointStatePoint &state,
00274                                      HekJointStateExtended         &msg);
00275 
00282     void updateRobotStatusMsg(hekateros::HekRobotState     &status,
00283                               industrial_msgs::RobotStatus &msg);
00284 
00291     void updateExtendedRobotStatusMsg(hekateros::HekRobotState &status,
00292                                       HekRobotStatusExtended   &msg);
00293 
00294   protected:
00295     ros::NodeHandle    &m_nh;     
00296     double              m_hz;     
00297     hekateros::HekRobot m_robot;  
00298 
00299     // ROS services, publishers, subscriptions.
00300     MapServices       m_services;       
00301     MapClientServices m_clientServices; 
00302     MapPublishers     m_publishers;     
00303     MapSubscriptions  m_subscriptions;  
00304 
00305     // Messages for published data.
00306     sensor_msgs::JointState       m_msgJointState;  
00307     HekJointStateExtended         m_msgJointStateEx;
00309     industrial_msgs::RobotStatus  m_msgRobotStatus; 
00310     HekRobotStatusExtended        m_msgRobotStatusEx;
00312 
00313     // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
00314     // Service callbacks
00315     // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
00316 
00325     bool calibrate(hekateros_control::Calibrate::Request  &req,
00326                    hekateros_control::Calibrate::Response &rsp);
00327 
00336     bool clearAlarms(hekateros_control::ClearAlarms::Request  &req,
00337                      hekateros_control::ClearAlarms::Response &rsp);
00338 
00347     bool closeGripper(hekateros_control::CloseGripper::Request  &req,
00348                       hekateros_control::CloseGripper::Response &rsp);
00349 
00358     bool estop(hekateros_control::EStop::Request  &req,
00359                hekateros_control::EStop::Response &rsp);
00360 
00369     bool freeze(hekateros_control::Freeze::Request  &req,
00370                 hekateros_control::Freeze::Response &rsp);
00371 
00380     bool getProductInfo(hekateros_control::GetProductInfo::Request  &req,
00381                         hekateros_control::GetProductInfo::Response &rsp);
00382 
00391     bool gotoBalancedPos(hekateros_control::GotoBalancedPos::Request  &req,
00392                          hekateros_control::GotoBalancedPos::Response &rsp);
00393 
00402     bool gotoParkedPos(hekateros_control::GotoParkedPos::Request  &req,
00403                        hekateros_control::GotoParkedPos::Response &rsp);
00404 
00413     bool gotoZeroPt(hekateros_control::GotoZeroPt::Request  &req,
00414                     hekateros_control::GotoZeroPt::Response &rsp);
00415 
00424     bool isAlarmed(hekateros_control::IsAlarmed::Request  &req,
00425                    hekateros_control::IsAlarmed::Response &rsp);
00426 
00435     bool isCalibrated(hekateros_control::IsCalibrated::Request  &req,
00436                       hekateros_control::IsCalibrated::Response &rsp);
00437 
00446     bool isDescLoaded(hekateros_control::IsDescLoaded::Request  &req,
00447                       hekateros_control::IsDescLoaded::Response &rsp);
00448 
00457     bool openGripper(hekateros_control::OpenGripper::Request  &req,
00458                      hekateros_control::OpenGripper::Response &rsp);
00459 
00468     bool release(hekateros_control::Release::Request  &req,
00469                  hekateros_control::Release::Response &rsp);
00470 
00479     bool resetEStop(hekateros_control::ResetEStop::Request  &req,
00480                     hekateros_control::ResetEStop::Response &rsp);
00481 
00490     bool setRobotMode(hekateros_control::SetRobotMode::Request  &req,
00491                       hekateros_control::SetRobotMode::Response &rsp);
00492 
00501     bool stop(hekateros_control::Stop::Request  &req,
00502               hekateros_control::Stop::Response &rsp);
00503 
00504 
00505     // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
00506     // Topic Publishers
00507     // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
00508 
00512     void publishJointState();
00513 
00517     void publishRobotStatus();
00518 
00519 
00520     // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
00521     // Subscribed Topic Callbacks
00522     // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
00523 
00529     void execJointCmd(const trajectory_msgs::JointTrajectory &jt);
00530   };
00531 
00532 } // namespace hc
00533 
00534 
00535 #endif // _HEKATEROS_CONTROL_H


hekateros_control
Author(s): Robin Knight , Daniel Packard
autogenerated on Mon Oct 6 2014 00:36:42