Drone Movement · Study
English translation
Execution conditions
This exercise simulates coordinates. When extending it to actual flight, separately check the provided device's coordinate system, units, and command response behavior.
Topics covered
Assuming forward and sideways directions stay the same after turning will lead to an incorrect path. First check the coordinate frames through calculation.
Overall workflow
Image/input events → coordinate/validity checks → bounded commands → path/failure checks
Body Frame and World Frame
If the aircraft's forward direction is x and left is y, moving forward after a yaw rotation follows a different direction in the World Frame. At yaw=90°, forward body movement follows the world y direction.
Changing the order of rotation and translation generally changes the result.
Examine paths and errors together
Even with a correct command path, accumulated distance errors change the endpoint. First check coordinates, units, and rotation signs in a simulated path, then examine endpoint distributions under different error conditions. Validate actual flight commands separately from this calculation.
Compare MATLAB and Python Tello commands
The existing MATLAB materials use the Ryze Tello support package. In Python, DJITelloPy can express the same actions.
MATLAB distance arguments use m, while Python move_forward arguments use cm. Also check rotation API units and directions.
For example, moving forward 0.5 m corresponds to moveforward(r,‘Distance’,0.5) in MATLAB and tello.move_forward(50) in Python. These calls send commands to an airborne aircraft, so the basic example checks only the command list and unit conversion.
Worked example
Start at (0,0) m with yaw=0°. Forward is body +x, right is body -y, and yaw is counterclockwise. Use the 5 provided commands.
import math
import numpy as np
import matplotlib.pyplot as plt
# world x: initial forward direction, world y: initial left direction, yaw: counterclockwise in degrees
commands=[('forward',1.),('right',.5),('yaw',90.),('forward',1.),('right',.5)]
pos=np.array([0.,0.]);yaw=0.;trace=[pos.copy()]
def body_to_world(dx,dy,yaw_deg):
a=math.radians(yaw_deg)
return np.array([[math.cos(a),-math.sin(a)],[math.sin(a),math.cos(a)]])@np.array([dx,dy])
# Example: world displacement for 1 m forward at yaw=90
print(body_to_world(1,0,90))
[6.123234e-17 1.000000e+00]
Official documentation and data
Reference example
View more examples