📋 المحتوى المنظم
📖 محتوى تعليمي مفصّل
نوع: محتوى تعليمي
# specifies the patrol coordinates
waypoints = [[-30, 20], [-60, 30], [-75, 0], [-40, -10]]
# target altitude of the drone in meters
self.target_altitude = 8
نوع: محتوى تعليمي
while self.step(self.time_step) != -1:
نوع: محتوى تعليمي
# reads sensors
roll, pitch, yaw = self.imu.getRollPitchYaw()
x_pos, y_pos, altitude = self.gps.getValues()
roll_acceleration, pitch_acceleration, _ = self.gyro.getValues()
self.current_pose = [x_pos, y_pos, altitude, roll, pitch, yaw]
نوع: محتوى تعليمي
if altitude > self.target_altitude - 1:
# as soon as it reaches the target altitude,
# computes the disturbances to go to the given waypoints
if self.getTime() - t1 > 0.1:
yaw_disturbance, pitch_disturbance = self.move_to_target(
waypoints)
t1 = self.getTime()
نوع: محتوى تعليمي
# calculates the desired input values for roll, pitch, yaw,
# and altitude using various constants and disturbance values
roll_input = self.K_ROLL_P * clamp(roll, -1, 1) + \
roll_acceleration + roll_disturbance
pitch_input = self.K_PITCH_P * clamp(pitch, -1, 1) + \
pitch_acceleration + pitch_disturbance
yaw_input = yaw_disturbance
clamped_difference_altitude = clamp(self.target_altitude - \
altitude + self.K_VERTICAL_OFFSET, -1, 1)
vertical_input = self.K_VERTICAL_P * \
pow(clamped_difference_altitude, 3.0)
نوع: محتوى تعليمي
# calculates the motors' input values based on the
# desired roll, pitch, yaw, and altitude values
front_left_motor_input = self.K_VERTICAL_THRUST + vertical_input \
- yaw_input + pitch_input - roll_input
front_right_motor_input = self.K_VERTICAL_THRUST + vertical_input \
+ yaw_input + pitch_input + roll_input
rear_left_motor_input = self.K_VERTICAL_THRUST + vertical_input \
+ yaw_input - pitch_input - roll_input
rear_right_motor_input = self.K_VERTICAL_THRUST + vertical_input \
- yaw_input - pitch_input + roll_input
نوع: محتوى تعليمي
# sets the velocity of each motor based on the motors' input values calculated above
self.front_left_motor.setVelocity(front_left_motor_input)
self.front_right_motor.setVelocity(-front_right_motor_input)
self.rear_left_motor.setVelocity(rear_left_motor_input)
self.rear_right_motor.setVelocity(rear_right_motor_input)
نوع: محتوى تعليمي
robot = Mavic()
robot.run()
نوع: METADATA
وزارة التعليم
323
Ministry of Education
2025 - 1447
🔍 عناصر مرئية
waypoints (نقاط الطريق)
A blue callout box with an arrow pointing to the 'waypoints' variable in the Python code. The box contains Arabic text explaining the term.
📄 النص الكامل للصفحة
# specifies the patrol coordinates
waypoints = [[-30, 20], [-60, 30], [-75, 0], [-40, -10]]
# target altitude of the drone in meters
self.target_altitude = 8
while self.step(self.time_step) != -1:
# reads sensors
roll, pitch, yaw = self.imu.getRollPitchYaw()
x_pos, y_pos, altitude = self.gps.getValues()
roll_acceleration, pitch_acceleration, _ = self.gyro.getValues()
self.current_pose = [x_pos, y_pos, altitude, roll, pitch, yaw]
if altitude > self.target_altitude - 1:
# as soon as it reaches the target altitude,
# computes the disturbances to go to the given waypoints
if self.getTime() - t1 > 0.1:
yaw_disturbance, pitch_disturbance = self.move_to_target(
waypoints)
t1 = self.getTime()
# calculates the desired input values for roll, pitch, yaw,
# and altitude using various constants and disturbance values
roll_input = self.K_ROLL_P * clamp(roll, -1, 1) + \
roll_acceleration + roll_disturbance
pitch_input = self.K_PITCH_P * clamp(pitch, -1, 1) + \
pitch_acceleration + pitch_disturbance
yaw_input = yaw_disturbance
clamped_difference_altitude = clamp(self.target_altitude - \
altitude + self.K_VERTICAL_OFFSET, -1, 1)
vertical_input = self.K_VERTICAL_P * \
pow(clamped_difference_altitude, 3.0)
# calculates the motors' input values based on the
# desired roll, pitch, yaw, and altitude values
front_left_motor_input = self.K_VERTICAL_THRUST + vertical_input \
- yaw_input + pitch_input - roll_input
front_right_motor_input = self.K_VERTICAL_THRUST + vertical_input \
+ yaw_input + pitch_input + roll_input
rear_left_motor_input = self.K_VERTICAL_THRUST + vertical_input \
+ yaw_input - pitch_input - roll_input
rear_right_motor_input = self.K_VERTICAL_THRUST + vertical_input \
- yaw_input - pitch_input + roll_input
# sets the velocity of each motor based on the motors' input values calculated above
self.front_left_motor.setVelocity(front_left_motor_input)
self.front_right_motor.setVelocity(-front_right_motor_input)
self.rear_left_motor.setVelocity(rear_left_motor_input)
self.rear_right_motor.setVelocity(rear_right_motor_input)
robot = Mavic()
robot.run()
وزارة التعليم
323
Ministry of Education
2025 - 1447
--- VISUAL CONTEXT ---
**FIGURE**: waypoints (نقاط الطريق)
Description: A blue callout box with an arrow pointing to the 'waypoints' variable in the Python code. The box contains Arabic text explaining the term.
Context: Provides an Arabic translation and explanation for the 'waypoints' variable, clarifying that it refers to the specific path the drone will fly.
🎴 بطاقات تعليمية للمراجعة
عدد البطاقات: 4 بطاقة لهذه الصفحة
ما هي القيمة التي يتم تخزينها في المتغير 'self.target_altitude'؟
الإجابة: يتم تخزين الارتفاع المستهدف للطائرة المسيرة بالأمتار في المتغير 'self.target_altitude'.
الشرح: يشير اسم المتغير 'target_altitude' بوضوح إلى أنه يمثل الارتفاع المستهدف. القيمة المخزنة هي 8، مما يعني أن الطائرة تسعى للوصول إلى ارتفاع 8 أمتار.
تلميح: انظر إلى الوحدة المستخدمة في قيمة المتغير.
ما هو الغرض الأساسي من متغير 'waypoints' في الكود المقدم؟
الإجابة: يحدد متغير 'waypoints' الإحداثيات (المواقع) التي يجب على الطائرة المسيرة (الدرون) اتباعها لتحديد مسار رحلتها.
الشرح: كلمة 'waypoints' تعني نقاط الطريق أو المعالم التي توجه الطائرة المسيرة في مسارها المحدد. في هذا الكود، هي عبارة عن قائمة بإحداثيات (x, y) للطائرة لتتبعها.
تلميح: فكر في ماذا تعني كلمة 'waypoints' في سياق الملاحة أو المسارات.
ما هي وظيفة الجزء 'if altitude > self.target_altitude - 1:' في الكود؟
الإجابة: تتحقق هذه الجملة الشرطية مما إذا كانت الطائرة المسيرة قد وصلت إلى الارتفاع المستهدف أو قاربته (ضمن نطاق 1 متر)، لتتمكن بعدها من البدء في حساب الاضطرابات اللازمة للتحرك نحو نقاط الطريق.
الشرح: قبل أن تبدأ الطائرة المسيرة في تنفيذ أوامر الحركة الدقيقة نحو نقاط الطريق، يجب عليها أولاً الوصول إلى الارتفاع الذي تم تحديده كهدف. هذه الجملة تضمن أن الطائرة قد حققت هذا الشرط الأولي.
تلميح: ما هي الظروف التي يجب توافرها قبل البدء في تنفيذ مهام الملاحة المعقدة؟
اشرح كيف يتم حساب مدخلات المحركات (motor inputs) في الكود.
الإجابة: يتم حساب مدخلات المحركات (اليسار الأمامي، اليمين الأمامي، اليسار الخلفي، اليمين الخلفي) بناءً على قيم الانحراف (roll, pitch, yaw)، والارتفاع، بالإضافة إلى عوامل تصحيح واضطرابات محددة، باستخدام ثوابت التحكم (K_ROLL_P, K_PITCH_P, K_VERTICAL_P, K_VERTICAL_THRUST) وقيم المستشعرات.
الشرح: يتم تجميع قوى الدفع لكل محرك من خلال معالجة مدخلات التحكم المختلفة. تشمل هذه المدخلات: التحكم في الارتفاع (vertical_input)، التحكم في الانعراج (yaw_input)، التحكم في الميلان (pitch_input)، والتحكم في الدوران (roll_input). كل هذه المدخلات يتم دمجها مع ثابت الدفع الرأسي (K_VERTICAL_THRUST) وتطبيق ثوابت التحكم لتحديد سرعة كل محرك.
تلميح: ما هي المكونات الأساسية التي تؤثر على حركة الدرون (الدوران، الميلان، الانعراج، الارتفاع) وكيف تتداخل مع بعضها البعض؟