Пример #1
0
class Simulator(object):
    def __init__(self):
        self._drone = SimpleVirtualDrone()
        self._controller = SimpleController(self._drone, log=True)
        self._loop = asyncio.get_event_loop()
        #self._drone.set_init([0., 0., 0.], [0., 0., 1.])
        self.started = asyncio.Future()
        # self._AOO = []
        # self._drone.dt = 5e-4
        # self._drone.noise_z = 1e-10

    @asyncio.coroutine
    def run(self):
        logger.info('starting simulation...')
        yield from self._controller.arm()
        self._loop.call_soon_threadsafe(
            self._loop.create_task,
            self._controller.start()
        )
        self.started.set_result(True)
        logger.info('started.')

    @asyncio.coroutine
    def get_data(self):
        pos = list(self._drone.pos)
        ori = list(self._drone.rot.flatten())
        # oori = ori[:, 2]
        # self._AOO.append(self._drone.acc_sensor[2])
        # self._AOO.append(oori)
        return pos, ori

    @asyncio.coroutine
    def stop(self):
        yield from self._controller.stop()
        yield from self._drone.stop()
Пример #2
0
class UserView:
    def __init__(self):
        self.controller = SimpleController(self)

    def update_display(self, state, msg):
        if isinstance(msg, model.User):
            msg = f'{msg.username};{msg.email}'
        print(f"{'Success' if state else 'Error'}>>>{msg}")

    def create_user(self):
        username = input('username: '******'email: ')
        self.controller.create(username, email)

    def get_user(self):
        user_id = input('user id: ')
        self.controller.get(user_id)
Пример #3
0
 def __init__(self):
     self.controller = SimpleController(self)
Пример #4
0
 def __init__(self):
     self._drone = SimpleVirtualDrone()
     self._controller = SimpleController(self._drone, log=True)
     self._loop = asyncio.get_event_loop()
     #self._drone.set_init([0., 0., 0.], [0., 0., 1.])
     self.started = asyncio.Future()