abs_hand_command.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Software License Agreement (BSD License)
4 #
5 # Copyright (c) 2013, Tokyo Opensource Robotics Kyokai Association
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 #
12 # * Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # * Redistributions in binary form must reproduce the above
15 # copyright notice, this list of conditions and the following
16 # disclaimer in the documentation and/or other materials provided
17 # with the distribution.
18 # * Neither the name of Tokyo Opensource Robotics Kyokai Association. nor the
19 # names of its contributors may be used to endorse or promote products
20 # derived from this software without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
34 #
35 # Author: Isaac Isao Saito
36 
37 import rospy
38 
39 
40 class AbsractHandCommand(object):
41  '''
42  Following Command design pattern, this class represents an abstract
43  command for hand classes of NEXTAGE OPEN.
44  '''
45  # TODO: Unittest is needed!!DIO_V
46 
47  def __init__(self, hands, hand, dio_pins):
48  '''
49  @type hands: nextage_ros_bridge.base_hands.BaseHands
50  @type hand: str
51  @param hand: Side of hand. Variables that are defined in
52  nextage_ros_bridge.base_hands.BaseHands can be used
53  { HAND_L, HAND_R }.
54  @type dio_pins: [int]
55  @param dio_pins: List of DIO pins that are used in each HandCommand
56  class. The order is important; it needs be defined
57  in subclasses.
58  '''
59  self._hands = hands
60  self._hand = hand
61  self._assign_dio_names(dio_pins)
62 
63  def execute(self, operation):
64  '''
65  Needs overriddedn, otherwise expcetion occurs.
66 
67  @type operation: str
68  @param operation: name of the operation.
69  @rtype: bool
70  @return: True if dout was writtable to the register. False otherwise.
71 
72  @raise exception: RuntimeError
73  '''
74  msg = 'AbsractHandCommand.execute() not extended.'
75  rospy.logerr(msg)
76  raise NotImplementedError(msg)
77 
78  def _assign_dio_names(self, dio_pins):
79  '''
80  It's recommended in the derived classes to re-assign DIO names to
81  better represent the specific purposes of each DIO pin in there.
82  Since doing so isn' mandatory, this method doesn't emit error even when
83  it's not implemented.
84  @type dio_pins: [int]
85  @param dio_pins: List of DIO pins that are used in each HandCommand
86  class. The order is important; it needs be defined
87  in subclasses.
88  '''
89  pass


nextage_ros_bridge
Author(s): Isaac Isao Saito , Akio Ochiai
autogenerated on Wed Jun 17 2020 04:14:47