How to use the pypot.robot.Robot function in pypot

To help you get started, we’ve selected a few pypot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github poppy-project / pypot / pypot / robot / xmlparser.py View on Github external
def parse_robot_node(robot_node):
    robot = pypot.robot.Robot()

    controllers_node = robot_node.getElementsByTagName('DxlController')
    for c in controllers_node:
        dxl_io, dxl_motors = parse_controller_node(c)
        robot._attach_dxl_motors(dxl_io, dxl_motors)

    motors_group_node = robot_node.getElementsByTagName('DxlMotorGroup')
    for g in motors_group_node:
        group_name, motor_names = parse_motor_group_node(g)
        motors = [getattr(robot, name) for name in motor_names]
        setattr(robot, group_name, motors)
        robot.alias.append(group_name)

    return robot
github poppy-project / pypot / pypot / vrep / __init__.py View on Github external
robot.start_simulation = start_simu
    robot.stop_simulation = stop_simu
    robot.reset_simulation = reset_simu

    def current_simulation_time(robot):
        return robot._controllers[0].io.get_simulation_current_time()
    Robot.current_simulation_time = property(lambda robot: current_simulation_time(robot))

    def get_object_position(robot, object, relative_to_object=None):
        return vrep_io.get_object_position(object, relative_to_object)
    Robot.get_object_position = partial(get_object_position, robot)

    def get_object_orientation(robot, object, relative_to_object=None):
        return vrep_io.get_object_orientation(object, relative_to_object)
    Robot.get_object_orientation = partial(get_object_orientation, robot)

    return robot
github poppy-project / pypot / pypot / vrep / __init__.py View on Github external
vc = VrepController(vrep_io, scene, motors)
    vc._init_vrep_streaming()

    sensor_controllers = []

    if tracked_objects:
        sensors = [ObjectTracker(name) for name in tracked_objects]
        vot = VrepObjectTracker(vrep_io, sensors)
        sensor_controllers.append(vot)

    if tracked_collisions:
        sensors = [VrepCollisionDetector(name) for name in tracked_collisions]
        vct = VrepCollisionTracker(vrep_io, sensors)
        sensor_controllers.append(vct)

    robot = Robot(motor_controllers=[vc],
                  sensor_controllers=sensor_controllers)

    for m in robot.motors:
        m.goto_behavior = 'minjerk'

    init_pos = {m: m.goal_position for m in robot.motors}

    make_alias(config, robot)

    def start_simu():
        vrep_io.start_simulation()

        for m, p in init_pos.iteritems():
            m.goal_position = p

        vc.start()
github poppy-project / pypot / pypot / config / xmlparser.py View on Github external
def _handle_robot(dom):
    """ Parses the  element of an xml file and returns a :py:class:`~pyrobot.robot.Robot`. """
    robot_node = dom.getElementsByTagName("Robot")[0]

    name = robot_node.getAttribute("name")

    eeprom_node = robot_node.getElementsByTagName("EEPROM")[0]
    eeprom_values = _handle_eeprom(eeprom_node)

    controller_nodes = dom.getElementsByTagName("DynamixelController")
    controllers = [_handle_controller(c) for c in controller_nodes]

    motors = sum(map(lambda c: c.motors, controllers), [])

    robot = pypot.robot.Robot(name, motors, controllers, eeprom_values)

    return robot
github poppy-project / pypot / pypot / creatures / abstractcreature.py View on Github external
logger = logging.getLogger(__name__)

MAX_SETUP_TRIALS = 10


class classproperty(property):
    def __get__(self, cls, owner):
        return self.fget.__get__(None, owner)()


def camelcase_to_underscore(name):
    return re.sub('([a-z])([A-Z0-9])', r'\1_\2', name).lower()


class AbstractPoppyCreature(Robot):
    """ Abstract Class for Any Poppy Creature. """
    def __new__(cls,
                base_path=None, config=None,
                simulator=None, scene=None, host='localhost', port=19997, id=0,
                use_snap=False, snap_host='0.0.0.0', snap_port=6969, snap_quiet=True,
                use_http=False, http_host='0.0.0.0', http_port=8080, http_quiet=True,
                use_remote=False, remote_host='0.0.0.0', remote_port=4242,
                use_ws=False, ws_host='0.0.0.0', ws_port=9009,
                start_background_services=True, sync=True,
                **extra):
        """ Poppy Creature Factory.

        Creates a Robot (real or simulated) and specifies it to make it a specific Poppy Creature.

        :param str config: path to a specific json config (if None uses the default config of the poppy creature - e.g. poppy_humanoid.json)
github poppy-project / pypot / pypot / dynamixel / __init__.py View on Github external
motorcls = {
                'MX': DxlMXMotor,
                'RX': DxlAXRXMotor,
                'AX': DxlAXRXMotor,
                'XL': DxlXL320Motor,
                'SR': DxlSRMotor,
            }

            motors = [motorcls[model[:2]](id, model=model)
                      for id, model in zip(ids, models)]

            c = BaseDxlController(dxl_io, motors)
            motor_controllers.append(c)
            break

    return Robot(motor_controllers)