Revision 64f5c90e client/python/hlrc_client/RobotController.py
| client/python/hlrc_client/RobotController.py | ||
|---|---|---|
| 26 | 26 |
""" |
| 27 | 27 |
|
| 28 | 28 |
import logging |
| 29 |
try: |
|
| 30 |
import rsb |
|
| 31 |
import rst |
|
| 32 |
import rstsandbox |
|
| 33 |
from rst.robot.EmotionState_pb2 import EmotionState |
|
| 34 |
from rst.robot.Animation_pb2 import Animation |
|
| 35 |
from rst.robot.GazeTarget_pb2 import GazeTarget |
|
| 36 |
from rst.robot.MouthTarget_pb2 import MouthTarget |
|
| 37 |
except ImportError, e: |
|
| 38 |
print("Warning, RSB import error: ")
|
|
| 39 |
print e |
|
| 40 |
RSB_SUPPORT = False |
|
| 41 |
else: |
|
| 42 |
from MiddlewareRSB import * |
|
| 43 |
RSB_SUPPORT = True |
|
| 44 |
|
|
| 45 |
from MiddlewareROS import * |
|
| 46 | 29 |
import sys |
| 30 |
import errno |
|
| 47 | 31 |
|
| 48 | 32 |
class RobotController: |
| 49 | 33 |
def __init__(self, mw_name, scope, loglevel=logging.WARNING): |
| ... | ... | |
| 66 | 50 |
|
| 67 | 51 |
|
| 68 | 52 |
if (self.mw.upper() == "RSB"): |
| 69 |
if (not RSB_SUPPORT): |
|
| 70 |
self.logger.error("ERROR: no RSB support detected")
|
|
| 53 |
self.logger.info("creating new middleware connection via RSB")
|
|
| 54 |
try: |
|
| 55 |
from MiddlewareRSB import MiddlewareRSB |
|
| 56 |
except ImportError, e: |
|
| 57 |
self.logger.error("failed to import RSB or the necessary data types: {}".format(e))
|
|
| 71 | 58 |
sys.exit(errno.EINVAL) |
| 72 |
else: |
|
| 73 |
self.logger.info("creating new middleware connection via RSB")
|
|
| 74 |
self.middleware = MiddlewareRSB(self.scope, self.loglevel) |
|
| 59 |
|
|
| 60 |
#import worked, safe to intantiate RSB mw now |
|
| 61 |
self.middleware = MiddlewareRSB(self.scope, self.loglevel) |
|
| 62 |
|
|
| 75 | 63 |
elif (self.mw.upper() == "ROS"): |
| 76 | 64 |
self.logger.info("creating new middleware connection via ROS")
|
| 65 |
try: |
|
| 66 |
from MiddlewareROS import MiddlewareROS |
|
| 67 |
except ImportError, e: |
|
| 68 |
self.logger.error("failed to import ROS or the necessary data types: {}".format(e))
|
|
| 69 |
sys.exit(errno.EINVAL) |
|
| 70 |
|
|
| 71 |
#import worked, safe to intantiate RSB mw now |
|
| 77 | 72 |
self.middleware = MiddlewareROS(self.scope, self.loglevel) |
| 78 | 73 |
else: |
| 79 | 74 |
self.logger.error("invalid middleware requested (%s). supported: {ROS, RSB}\n\n" % (self.mw))
|
Also available in: Unified diff