Revision 465c7ad7 client/python/hlrc_client/RobotController.py
client/python/hlrc_client/RobotController.py | ||
---|---|---|
41 | 41 |
# create nice and actually usable formatter and add it to the handler |
42 | 42 |
self.config_logger(loglevel) |
43 | 43 |
|
44 |
#store |
|
44 |
# store
|
|
45 | 45 |
self.scope = scope |
46 | 46 |
self.mw = mw_name |
47 | 47 |
self.loglevel = loglevel |
48 | 48 |
|
49 | 49 |
self.middleware = None |
50 | 50 |
|
51 |
|
|
52 | 51 |
if (self.mw.upper() == "RSB"): |
53 | 52 |
self.logger.info("creating new middleware connection via RSB") |
54 | 53 |
try: |
... | ... | |
57 | 56 |
self.logger.error("failed to import RSB or the necessary data types: {}".format(e)) |
58 | 57 |
sys.exit(errno.EINVAL) |
59 | 58 |
|
60 |
#import worked, safe to intantiate RSB mw now |
|
59 |
# import worked, safe to intantiate RSB mw now
|
|
61 | 60 |
self.middleware = MiddlewareRSB(self.scope, self.loglevel) |
62 | 61 |
|
63 | 62 |
elif (self.mw.upper() == "ROS"): |
... | ... | |
68 | 67 |
self.logger.error("failed to import ROS or the necessary data types: {}".format(e)) |
69 | 68 |
sys.exit(errno.EINVAL) |
70 | 69 |
|
71 |
#import worked, safe to intantiate RSB mw now |
|
70 |
# import worked, safe to intantiate RSB mw now
|
|
72 | 71 |
self.middleware = MiddlewareROS(self.scope, self.loglevel) |
73 | 72 |
else: |
74 | 73 |
self.logger.error("invalid middleware requested (%s). supported: {ROS, RSB}\n\n" % (self.mw)) |
... | ... | |
88 | 87 |
""" |
89 | 88 |
formatter = logging.Formatter('%(asctime)s %(name)-30s %(levelname)-8s > %(message)s') |
90 | 89 |
ch = logging.StreamHandler() |
91 |
#ch.setLevel(level) |
|
90 |
# ch.setLevel(level)
|
|
92 | 91 |
ch.setFormatter(formatter) |
93 | 92 |
self.logger.setLevel(level) |
94 | 93 |
self.logger.addHandler(ch) |
95 | 94 |
|
96 |
def set_current_emotion(self, robot_emotion, blocking = False):
|
|
95 |
def set_current_emotion(self, robot_emotion, blocking=False):
|
|
97 | 96 |
"""set the current emotion |
98 | 97 |
:param robot_emotion: a RobotEmotion object |
99 | 98 |
:param blocking: should this call block during execution? |
... | ... | |
101 | 100 |
self.logger.debug("set_current_emotion(%s) %s" % (robot_emotion, ("BLOCKING" if blocking else "NON_BLOCKING"))) |
102 | 101 |
self.middleware.set_current_emotion(robot_emotion, blocking) |
103 | 102 |
|
104 |
def set_default_emotion(self, robot_emotion, blocking = False):
|
|
103 |
def set_default_emotion(self, robot_emotion, blocking=False):
|
|
105 | 104 |
"""set the default emotion |
106 | 105 |
:param robot_emotion: a RobotEmotion object |
107 | 106 |
:param blocking: should this call block during execution? |
... | ... | |
109 | 108 |
self.logger.debug("set_default_emotion(%s) %s" % (robot_emotion, ("BLOCKING" if blocking else "NON_BLOCKING"))) |
110 | 109 |
self.middleware.set_default_emotion(robot_emotion, blocking) |
111 | 110 |
|
112 |
def set_gaze_target(self, robot_gaze, blocking = False):
|
|
111 |
def set_gaze_target(self, robot_gaze, blocking=False):
|
|
113 | 112 |
"""set a gaze target |
114 | 113 |
:param robot_gaze: a RobotGaze object |
115 | 114 |
:param blocking: should this call block during execution? |
... | ... | |
118 | 117 |
self.logger.debug("set_gaze_target(%s) %s" % (robot_gaze, ("BLOCKING" if blocking else "NON_BLOCKING"))) |
119 | 118 |
self.middleware.set_gaze_target(robot_gaze, blocking) |
120 | 119 |
|
121 |
def set_mouth_target(self, robot_mouth, blocking = False): |
|
120 |
def set_lookat_target(self, x, y, z, blocking=False, frame_id='', roll=0.0): |
|
121 |
"""set a gaze at a Cartesian position |
|
122 |
:param x,y,z: position to look at (in eyes frame or frame_id) |
|
123 |
:param roll: side-ways motion of head |
|
124 |
:param blocking: True if this call should block until execution finished on robot |
|
125 |
""" |
|
126 |
self.logger.debug("set_lookat_target(%s) %s" % ((x,y,z), "BLOCKING" if blocking else "NON_BLOCKING")) |
|
127 |
self.middleware.set_lookat_target(x, y, z, blocking, frame_id, roll) |
|
128 |
|
|
129 |
def set_mouth_target(self, robot_mouth, blocking=False): |
|
122 | 130 |
"""set a mouth target |
123 | 131 |
:param robot_mouth: a RobotMouth object |
124 | 132 |
:param blocking: should this call block during execution? |
... | ... | |
126 | 134 |
self.logger.debug("set_mouth_target(%s) %s" % (robot_mouth, ("BLOCKING" if blocking else "NON_BLOCKING"))) |
127 | 135 |
self.middleware.set_mouth_target(robot_mouth, blocking) |
128 | 136 |
|
129 |
def set_head_animation(self, robot_animation, blocking = False):
|
|
137 |
def set_head_animation(self, robot_animation, blocking=False):
|
|
130 | 138 |
"""set a head animation |
131 | 139 |
:param robot_animation: a RobotAnimation object |
132 | 140 |
:param blocking: should this call block during execution? |
... | ... | |
134 | 142 |
self.logger.debug("set_head_animation(%s) %s" % (robot_animation, ("BLOCKING" if blocking else "NON_BLOCKING"))) |
135 | 143 |
self.middleware.set_head_animation(robot_animation, blocking) |
136 | 144 |
|
137 |
def set_speak(self, text, blocking = False):
|
|
145 |
def set_speak(self, text, blocking=False):
|
|
138 | 146 |
"""request the robot to say something using tts |
139 | 147 |
:param text: text to synthesize |
140 | 148 |
:param blocking: should this call block during execution? |
141 | 149 |
""" |
142 | 150 |
self.logger.debug("set_speak(%s) %s" % (text, ("BLOCKING" if blocking else "NON_BLOCKING"))) |
143 | 151 |
self.middleware.set_speak(text, blocking) |
144 |
|
|
145 |
#def get_gaze_target(self): |
|
146 |
# result = self.middleware.get_gaze_target() |
|
147 |
# self.logger.debug("get_gaze_target() returned %s" % (result)) |
|
148 |
# return self.middleware.get_gaze_target() |
Also available in: Unified diff