How to use the pypot.utils.pypot_time.sleep 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 / dynamixel / io / abstract_io.py View on Github external
# Observed with the USB2AX on Linux with pyserial 2.7
                # We have to first open/close the port in order to make it work
                # at 1Mbauds
                if platform.system() == 'Linux' and self._sync_read:
                    self._serial = serial.Serial(port, 9600)
                    self._serial.close()

                self._serial = serial.Serial(port, baudrate, timeout=timeout)
                self.__used_ports.add(port)

            if platform.system() == 'Darwin' and self._sync_read:
                if not self.ping(self._protocol.DxlBroadcast):
                    self.close()
                    continue
                else:
                    time.sleep(self.timeout)
                    self.flush()
            break
        else:
            raise DxlError('could not connect to the port {}'.format(self.port))
github poppy-project / pypot / pypot / utils / stoppablethread.py View on Github external
while not thread.should_stop():
        if thread.should_pause():
            thread.wait_to_resume()

        start = time.time()
        if hasattr(thread, '_updated'):
            thread._updated.clear()
        update_func()
        if hasattr(thread, '_updated'):
            thread._updated.set()
        end = time.time()

        dt = thread.period - (end - start)

        if dt > 0:
            time.sleep(dt)
github poppy-project / pypot / pypot / primitive / primitive.py View on Github external
if control == 'minjerk':
            goto_min_jerk = GotoMinJerk(self, position, duration)
            goto_min_jerk.start()
            if wait:
                goto_min_jerk.wait_to_stop()

        elif control == 'dummy':
            dp = abs(self.present_position - position)
            speed = (dp / float(duration)) if duration > 0 else numpy.inf

            self.moving_speed = speed
            self.goal_position = position

            if wait:
                time.sleep(duration)
github poppy-project / pypot / pypot / dynamixel / motor.py View on Github external
if control == 'minjerk':
            goto_min_jerk = GotoMinJerk(self, position, duration)
            goto_min_jerk.start()

            if wait:
                goto_min_jerk.wait_to_stop()

        elif control == 'dummy':
            dp = abs(self.present_position - position)
            speed = (dp / float(duration)) if duration > 0 else 0

            self.moving_speed = speed
            self.goal_position = position

            if wait:
                time.sleep(duration)

        elif control == 'linear':
            goto_linear = GotoLinear(self, position, duration)
            goto_linear.start()

            if wait:
                goto_linear.wait_to_stop()
github poppy-project / pypot / pypot / vrep / __init__.py View on Github external
with open('my_config.json') as f:
                config = json.load(f)

            from pypot.robot import from_config
            from pypot.vrep import from_vrep

            real_robot = from_config(config)
            simulated_robot = from_vrep(config, '127.0.0.1', 19997, 'poppy.ttt')

    """
    vrep_io = VrepIO(vrep_host, vrep_port)

    vreptime = vrep_time(vrep_io)
    pypot_time.time = vreptime.get_time
    pypot_time.sleep = vreptime.sleep

    if isinstance(config, basestring):
        with open(config) as f:
            config = json.load(f, object_pairs_hook=OrderedDict)

    motors = [motor_from_confignode(config, name)
              for name in config['motors'].keys()]

    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)