actuator_state_interface.h
Go to the documentation of this file.
1 // Copyright (C) 2012, hiDOF INC.
3 // Copyright (C) 2013, PAL Robotics S.L.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 // * Redistributions of source code must retain the above copyright notice,
8 // this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of hiDOF, Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived from
14 // this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 // POSSIBILITY OF SUCH DAMAGE.
28 
30 
31 #ifndef HARDWARE_INTERFACE_ACTUATOR_STATE_INTERFACE_H
32 #define HARDWARE_INTERFACE_ACTUATOR_STATE_INTERFACE_H
33 
35 #include <string>
36 
37 namespace hardware_interface
38 {
39 
42 {
43 public:
44  ActuatorStateHandle() : name_(), pos_(0), vel_(0), eff_(0) {}
45 
52  ActuatorStateHandle(const std::string& name, const double* pos, const double* vel, const double* eff)
53  : name_(name), pos_(pos), vel_(vel), eff_(eff)
54  {
55  if (!pos)
56  {
57  throw HardwareInterfaceException("Cannot create handle '" + name + "'. Position data pointer is null.");
58  }
59  if (!vel)
60  {
61  throw HardwareInterfaceException("Cannot create handle '" + name + "'. Velocity data pointer is null.");
62  }
63  if (!eff)
64  {
65  throw HardwareInterfaceException("Cannot create handle '" + name + "'. Effort data pointer is null.");
66  }
67  }
68 
69  std::string getName() const {return name_;}
70  double getPosition() const {assert(pos_); return *pos_;}
71  double getVelocity() const {assert(vel_); return *vel_;}
72  double getEffort() const {assert(eff_); return *eff_;}
73 
74  const double* getPositionPtr() const {return pos_;}
75  const double* getVelocityPtr() const {return vel_;}
76  const double* getEffortPtr() const {return eff_;}
77 
78 private:
79  std::string name_;
80  const double* pos_;
81  const double* vel_;
82  const double* eff_;
83 };
84 
92 class ActuatorStateInterface : public HardwareResourceManager<ActuatorStateHandle> {};
93 
94 }
95 
96 #endif
An exception related to a HardwareInterface.
Hardware interface to support reading the state of an array of actuators.
Base class for handling hardware resources.
ActuatorStateHandle(const std::string &name, const double *pos, const double *vel, const double *eff)


hardware_interface
Author(s): Wim Meeussen, Adolfo Rodriguez Tsouroukdissian
autogenerated on Mon Apr 20 2020 03:52:05