robot.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /*
36  * The robot model tracks the state of the robot.
37  *
38  * State path:
39  * +---------------+
40  * Actuators --> | Transmissions | --> Joints
41  * +---------------+
42  *
43  * Author: Stuart Glaser
44  */
45 
46 #ifndef ROBOT_H
47 #define ROBOT_H
48 
49 #include <vector>
50 #include <map>
51 #include <string>
52 #include <urdf/model.h>
54 #include <hardware_interface/hardware_interface.h>
57 
58 class TiXmlElement;
59 
60 // Forward declared to avoid extra includes
61 namespace pluginlib {
62 template <class T> class ClassLoader;
63 }
64 
65 namespace pr2_mechanism_model
66 {
67 
68 
78 class Robot
79 {
80 public:
83 
85  ~Robot() { }
86 
88  bool initXml(TiXmlElement *root);
89 
92 
94  std::vector<boost::shared_ptr<Transmission> > transmissions_;
95 
97  int getTransmissionIndex(const std::string &name) const;
98 
100  pr2_hardware_interface::Actuator* getActuator(const std::string &name) const;
101 
104 
106  ros::Time getTime();
107 
110 
111 private:
113 };
114 
115 
116 
127 {
128 public:
130  RobotState(Robot *model);
131 
134 
136  std::vector<JointState> joint_states_;
137 
139  JointState *getJointState(const std::string &name);
140 
142  const JointState *getJointState(const std::string &name) const;
143 
145  ros::Time getTime() {return model_->getTime();};
146 
152  std::vector<std::vector<pr2_hardware_interface::Actuator*> > transmissions_in_;
153 
159  std::vector<std::vector<pr2_mechanism_model::JointState*> > transmissions_out_;
160 
165 
170 
172  void enforceSafety();
173 
175  bool isHalted();
176 
178  void zeroCommands();
179 
180 
181  std::map<std::string, JointState*> joint_states_map_;
182 
183 };
184 
185 }
186 
187 #endif
pr2_mechanism_model::Robot::getTransmissionIndex
int getTransmissionIndex(const std::string &name) const
get the transmission index based on the transmission name. Returns -1 on failure
Definition: robot.cpp:138
pr2_mechanism_model::RobotState::propagateJointEffortToActuatorEffort
void propagateJointEffortToActuatorEffort()
Propagete the joint efforts, through the transmissions, to the actuator efforts.
Definition: robot.cpp:235
pr2_mechanism_model::JointState
Definition: joint.h:103
pr2_mechanism_model::Robot::getTime
ros::Time getTime()
Get the time when the current controller cycle was started.
Definition: robot.cpp:121
boost::shared_ptr
pr2_mechanism_model
Definition: chain.h:41
pr2_mechanism_model::RobotState::RobotState
RobotState(Robot *model)
constructor
Definition: robot.cpp:158
pr2_mechanism_model::Robot::getTransmission
boost::shared_ptr< pr2_mechanism_model::Transmission > getTransmission(const std::string &name) const
get a transmission pointer based on the transmission name. Returns NULL on failure
Definition: robot.cpp:148
hardware_interface::HardwareInterface
pr2_mechanism_model::Robot::getActuator
pr2_hardware_interface::Actuator * getActuator(const std::string &name) const
get an actuator pointer based on the actuator name. Returns NULL on failure
Definition: robot.cpp:143
pr2_mechanism_model::RobotState::enforceSafety
void enforceSafety()
Modify the commanded_effort_ of each joint state so that the joint limits are satisfied.
Definition: robot.cpp:256
pr2_mechanism_model::Robot::transmissions_
std::vector< boost::shared_ptr< Transmission > > transmissions_
The list of transmissions.
Definition: robot.h:94
urdf::Model
pr2_hardware_interface::HardwareInterface
hardware_interface.h
joint.h
pr2_mechanism_model::RobotState::propagateActuatorPositionToJointPosition
void propagateActuatorPositionToJointPosition()
Propagete the actuator positions, through the transmissions, to the joint positions.
Definition: robot.cpp:221
pr2_mechanism_model::Robot::~Robot
~Robot()
Destructor.
Definition: robot.h:85
pr2_mechanism_model::RobotState
This class provides the controllers with an interface to the robot state.
Definition: robot.h:126
pr2_mechanism_model::RobotState::getJointState
JointState * getJointState(const std::string &name)
Get a joint state by name.
Definition: robot.cpp:203
model.h
pr2_mechanism_model::Robot::Robot
Robot(pr2_hardware_interface::HardwareInterface *hw)
Constructor.
Definition: robot.cpp:46
pr2_mechanism_model::Robot::robot_model_
urdf::Model robot_model_
The kinematic/dynamic model of the robot.
Definition: robot.h:91
transmission.h
pr2_mechanism_model::Robot
This class provides the controllers with an interface to the robot model.
Definition: robot.h:78
pluginlib
pr2_mechanism_model::RobotState::joint_states_map_
std::map< std::string, JointState * > joint_states_map_
Definition: robot.h:181
pr2_mechanism_model::Robot::hw_
pr2_hardware_interface::HardwareInterface * hw_
a pointer to the pr2 hardware interface. Only for advanced users
Definition: robot.h:109
pr2_mechanism_model::Robot::initXml
bool initXml(TiXmlElement *root)
Initialize the robot model form xml.
Definition: robot.cpp:51
pr2_mechanism_model::RobotState::joint_states_
std::vector< JointState > joint_states_
The vector of joint states, in no particular order.
Definition: robot.h:136
pr2_mechanism_model::RobotState::getTime
ros::Time getTime()
Get the time when the current controller cycle was started.
Definition: robot.h:145
pr2_mechanism_model::RobotState::propagateJointPositionToActuatorPosition
void propagateJointPositionToActuatorPosition()
Propagete the joint positions, through the transmissions, to the actuator positions.
Definition: robot.cpp:270
ros::Time
pr2_mechanism_model::RobotState::isHalted
bool isHalted()
Checks if one (or more) of the motors are halted.
Definition: robot.cpp:244
pr2_mechanism_model::RobotState::transmissions_out_
std::vector< std::vector< pr2_mechanism_model::JointState * > > transmissions_out_
Definition: robot.h:159
pr2_mechanism_model::RobotState::zeroCommands
void zeroCommands()
Set the commanded_effort_ of each joint state to zero.
Definition: robot.cpp:264
pr2_mechanism_model::RobotState::model_
Robot * model_
The robot model containing the transmissions, urdf robot model, and hardware interface.
Definition: robot.h:133
pr2_mechanism_model::RobotState::propagateActuatorEffortToJointEffort
void propagateActuatorEffortToJointEffort()
Propagete the actuator efforts, through the transmissions, to the joint efforts.
Definition: robot.cpp:279
pr2_mechanism_model::RobotState::transmissions_in_
std::vector< std::vector< pr2_hardware_interface::Actuator * > > transmissions_in_
Definition: robot.h:145
pr2_hardware_interface::Actuator
pr2_mechanism_model::Robot::transmission_loader_
boost::shared_ptr< pluginlib::ClassLoader< pr2_mechanism_model::Transmission > > transmission_loader_
Definition: robot.h:112


pr2_mechanism_model
Author(s): Eric Berger berger@willowgarage.com, Stuart Glaser, Wim Meeussen
autogenerated on Mon Mar 6 2023 03:49:17