📋 المحتوى المنظم
📖 محتوى تعليمي مفصّل
نوع: محتوى تعليمي
self.current_pose = 6 * [0] #X, Y, Z, yaw, pitch, roll
self.target_position = [0, 0, 0]
self.target_index = 0
self.target_altitude = 0
نوع: محتوى تعليمي
تهيئة موضع المسيرة (X, Y, Z) ودورانه (الالتفاف، الانحدار، الانعراج).
نوع: محتوى تعليمي
def move_to_target(self, waypoints):
نوع: محتوى تعليمي
# Moves the drone to the given coordinates
# Parameters:
# waypoints (list): list of X,Y coordinates
# Returns:
# yaw_disturbance (float): yaw disturbance (negative value to go on the right)
# pitch_disturbance (float): pitch disturbance (negative value to go forward)
نوع: محتوى تعليمي
if self.target_position[0:2] == [0, 0]: # initialization
self.target_position[0:2] = waypoints[0]
نوع: محتوى تعليمي
# if the drone is at the position with a precision of target_precision
if all([(abs(x1 - x2) < self.target_precision for (x1, x2)
in zip(self.target_position, self.current_pose[0:2]))]):
نوع: محتوى تعليمي
self.target_index += 1
if self.target_index > len(waypoints) - 1:
self.target_index = 0
self.target_position[0:2] = waypoints[self.target_index]
نوع: محتوى تعليمي
# computes the angle between the current position of the drone and its target position
# and normalizes the resulting angle to be within the range of [-pi, pi]
نوع: محتوى تعليمي
self.target_position[2] = np.arctan2(
self.target_position[1] - self.current_pose[1],
self.target_position[0] - self.current_pose[0])
angle_left = self.target_position[2] - self.current_pose[5]
angle_left = (angle_left + 2 * np.pi) % (2 * np.pi)
if (angle_left > np.pi):
angle_left -= 2 * np.pi
نوع: محتوى تعليمي
# turns the drone to the left or to the right according to the value
# and the sign of angle_left and adjusts pitch_disturbance
نوع: محتوى تعليمي
yaw_disturbance = self.MAX_YAW_DISTURBANCE * angle_left / (2 * np.pi)
pitch_disturbance = clamp(
np.log10(abs(angle_left)), self.MAX_PITCH_DISTURBANCE, 0.1)
نوع: محتوى تعليمي
return yaw_disturbance, pitch_disturbance
نوع: محتوى تعليمي
def run(self):
نوع: محتوى تعليمي
# time intervals used for adjustments in order to reach the target altitude
نوع: محتوى تعليمي
t1 = self.getTime()
roll_disturbance = 0
pitch_disturbance = 0
yaw_disturbance = 0
نوع: METADATA
وزارة التعليم
Ministry of Education
2023 - 1447
322
🔍 عناصر مرئية
A blue callout box with an arrow pointing to the Python code line 'self.current_pose = 6 * [0] #X, Y, Z, yaw, pitch, roll'. The box contains Arabic text explaining the purpose of the variables.
📄 النص الكامل للصفحة
self.current_pose = 6 * [0] #X, Y, Z, yaw, pitch, roll
self.target_position = [0, 0, 0]
self.target_index = 0
self.target_altitude = 0
تهيئة موضع المسيرة (X, Y, Z) ودورانه (الالتفاف، الانحدار، الانعراج).
def move_to_target(self, waypoints):
# Moves the drone to the given coordinates
# Parameters:
# waypoints (list): list of X,Y coordinates
# Returns:
# yaw_disturbance (float): yaw disturbance (negative value to go on the right)
# pitch_disturbance (float): pitch disturbance (negative value to go forward)
if self.target_position[0:2] == [0, 0]: # initialization
self.target_position[0:2] = waypoints[0]
# if the drone is at the position with a precision of target_precision
if all([(abs(x1 - x2) < self.target_precision for (x1, x2)
in zip(self.target_position, self.current_pose[0:2]))]):
self.target_index += 1
if self.target_index > len(waypoints) - 1:
self.target_index = 0
self.target_position[0:2] = waypoints[self.target_index]
# computes the angle between the current position of the drone and its target position
# and normalizes the resulting angle to be within the range of [-pi, pi]
self.target_position[2] = np.arctan2(
self.target_position[1] - self.current_pose[1],
self.target_position[0] - self.current_pose[0])
angle_left = self.target_position[2] - self.current_pose[5]
angle_left = (angle_left + 2 * np.pi) % (2 * np.pi)
if (angle_left > np.pi):
angle_left -= 2 * np.pi
# turns the drone to the left or to the right according to the value
# and the sign of angle_left and adjusts pitch_disturbance
yaw_disturbance = self.MAX_YAW_DISTURBANCE * angle_left / (2 * np.pi)
pitch_disturbance = clamp(
np.log10(abs(angle_left)), self.MAX_PITCH_DISTURBANCE, 0.1)
return yaw_disturbance, pitch_disturbance
def run(self):
# time intervals used for adjustments in order to reach the target altitude
t1 = self.getTime()
roll_disturbance = 0
pitch_disturbance = 0
yaw_disturbance = 0
وزارة التعليم
Ministry of Education
2023 - 1447
322
--- VISUAL CONTEXT ---
**DIAGRAM**: Untitled
Description: A blue callout box with an arrow pointing to the Python code line 'self.current_pose = 6 * [0] #X, Y, Z, yaw, pitch, roll'. The box contains Arabic text explaining the purpose of the variables.
Context: This box provides an Arabic explanation for the initial variable assignments in the Python code, clarifying what 'X, Y, Z, yaw, pitch, roll' represent in the context of drone positioning and rotation.