コード例 #1
0
ファイル: command_line.py プロジェクト: zhengfengran/spot-sdk
    def _run(self, robot, options):
        """Implementation of the command.

        Args:
            robot: Robot object on which to run the command.
            options: Parsed command-line arguments.

        Returns:
            False if timesync cannot be established, True otherwise.
        """
        endpoint = TimeSyncEndpoint(
            robot.ensure_client(TimeSyncClient.default_service_name))
        if not endpoint.establish_timesync(break_on_success=True):
            print("Failed to achieve time sync")
            return False

        if options.proto:
            print(endpoint.response)
            return True

        print("GRPC round-trip time: {}".format(
            duration_str(endpoint.round_trip_time)))
        print("Local time to robot time: {}".format(
            duration_str(endpoint.clock_skew)))

        return True
コード例 #2
0
ファイル: command_line.py プロジェクト: zhangzifa/spot-sdk
    def _run(self, robot, options):
        endpoint = TimeSyncEndpoint(
            robot.ensure_client(TimeSyncClient.default_service_name))
        if not endpoint.establish_timesync(break_on_success=True):
            print("Failed to acheive time sync")
            return False

        if options.proto:
            print(endpoint.response)
            return True

        print("GRPC round-trip time: {}".format(
            duration_str(endpoint.round_trip_time)))
        print("Local time to robot time: {}".format(
            duration_str(endpoint.clock_skew)))

        return True
コード例 #3
0
 def _time_sync_str(self):
     if not self._robot.time_sync:
         return 'Time sync: (none)'
     if self._robot.time_sync.stopped:
         status = 'STOPPED'
         exception = self._robot.time_sync.thread_exception
         if exception:
             status = '{} Exception: {}'.format(status, exception)
     else:
         status = 'RUNNING'
     try:
         skew = self._robot.time_sync.get_robot_clock_skew()
         if skew:
             skew_str = 'offset={}'.format(duration_str(skew))
         else:
             skew_str = "(Skew undetermined)"
     except (TimeSyncError, RpcError) as err:
         skew_str = '({})'.format(err)
     return 'Time sync: {} {}'.format(status, skew_str)
コード例 #4
0
 def check_timesync(self):
     """Check and report time difference between robot and client."""
     clock_skew = self.get_clock_skew()
     if clock_skew:
         self.le_timesync.setText(duration_str(clock_skew))