robot.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2008, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 /*
00036  * The robot model tracks the state of the robot.
00037  *
00038  * State path:
00039  *               +---------------+
00040  * Actuators --> | Transmissions | --> Joints
00041  *               +---------------+
00042  *
00043  * Author: Stuart Glaser
00044  */
00045 
00046 #ifndef ROBOT_H
00047 #define ROBOT_H
00048 
00049 #include <vector>
00050 #include <map>
00051 #include <string>
00052 #include <urdf/model.h>
00053 #include <pr2_hardware_interface/hardware_interface.h>
00054 #include <hardware_interface/hardware_interface.h>
00055 #include "pr2_mechanism_model/joint.h"
00056 #include "pr2_mechanism_model/transmission.h"
00057 
00058 class TiXmlElement;
00059 
00060 // Forward declared to avoid extra includes
00061 namespace pluginlib {
00062 template <class T> class ClassLoader;
00063 }
00064 
00065 namespace pr2_mechanism_model
00066 {
00067 
00068 
00078 class Robot
00079 {
00080 public:
00082   Robot(pr2_hardware_interface::HardwareInterface *hw);
00083 
00085   ~Robot() { }
00086 
00088   bool initXml(TiXmlElement *root);
00089 
00091   urdf::Model robot_model_;
00092 
00094   std::vector<boost::shared_ptr<Transmission> > transmissions_;
00095 
00097   int getTransmissionIndex(const std::string &name) const;
00098 
00100   pr2_hardware_interface::Actuator* getActuator(const std::string &name) const;
00101 
00103   boost::shared_ptr<pr2_mechanism_model::Transmission> getTransmission(const std::string &name) const;
00104 
00106   ros::Time getTime();
00107 
00109   pr2_hardware_interface::HardwareInterface* hw_;
00110 
00111 private:
00112   boost::shared_ptr<pluginlib::ClassLoader<pr2_mechanism_model::Transmission> > transmission_loader_;
00113 };
00114 
00115 
00116 
00126 class RobotState : public hardware_interface::HardwareInterface
00127 {
00128 public:
00130   RobotState(Robot *model);
00131 
00133   Robot *model_;
00134 
00136   std::vector<JointState> joint_states_;
00137 
00139   JointState *getJointState(const std::string &name);
00140 
00142   const JointState *getJointState(const std::string &name) const;
00143 
00145   ros::Time getTime() {return model_->getTime();};
00146 
00152   std::vector<std::vector<pr2_hardware_interface::Actuator*> > transmissions_in_;
00153 
00159   std::vector<std::vector<pr2_mechanism_model::JointState*> > transmissions_out_;
00160 
00162   void propagateActuatorPositionToJointPosition();
00164   void propagateJointPositionToActuatorPosition();
00165 
00167   void propagateJointEffortToActuatorEffort();
00169   void propagateActuatorEffortToJointEffort();
00170 
00172   void enforceSafety();
00173 
00175   bool isHalted();
00176 
00178   void zeroCommands();
00179 
00180 
00181   std::map<std::string, JointState*> joint_states_map_;
00182 
00183 };
00184 
00185 }
00186 
00187 #endif


pr2_mechanism_model
Author(s): Eric Berger berger@willowgarage.com, Stuart Glaser, Wim Meeussen
autogenerated on Wed Aug 26 2015 15:37:19