Пример #1
0
 def _update_land(self, command: Command, state: State) -> State:
     assert command.opcode == "land"
     state = state.copy_and_set_has_taken_off(False)
     state = state.copy_and_set_time_used_seconds(
         state.time_used_seconds + state.z_meters / self.drone_config.speed_mps)
     state = state.copy_and_set_z_meters(0)
     return state
Пример #2
0
 def _update_down(self, command: Command, state: State) -> State:
     assert command.opcode == "down"
     down_meters, = command.operands
     state = state.copy_and_set_time_used_seconds(
         state.time_used_seconds + down_meters / self.drone_config.speed_mps)
     state = state.copy_and_set_z_meters(state.z_meters - down_meters)
     return state
Пример #3
0
 def _update_takeoff(self, command: Command, state: State) -> State:
     assert command.opcode == "takeoff"
     state = state.copy_and_set_has_taken_off(True)
     state = state.copy_and_set_time_used_seconds(
         state.time_used_seconds + self.drone_config.takeoff_height_meters / self.drone_config.speed_mps)
     state = state.copy_and_set_z_meters(self.drone_config.takeoff_height_meters)
     return state
Пример #4
0
 def test_copy_and_set_z_meters(self):
     state = State()
     actual = state.copy_and_set_z_meters(1)
     expected = State(has_taken_off=False, time_used_seconds=0,
                      x_meters=0, y_meters=0, z_meters=1, orientation_degrees=0)
     self.assertEqual(expected, actual)