การเคลื่อนไหว#
การแนะนำ#
โดรน VEX AIR มีใบพัดสี่ใบ ทำให้สามารถเคลื่อนที่ไปในทิศทางใดก็ได้และหมุนได้อย่างอิสระ ระบบควบคุมการเคลื่อนไหวช่วยให้สามารถควบคุมการเคลื่อนที่ การหมุน การปรับความเร็ว และการติดตามตำแหน่งได้

ด้านล่างนี้คือรายการวิธีการทั้งหมดที่มีให้เลือกใช้:
การกระทำ
take_off– ยกโดรนขึ้นสู่ความสูงที่กำหนดland– ลงจอดโดรนhover- รักษาโดรนให้อยู่ในตำแหน่งเดิมclimb– เคลื่อนโดรนในทิศทางแนวตั้งที่กำหนดclimb_for– เคลื่อนโดรนในทิศทางแนวตั้งที่กำหนดเป็นระยะทางที่ระบุclimb_to– ย้ายโดรนไปยังระดับความสูงที่กำหนดmove_at– เคลื่อนย้ายโดรนตามทิศทางและความเร็วที่กำหนดmove_for– เคลื่อนย้ายโดรนในทิศทางที่กำหนดและระยะทางที่กำหนดmove_to– ย้ายโดรนไปยังตำแหน่งที่กำหนดโดยรักษาทิศทางเดิมไว้turn– เลี้ยวโดรนไปทางซ้ายหรือขวาturn_for– หมุนโดรนเป็นจำนวนองศาที่กำหนดturn_to– หมุนโดรนให้หันไปทางทิศทางที่กำหนดmove_with_vectors– เคลื่อนย้ายโดรนโดยใช้ค่า x, y, z และการหมุนตามเวกเตอร์
ตัวปรับแต่ง
set_steering_mode– ตั้งค่า POV สำหรับการบังคับโดรนset_movement_mode– ตั้งค่ารูปแบบการเคลื่อนที่ของโดรนset_climb_velocity– ตั้งค่าความเร็วในการปีนขึ้นเริ่มต้นset_move_velocity– ตั้งค่าความเร็วในการเคลื่อนที่เริ่มต้นset_turn_velocity- ตั้งค่าความเร็วในการเลี้ยวเริ่มต้นset_max_z_height- กำหนดขีดจำกัดความสูงที่โดรนจะบินได้set_xyz_position– กำหนดตำแหน่งปัจจุบันของโดรน
ผู้รับ
get_max_z_height– ส่งคืนความสูงสูงสุดที่โดรนสามารถเข้าถึงได้get_flight_state– ส่งคืนสถานะปัจจุบันของโดรนget_x_position– ส่งคืนพิกัด x ของโดรนget_y_position– ส่งคืนพิกัด y ของโดรนget_z_position– ส่งคืนพิกัด z ของโดรนget_safe_mode– ส่งคืนสถานะการล็อกใบพัดของโดรนis_climb_active– คืนค่าว่าโดรนกำลังปีนขึ้นอยู่หรือไม่is_move_active– ส่งคืนว่าโดรนกำลังเคลื่อนที่อยู่หรือไม่is_turn_active– คืนค่าว่าโดรนกำลังเลี้ยวอยู่หรือไม่is_hovering- คืนค่าว่าโดรนกำลังลอยอยู่หรือไม่is_taking_off– คืนค่าว่าโดรนกำลังบินขึ้นหรือไม่is_landing– ส่งคืนว่าโดรนกำลังลงจอดอยู่หรือไม่is_landed- คืนค่าว่าโดรนลงจอดแล้วหรือไม่
การกระทำ#
take_off#
take_off จะเริ่มการทำงานของใบพัดและยกโดรนขึ้นสู่อากาศ ต้องใช้วิธีนี้ก่อนจึงจะสามารถทำการเคลื่อนไหวอื่นๆ ได้
In VEX AIR Competition Matches, take_off must be the first method in your project. The Field Control System (FCS) does not make the drone take off automatically, so your project must handle takeoff. Your project starts running on its own when the FCS enables flight at the start of a Match.
วิธีใช้:
drone.take_off(climb_to, units, wait)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ตำแหน่ง z (ความสูง) ที่โดรนจะบินไป |
|
หน่วยที่ใช้:
|
|
ตัวเลือกเสริม |
# Fly for 1 second
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.land()
land#
คำสั่ง land จะลดระดับโดรนลงสู่พื้น ใบพัดจะยังคงหมุนต่อไปจนกว่าโครงการจะหยุดลง
วิธีใช้:
drone.land(wait)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ตัวเลือกเสริม |
# Land after 1 second
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.land()
hover#
hover หยุดโดรนไม่ให้เคลื่อนที่ไปในทิศทางใด ๆ และรักษาระดับตำแหน่งปัจจุบันในอากาศ
Usage:
drone.hover()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Hold current position for 3 seconds after moving forward
drone.take_off(climb_to=500, units=MM)
drone.move_at(angle=0, velocity=50)
wait(1, SECONDS)
drone.hover()
wait(3, SECONDS)
drone.land()
climb#
คำสั่ง climb จะเคลื่อนโดรนไปในทิศทางแนวตั้งที่กำหนด
Usage:
drone.climb(direction, velocity)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ทิศทางที่โดรนจะบิน: |
|
ความเร็วในการไต่ระดับของโดรน คิดเป็นเปอร์เซ็นต์ |
# Climb upwards for 2 seconds
drone.take_off(climb_to=500, units=MM)
wait(2, SECONDS)
drone.climb(UP, 50)
wait(2, SECONDS)
drone.land()
climb_for#
คำสั่ง climb_for จะเคลื่อนโดรนไปในทิศทางแนวตั้งที่กำหนดไว้เป็นระยะทางที่ระบุ
วิธีใช้:
drone.climb_for(direction, distance, units, velocity, wait)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ทิศทางที่โดรนจะบิน: |
|
ระยะทางที่โดรนจะบินได้ |
|
(ไม่บังคับ) หน่วยที่ใช้แสดงระยะทาง:
|
|
(ไม่บังคับ) ความเร็วในการไต่ระดับของโดรน (แสดงเป็นเปอร์เซ็นต์) หากไม่ได้ระบุความเร็ว ค่าเริ่มต้นคือ 50% |
|
ตัวเลือกเสริม |
# Lower drone before landing
drone.take_off(climb_to=700, units=MM)
wait(2, SECONDS)
drone.climb_for(direction=DOWN, distance=300, units=MM, velocity=50)
wait(2, SECONDS)
drone.land()
climb_to#
คำสั่ง climb_to จะเคลื่อนโดรนไปยังตำแหน่ง z ที่กำหนด
วิธีใช้:
drone.climb_to(z, units, velocity, wait)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ค่าตำแหน่ง z (แสดงเป็นจำนวนเต็มหรือทศนิยม) ที่โดรนจะไต่ระดับขึ้นไป |
|
(ไม่บังคับ) หน่วยที่ใช้แสดงระยะทาง:
|
|
(ไม่บังคับ) ความเร็วในการไต่ระดับของโดรน (แสดงเป็นเปอร์เซ็นต์) |
|
ตัวเลือกเสริม |
# Reach 500 mm after takeoff
drone.take_off(climb_to=300, units=MM)
wait(1, SECONDS)
drone.climb_to(z=500, units=MM, velocity=50)
wait(1, SECONDS)
drone.land()
move_at#
คำสั่ง move_at จะเคลื่อนโดรนด้วยมุมและความเร็วที่กำหนด
วิธีใช้:
drone.move_at(angle, velocity)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
มุมที่โดรนเคลื่อนที่ โดยแสดงเป็นจำนวนเต็มหรือทศนิยม มีค่าตั้งแต่ 0 ถึง 359 องศา |
|
ความเร็วที่โดรนจะเคลื่อนที่คิดเป็นเปอร์เซ็นต์ |
# Move left for 2 seconds
drone.take_off(climb_to=500, units=MM)
drone.move_at(angle=270, velocity=50)
wait(2, SECONDS)
drone.land()
move_for#
move_for เคลื่อนโดรนไปในทิศทางที่กำหนดเป็นระยะทางที่กำหนดโดยใช้ set_move_velocity ปัจจุบัน
วิธีใช้:
drone.move_for(angle, distance, units, velocity, wait)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
มุมที่โดรนเคลื่อนที่ โดยมีค่าเป็นจำนวนเต็มหรือทศนิยม (float) อยู่ในช่วงตั้งแต่ 0 ถึง 359 องศา |
|
ระยะทางที่โดรนจะเคลื่อนที่ (ระบุเป็นจำนวนเต็มหรือทศนิยม) |
|
(ไม่บังคับ) หน่วยที่ใช้แสดงระยะทาง:
|
|
(ไม่บังคับ) ความเร็วในการเคลื่อนที่ของโดรน (แสดงเป็นเปอร์เซ็นต์) |
|
ตัวเลือกเสริม |
# Move forward for 200 mm
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.move_for(angle=0, distance=200, units=MM, velocity=50)
wait(1, SECONDS)
drone.land()
move_to#
คำสั่ง move_to จะเคลื่อนโดรนไปยังตำแหน่งที่กำหนดในอากาศ โดยรักษาระดับทิศทางเดิมไว้
วิธีใช้:
drone.move_to(x, y, z, units, move_velocity, climb_velocity, wait)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
พิกัด x ที่โดรนจะเคลื่อนที่ไป |
|
พิกัด y ที่โดรนจะเคลื่อนที่ไป |
|
พิกัด z ที่โดรนจะเคลื่อนที่ไป |
|
(ไม่บังคับ) หน่วยที่ใช้แสดงระยะทาง:
|
|
(ไม่บังคับ) ความเร็วในการเคลื่อนที่ของโดรน (แสดงเป็นเปอร์เซ็นต์) |
|
(ไม่บังคับ) ความเร็วในการไต่ระดับของโดรน (แสดงเป็นเปอร์เซ็นต์) |
|
ตัวเลือกเสริม |
# Move diagonally to (300, 300, 800)
drone.take_off(climb_to=300, units=MM)
wait(2, SECONDS)
drone.move_to(x=300, y=300, z=800, units=MM, move_velocity=50, climb_velocity=50)
wait(2, SECONDS)
drone.land()
turn#
turn เลี้ยวโดรนไปในทิศทางที่กำหนดโดยใช้ set_turn_velocity
วิธีใช้:
drone.turn(direction, velocity)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ทิศทางที่โดรนจะเลี้ยว: |
|
(ไม่บังคับ) ความเร็วในการเลี้ยวของโดรน (แสดงเป็นเปอร์เซ็นต์) |
# Turn to the right for 2 seconds
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.turn(RIGHT, 50)
wait(2, SECONDS)
drone.land()
turn_for#
turn_for หมุนโดรนไปในทิศทางที่กำหนดเป็นระยะทางที่กำหนดโดยสัมพันธ์กับทิศทางที่หันหน้าอยู่ในปัจจุบันโดยใช้ set_turn_velocity
วิธีใช้:
drone.turn_for(direction, angle, velocity, wait)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ทิศทางที่โดรนจะเลี้ยว: |
|
มุมที่โดรนหมุน โดยมีค่าเป็นจำนวนเต็มหรือทศนิยม (float) ตั้งแต่ 0 ถึง 359 องศา |
|
(ไม่บังคับ) ความเร็วในการเลี้ยวของโดรน (แสดงเป็นเปอร์เซ็นต์) |
|
ตัวเลือกเสริม |
# Turn around, then land
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.turn_for(RIGHT, 180)
wait(1, SECONDS)
drone.land()
turn_to#
turn_to หมุนโดรนให้หันหน้าไปยังทิศทางที่กำหนดโดยใช้ set_turn_velocity ปัจจุบัน
วิธีใช้:
drone.turn_to(heading, velocity, wait)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ทิศทางที่โดรนจะหันไปนั้นสามารถปรับได้ตั้งแต่ 0 ถึง 360 องศา |
|
(ไม่บังคับ) ความเร็วในการเลี้ยวของโดรน (แสดงเป็นเปอร์เซ็นต์) |
|
ตัวเลือกเสริม |
# Turn to face each of the cardinal headings
drone.take_off(climb_to=500, units=MM)
drone.turn_to(heading=90, velocity=50)
wait(3, SECONDS)
drone.turn_to(heading=180, velocity=50)
wait(3, SECONDS)
drone.turn_to(heading=270, velocity=50)
wait(3, SECONDS)
drone.turn_to(heading=0, velocity=50)
wait(3, SECONDS)
drone.land()
move_with_vectors#
move_with_vectors เคลื่อนย้ายโดรนโดยใช้การเคลื่อนที่แบบเวกเตอร์ โดยผสมผสานการเคลื่อนที่ตามแกน x (แนวนอน) และแกน y (แนวตั้ง) พร้อมทั้งหมุนโดรนไปด้วย
หมายเหตุ: วิธีนี้ตั้งค่าความเร็วในการเคลื่อนที่และการหมุนโดยตรง ดังนั้นจึงไม่ใช้ set_move_velocity หรือ set_turn_velocity
วิธีใช้:
drone.move_with_vectors(forward, rightward, upward, rotation)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ความเร็วของโดรนตามแกน Y (การเคลื่อนที่ไปข้างหน้าและถอยหลัง) รับค่าตั้งแต่ -100 ถึง 100 ในรูปแบบเปอร์เซ็นต์ โดยค่าลบหมายถึงเคลื่อนที่ถอยหลัง และค่าบวกหมายถึงเคลื่อนที่ไปข้างหน้า |
|
ความเร็วของโดรนตามแนวแกน X (การเคลื่อนที่ไปด้านข้าง) รับค่าตั้งแต่ -100 ถึง 100 ในรูปแบบเปอร์เซ็นต์ โดยค่าลบหมายถึงเคลื่อนที่ไปทางซ้าย และค่าบวกหมายถึงเคลื่อนที่ไปทางขวา |
|
ความเร็วของโดรนตามแนวแกน Z (การเคลื่อนที่ขึ้นและลง) รับค่าตั้งแต่ -100 ถึง 100 ในรูปแบบเปอร์เซ็นต์ โดยค่าลบหมายถึงการเคลื่อนที่ลง และค่าบวกหมายถึงการเคลื่อนที่ขึ้น |
|
ความเร็วในการหมุนของโดรน รับค่าตั้งแต่ -100 ถึง 100 ในรูปแบบเปอร์เซ็นต์ โดยค่าลบจะหมุนทวนเข็มนาฬิกา และค่าบวกจะหมุนตามเข็มนาฬิกา |
# Move with controller
drone.take_off(climb_to=500, units=MM)
while True:
drone.move_with_vectors(
forward=controller.axis4.position(),
rightward=controller.axis3.position(),
upward=controller.axis1.position(),
rotation=controller.axis2.position()
)
wait(5, MSEC)
ตัวกลายพันธุ์#
set_steering_mode#
set_steering_mode กำหนดมุมมองที่ใช้ในการบังคับโดรน
วิธีใช้:
drone.set_steering_mode(style)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ตั้งค่ามุมมอง (POV) ที่ใช้ในการควบคุมโดรน |
# Steer based on the drone's starting orientation
# until button 7 is pressed
drone.take_off(climb_to=500, units=MM)
drone.set_steering_mode(HEADLESS)
while not controller.button7.pressing():
drone.move_with_vectors(
forward=controller.axis4.position(),
rightward=controller.axis3.position(),
upward=controller.axis1.position(),
rotation=controller.axis2.position()
)
wait(5, MSEC)
drone.land()
set_movement_mode#
set_movement_mode กำหนดรูปแบบการเคลื่อนที่ของโดรน
รูปแบบการเคลื่อนไหวนี้ใช้เมื่อบังคับโดรนด้วยรีโมทคอนโทรล
วิธีใช้:
drone.set_movement_mode(style)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ตั้งค่าความเร็วที่ใช้ในการบังคับทิศทางโดร
|
# Control the drone with the balanced movement style
drone.take_off(climb_to=500, units=MM)
drone.set_movement_mode(BALANCED)
while not controller.button5.pressing():
drone.move_with_vectors(
forward=controller.axis4.position(),
rightward=controller.axis3.position(),
upward=controller.axis1.position(),
rotation=controller.axis2.position()
)
wait(5, MSEC)
drone.land()
set_climb_velocity#
set_climb_velocity กำหนดความเร็วในการปีนขึ้นเริ่มต้นเป็นเปอร์เซ็นต์ ซึ่งจะมีผลต่อเมธอดอื่นๆ ที่เกี่ยวข้องกับการปีนขึ้น ความเร็วในการปีนขึ้นเริ่มต้นคือ 50%
วิธีใช้:
drone.set_climb_velocity(velocity)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ความเร็วในการไต่ระดับของโดรน คิดเป็นเปอร์เซ็นต์ |
# Raise the drone quickly before landing
drone.take_off(climb_to=300, units=MM)
wait(1, SECONDS)
drone.set_climb_velocity(100)
drone.climb_for(direction=UP, distance=500, units=MM, velocity=100)
wait(1, SECONDS)
drone.land()
set_move_velocity#
set_move_velocity กำหนดความเร็วในการเคลื่อนที่เริ่มต้นเป็นเปอร์เซ็นต์ ซึ่งจะมีผลต่อเมธอดที่เกี่ยวข้องกับการเคลื่อนที่ทั้งหมดที่ตามมา ความเร็วในการเคลื่อนที่เริ่มต้นคือ 50%
วิธีใช้:
drone.set_move_velocity(velocity)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ความเร็วที่โดรนจะเคลื่อนที่คิดเป็นเปอร์เซ็นต์ |
# Move forward quickly, then reverse slowly
drone.take_off(climb_to=500, units=MM)
drone.set_move_velocity(100)
drone.move_for(angle=0, distance=500, units=MM, velocity=100)
wait(3, SECONDS)
drone.set_move_velocity(20)
drone.move_for(angle=180, distance=500, units=MM, velocity=20)
wait(5, SECONDS)
drone.land()
set_turn_velocity#
set_turn_velocity ตั้งค่าความเร็วในการเลี้ยวเริ่มต้นเป็นเปอร์เซ็นต์ ซึ่งจะมีผลต่อเมธอดอื่นๆ ที่เกี่ยวข้องกับการเลี้ยว ความเร็วในการเลี้ยวเริ่มต้นคือ 50%
วิธีใช้:
drone.set_turn_velocity(velocity)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ความเร็วในการเลี้ยวของโดรน คิดเป็นเปอร์เซ็นต์ |
# Turn clockwise quickly, then counterclockwise slowly
drone.take_off(climb_to=500, units=MM)
drone.set_turn_velocity(100)
drone.turn_for(RIGHT, 360)
wait(3, SECONDS)
drone.set_turn_velocity(20)
drone.turn_for(LEFT, 360)
wait(5, SECONDS)
drone.land()
set_max_z_height#
set_max_z_height กำหนดขีดจำกัดความสูงที่โดรนจะบินได้
วิธีใช้:
drone.set_max_z_height(z_height, units)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ค่าสูงสุดของแกน Z (เป็นจำนวนเต็มหรือทศนิยม) ที่โดรนจะไม่บินเกิน ในช่วงตั้งแต่ 1,000 ถึง 5,000 มม. หรือ 40 ถึง 196 นิ้ว |
|
(ไม่บังคับ) หน่วยวัดระยะทางมีดังนี้:
|
# Fly with controller under 1000 mm
drone.set_max_z_height(1000, MM)
drone.take_off(climb_to=500, units=MM)
while not controller.button7.pressing():
drone.move_with_vectors(
forward=controller.axis4.position(),
rightward=controller.axis3.position(),
upward=controller.axis1.position(),
rotation=controller.axis2.position()
)
drone.land()
set_xyz_position#
set_xyz_position ตั้งค่าพิกัด x, y หรือ z ปัจจุบันของโดรนเป็นค่าที่ระบุ
วิธีใช้:
drone.set_xyz_position(x, y, z, units)
หมายเหตุ: พารามิเตอร์ทั้งหมดเป็นตัวเลือก แต่ต้องระบุ อย่างน้อยหนึ่ง ตัว (x, yหรือ z)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
ตัวเลือกเสริม พิกัด x ที่จะตั้งค่าสำหรับโดรนในหน่วย |
|
ตัวเลือกเสริม พิกัด y ที่จะตั้งค่าสำหรับโดรนในหน่วย |
|
ตัวเลือกเสริม พิกัด z ที่จะตั้งค่าสำหรับโดรนในหน่วย |
|
(ไม่บังคับ) หน่วยที่ใช้แสดงระยะทาง:
|
# Reset the position to (0, 0, 0), then fly to z position -300
drone.take_off(climb_to=800, units=MM)
drone.set_xyz_position(x=0, y=0, z=0, units=MM)
wait(1, SECONDS)
drone.climb(DOWN, 50)
while not drone.get_z_position() < -300:
wait(5, MSEC)
drone.hover()
wait(1, SECONDS)
drone.land()
ผู้รับ#
get_max_z_height#
get_max_z_height จะส่งคืนค่าความสูงสูงสุดที่โดรนสามารถบินขึ้นไปได้ในรูปแบบจำนวนเต็ม
วิธีใช้:
drone.get_max_z_height(units)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
เลือกได้ หน่วยวัด:
|
# Display the new z height limit
controller.screen.print(drone.get_max_z_height(MM))
controller.screen.next_row()
drone.take_off(climb_to=500, units=MM)
drone.set_max_z_height(1000, MM)
controller.screen.print(drone.get_max_z_height(MM))
wait(1, SECONDS)
drone.land()
get_flight_state#
get_flight_state ส่งคืนสถานะการบินปัจจุบันของโดรนในรูปแบบ DroneFlightStateType:
MOTOR_OFF- ไม่มีสถานะการบินอื่นใดที่เป็นจริงCALIBRATION- โดรนกำลังปรับเทียบเซ็นเซอร์ของมันMOTOR_START- โดรนกำลังสตาร์ทมอเตอร์FLIGHT_READY- โดรนพร้อมบินแล้วFLIGHT- The drone is in flight.
Usage:
drone.get_flight_state()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Report the flight status as the drone takes off
controller.screen.print("Preparing for flight!")
controller.screen.next_row()
drone.take_off(climb_to=800, units=MM, wait=False)
while not drone.get_flight_state() == MOTOR_START:
wait(5, MSEC)
controller.screen.print("Motors starting...")
controller.screen.next_row()
while not drone.get_flight_state() == FLIGHT:
wait(5, MSEC)
controller.screen.print("Take off!")
get_x_position#
get_x_position ส่งคืนพิกัด x ของโดรนเป็นเลขฐานสิบ (float)
Usage:
drone.get_x_position(units)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
(ไม่บังคับ) หน่วยที่ใช้แสดงตำแหน่ง:
|
# Move to (200, 0, 500)
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.move_at(angle=90, velocity=50)
while not drone.get_x_position() > 200:
wait(5, MSEC)
drone.hover()
wait(1, SECONDS)
drone.land()
get_y_position#
get_y_position ส่งคืนพิกัด y ของโดรนเป็นทศนิยม (float)
วิธีใช้:
drone.get_y_position(units)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
(ไม่บังคับ) หน่วยที่ใช้แสดงตำแหน่ง:
|
# Move to (0, 200, 500)
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.move_at(angle=0, velocity=50)
while not drone.get_y_position() > 200:
wait(5, MSEC)
drone.hover()
wait(1, SECONDS)
drone.land()
get_z_position#
get_y_position ส่งคืนพิกัด z ของโดรนเป็นทศนิยม (float)
วิธีใช้:
drone.get_z_position(units)
พารามิเตอร์ |
คำอธิบาย |
|---|---|
|
(ไม่บังคับ) หน่วยที่ใช้แสดงตำแหน่ง:
|
# Move to (0, 0, 800)
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.climb(UP, 50)
while not drone.get_z_position() > 800:
wait(5, MSEC)
drone.hover()
wait(1, SECONDS)
drone.land()
get_safe_mode#
get_safe_mode returns a Boolean indicating whether the Propeller Lock is enabled on the drone.
True– เปิดใช้งานการล็อกใบพัดแล้วFalse– ระบบล็อคใบพัดไม่ได้เปิดใช้งาน
วิธีใช้:
drone.get_safe_mode()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Change the sound by enabling the Propeller Lock
while True:
if drone.get_safe_mode():
controller.sound.play(FAULT)
while controller.sound.is_active():
wait(50, MSEC)
else:
controller.sound.play(SUCCESS)
while controller.sound.is_active():
wait(50, MSEC)
wait(5, MSEC)
is_climb_active#
is_climb_active returns a Boolean indicating whether the drone is climbing.
True– ขณะนี้โดรนกำลังไต่ระดับขึ้นFalse– โดรนไม่ได้กำลังบินขึ้น
วิธีใช้:
drone.is_climb_active()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# After the drone starts to climb, play a sound and land
drone.take_off(climb_to=500, units=MM)
drone.climb(UP, 50)
wait(3, SECONDS)
if drone.is_climb_active():
controller.sound.play(SUCCESS)
drone.land()
is_move_active#
is_move_active returns a Boolean indicating whether the drone is currently using a move method.
True– ขณะนี้โดรนกำลังใช้วิธีการเคลื่อนที่False– ขณะนี้โดรนไม่ได้ใช้เมธอดการเคลื่อนที่
วิธีใช้:
drone.is_move_active()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# After the drone starts to move, play a sound and land
drone.take_off(climb_to=500, units=MM)
drone.move_at(angle=0, velocity=50)
wait(2, SECONDS)
if drone.is_move_active():
controller.sound.play(SUCCESS)
drone.land()
is_turn_active#
is_turn_active returns a Boolean indicating whether the drone is turning.
True– ขณะนี้โดรนกำลังเลี้ยวอยู่False– โดรนไม่เลี้ยว
วิธีใช้:
drone.is_turn_active()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# After the drone starts to turn, play a sound and land
drone.take_off(climb_to=500, units=MM)
drone.turn(RIGHT)
wait(2, SECONDS)
if drone.is_turn_active():
controller.sound.play(LOOPING)
while controller.sound.is_active():
wait(50, MSEC)
drone.land()
is_hovering#
is_hovering returns a Boolean indicating whether the drone is maintaining its position (hovering).
True– ขณะนี้โดรนกำลังรักษาระดับ (ลอยตัวอยู่กับที่)False– ขณะนี้โดรนกำลังเปลี่ยนตำแหน่ง
วิธีใช้:
drone.is_hovering()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Play a sound after the drone has finished taking off
drone.take_off(climb_to=700, units=MM)
while not drone.is_hovering():
wait(5, MSEC)
controller.sound.play(PAUSE)
wait(2, SECONDS)
drone.land()
is_taking_off#
is_taking_off returns a Boolean indicating whether the drone is in the process of taking off.
True– ขณะนี้โดรนกำลังอยู่ในขั้นตอนการบินขึ้นFalse– โดรนไม่ได้อยู่ในระหว่างการบินขึ้น
วิธีใช้:
drone.is_taking_off()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Play sounds while the drone is taking off
drone.take_off(climb_to=700, units=MM, wait=False)
wait(1, SECONDS)
while drone.is_taking_off():
controller.sound.play(LOOPING)
wait(5, MSEC)
is_landing#
is_landing returns a Boolean indicating whether the drone is in the process of landing.
True– ขณะนี้โดรนกำลังลงจอดFalse– โดรนไม่ได้กำลังลงจอด
วิธีใช้:
drone.is_landing()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Play sounds while the drone is landing
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.land(wait=False)
wait(1, SECONDS)
while drone.is_landing():
controller.sound.play(LOOPING)
wait(5, MSEC)
is_landed#
is_landed returns a Boolean indicating whether the drone is currently landed.
True– โดรนลงจอดแล้วFalse– โดรนยังไม่ได้ลงจอด
วิธีใช้:
drone.is_landed()
พารามิเตอร์ |
คำอธิบาย |
|---|---|
เมธอดนี้ไม่มีพารามิเตอร์ |
# Celebrate a successful landing
drone.take_off(climb_to=500, units=MM)
wait(1, SECONDS)
drone.land()
wait(1, SECONDS)
if drone.is_landed():
controller.sound.play(SUCCESS)