Loading salt/drone/scripts/circle_flightscript.py 0 → 100644 +63 −0 Original line number Diff line number Diff line """ This script shows a simple scripted flight path using the MotionCommander class. Simple example that connects to the crazyflie at `URI` and runs a sequence. Change the URI variable to your Crazyflie configuration. """ import logging import time import cflib.crtp from cflib.crazyflie.syncCrazyflie import SyncCrazyflie from cflib.positioning.motion_commander import MotionCommander URI = 'radio://0/80/2M' # Only output errors from the logging framework logging.basicConfig(level=logging.ERROR) if __name__ == '__main__': # Initialize the low-level drivers (don't list the debug drivers) cflib.crtp.init_drivers(enable_debug_driver=False) with SyncCrazyflie(URI) as scf: with MotionCommander(scf) as mc: mc.up(0.4) time.sleep(1.5) for i in range(2): mc.start_linear_motion(0.0, -0.12179274798194117, 0.6122934917841437) time.sleep(0.25) mc.start_linear_motion(0.0, -0.34683640211958267, 0.5190773581143323) time.sleep(0.25) mc.start_linear_motion(0.0, -0.5190773581143324, 0.3468364021195829) time.sleep(0.25) mc.start_linear_motion(0.0, -0.6122934917841437, 0.12179274798194117) time.sleep(0.25) mc.start_linear_motion(0.0, -0.6122934917841437, -0.12179274798194117) time.sleep(0.25) mc.start_linear_motion(0.0, -0.5190773581143324, -0.34683640211958267) time.sleep(0.25) mc.start_linear_motion(0.0, -0.3468364021195829, -0.5190773581143324) time.sleep(0.25) mc.start_linear_motion(0.0, -0.12179274798194117, -0.6122934917841436) time.sleep(0.25) mc.start_linear_motion(0.0, 0.12179274798194095, -0.6122934917841437) time.sleep(0.25) mc.start_linear_motion(0.0, 0.3468364021195829, -0.5190773581143325) time.sleep(0.25) mc.start_linear_motion(0.0, 0.5190773581143316, -0.34683640211958244) time.sleep(0.25) mc.start_linear_motion(0.0, 0.6122934917841443, -0.12179274798194162) time.sleep(0.25) mc.start_linear_motion(0.0, 0.6122934917841444, 0.1217927479819414) time.sleep(0.25) mc.start_linear_motion(0.0, 0.5190773581143318, 0.34683640211958244) time.sleep(0.25) mc.start_linear_motion(0.0, 0.34683640211958267, 0.5190773581143315) time.sleep(0.25) mc.start_linear_motion(0.0, 0.12179274798194162, 0.6122934917841443) time.sleep(0.25) mc.stop() time.sleep(1.5) salt/drone/scripts/velocity_point_generation.py 0 → 100644 +26 −0 Original line number Diff line number Diff line import numpy as np n_points = 16 radius = 0.4 time_for_segment = 4/n_points y_points = np.arange(n_points+1, dtype=np.float64) z_points = np.arange(n_points+1, dtype=np.float64) y_points = [x * 2*np.pi/n_points for x in y_points] z_points = [x * 2*np.pi/n_points for x in z_points] y_points = [np.cos(x) for x in y_points] z_points = [np.sin(x) for x in z_points] y_points = [x * 0.4 for x in y_points] z_points = [x * 0.4 for x in z_points] y_diff = [y_points[i+1]-y_points[i] for i in range(n_points)] z_diff = [z_points[i+1]-z_points[i] for i in range(n_points)] y_velocity = [y_diff[i]/time_for_segment for i in range(n_points)] z_velocity = [z_diff[i]/time_for_segment for i in range(n_points)] for i in range(n_points): print("mc.start_linear_motion(0.0,", y_velocity[i], ",", z_velocity[i], ")\ntime.sleep(", time_for_segment, ")") No newline at end of file Loading
salt/drone/scripts/circle_flightscript.py 0 → 100644 +63 −0 Original line number Diff line number Diff line """ This script shows a simple scripted flight path using the MotionCommander class. Simple example that connects to the crazyflie at `URI` and runs a sequence. Change the URI variable to your Crazyflie configuration. """ import logging import time import cflib.crtp from cflib.crazyflie.syncCrazyflie import SyncCrazyflie from cflib.positioning.motion_commander import MotionCommander URI = 'radio://0/80/2M' # Only output errors from the logging framework logging.basicConfig(level=logging.ERROR) if __name__ == '__main__': # Initialize the low-level drivers (don't list the debug drivers) cflib.crtp.init_drivers(enable_debug_driver=False) with SyncCrazyflie(URI) as scf: with MotionCommander(scf) as mc: mc.up(0.4) time.sleep(1.5) for i in range(2): mc.start_linear_motion(0.0, -0.12179274798194117, 0.6122934917841437) time.sleep(0.25) mc.start_linear_motion(0.0, -0.34683640211958267, 0.5190773581143323) time.sleep(0.25) mc.start_linear_motion(0.0, -0.5190773581143324, 0.3468364021195829) time.sleep(0.25) mc.start_linear_motion(0.0, -0.6122934917841437, 0.12179274798194117) time.sleep(0.25) mc.start_linear_motion(0.0, -0.6122934917841437, -0.12179274798194117) time.sleep(0.25) mc.start_linear_motion(0.0, -0.5190773581143324, -0.34683640211958267) time.sleep(0.25) mc.start_linear_motion(0.0, -0.3468364021195829, -0.5190773581143324) time.sleep(0.25) mc.start_linear_motion(0.0, -0.12179274798194117, -0.6122934917841436) time.sleep(0.25) mc.start_linear_motion(0.0, 0.12179274798194095, -0.6122934917841437) time.sleep(0.25) mc.start_linear_motion(0.0, 0.3468364021195829, -0.5190773581143325) time.sleep(0.25) mc.start_linear_motion(0.0, 0.5190773581143316, -0.34683640211958244) time.sleep(0.25) mc.start_linear_motion(0.0, 0.6122934917841443, -0.12179274798194162) time.sleep(0.25) mc.start_linear_motion(0.0, 0.6122934917841444, 0.1217927479819414) time.sleep(0.25) mc.start_linear_motion(0.0, 0.5190773581143318, 0.34683640211958244) time.sleep(0.25) mc.start_linear_motion(0.0, 0.34683640211958267, 0.5190773581143315) time.sleep(0.25) mc.start_linear_motion(0.0, 0.12179274798194162, 0.6122934917841443) time.sleep(0.25) mc.stop() time.sleep(1.5)
salt/drone/scripts/velocity_point_generation.py 0 → 100644 +26 −0 Original line number Diff line number Diff line import numpy as np n_points = 16 radius = 0.4 time_for_segment = 4/n_points y_points = np.arange(n_points+1, dtype=np.float64) z_points = np.arange(n_points+1, dtype=np.float64) y_points = [x * 2*np.pi/n_points for x in y_points] z_points = [x * 2*np.pi/n_points for x in z_points] y_points = [np.cos(x) for x in y_points] z_points = [np.sin(x) for x in z_points] y_points = [x * 0.4 for x in y_points] z_points = [x * 0.4 for x in z_points] y_diff = [y_points[i+1]-y_points[i] for i in range(n_points)] z_diff = [z_points[i+1]-z_points[i] for i in range(n_points)] y_velocity = [y_diff[i]/time_for_segment for i in range(n_points)] z_velocity = [z_diff[i]/time_for_segment for i in range(n_points)] for i in range(n_points): print("mc.start_linear_motion(0.0,", y_velocity[i], ",", z_velocity[i], ")\ntime.sleep(", time_for_segment, ")") No newline at end of file