skywalkerskywalker

プログラミング指導書 解答コード

授業用資料

授業で使用できるパワーポイントの資料をダウンロードできます。

ご活用ください。

小学生向け(Scratch)

(外部サイトに移動します。)

中学生向け(Python)

各練習問題の解答のコードです。

コピーして利用してください。

初級編-Q1

import time
from djitellopy import Tello

tello = Tello()
tello.connect()

tello.takeoff()

time.sleep(5)
tello.move_forward(100)

time.sleep(5)
tello.land()
 




初級編-Q2

from djitellopy import Tello

tello = Tello()
tello.connect()

tello.enable_mission_pads()

tello.takeoff()

pad = tello.get_mission_pad_id()

while pad != 1:
    tello.move_forward(30)

    pad = tello.get_mission_pad_id()

tello.flip_back()

tello.disable_mission_pads()
tello.land()
 




上級編-Q1

import time
from djitellopy import Tello

tello = Tello()
tello.connect()
tello.enable_mission_pads()
tello.takeoff()

pad = tello.get_mission_pad_id()

while pad != 2:
    tello.move_forward(20)
    pad = tello.get_mission_pad_id()

tello.go_xyz_speed_mid(0, 0, 30, 20, 2)

for i in range(3):
    for j in range(2):
        tello.curve_xyz_speed(50, 50, 5, 100, 0, 10, 20)
        time.sleep(3)
        tello.rotate_counter_clockwise(180)
        time.sleep(3)
    
    Z = tello.get_mission_pad_distance_z()
    tello.go_xyz_speed_mid(0, 0, Z, 20, 2)

tello.go_xyz_speed_mid(0, 0, 50, 20, 2)

while pad != 1:
    tello.move_back(20)
    pad = tello.get_mission_pad_id()

tello.go_xyz_speed_mid(0, 0, 50, 20, 1)

tello.land()
tello.disable_mission_pads()
tello.end()




中級編-Q1

import time
from djitellopy import Tello

tello = Tello()
tello.connect()

tello.takeoff()

time.sleep(5)
tello.move_forward(100)

time.sleep(5)
tello.land()

time.sleep(5)
tello.takeoff()

time.sleep(5)
tello.rotate_clockwise(180)

time.sleep(5)
tello.move_forward(100)

time.sleep(5)
tello.move_back(100)

time.sleep(5)
tello.land()
tello.end()




中級編-Q2

import time
from djitellopy import Tello

tello = Tello()
tello.connect()
tello.enable_mission_pads()
tello.takeoff()

pad= tello.get_mission_pad_id()

while pad != 2:
    tello.move_forward(30)
    pad = tello.get_mission_pad_id()

tello.go_xyz_speed_mid(0, 0, 50, 20, 2)
tello.land()

time.sleep(5)
tello.takeoff()
tello.rotate_clockwise(180)

while pad != 1:
    tello.move_forward(30)
    pad = tello.get_mission_pad_id()

time.sleep(5)
while pad != 2:
    tello.move_back(30)
    pad = tello.get_mission_pad_id()

time.sleep(5)
tello.go_xyz_speed_mid(0, 0, 50, 20, 2)
tello.land()
tello.end()




Q1

import time
from djitellopy import Tello

tello = Tello()
tello.connect()

tello.takeoff()

time.sleep(5)
tello.move_forward(100)

time.sleep(5)
tello.land()

time.sleep(5)
tello.takeoff()

time.sleep(5)
tello.rotate_clockwise(180)

time.sleep(5)
tello.move_forward(100)

time.sleep(5)
tello.move_back(100)

time.sleep(5)
tello.land()