diff --git a/salt/drone/crazyflie-lib-python b/salt/drone/crazyflie-lib-python index b9612f7d1905e98d4d22fa2367f144c6cd5c0ad0..b3ef5eb222f83f71a5d0a6e7ab29965783e51523 160000 --- a/salt/drone/crazyflie-lib-python +++ b/salt/drone/crazyflie-lib-python @@ -1 +1 @@ -Subproject commit b9612f7d1905e98d4d22fa2367f144c6cd5c0ad0 +Subproject commit b3ef5eb222f83f71a5d0a6e7ab29965783e51523 diff --git a/salt/drone/scripts/bridge.py b/salt/drone/scripts/bridge.py index c5a7a5f88e8b6360547c3387d775f2353a992106..39289557dba30cb023578125b85b65ae0e8d6374 100644 --- a/salt/drone/scripts/bridge.py +++ b/salt/drone/scripts/bridge.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import logging import sys @@ -176,4 +176,3 @@ if __name__ == '__main__': except KeyboardInterrupt: print('\n') bridge.stop() - diff --git a/salt/drone/scripts/circle_flightscript.py b/salt/drone/scripts/circle_flightscript.py index 9bf449aed6f8975eb4aebdae32ba4638b6b392f8..0ce1b1a24d1b5b885bef9ab40a31902dcb4d689d 100755 --- a/salt/drone/scripts/circle_flightscript.py +++ b/salt/drone/scripts/circle_flightscript.py @@ -1,17 +1,26 @@ -""" -This script shows a simple scripted flight path using the MotionCommander class. +#!/usr/bin/env python3 -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 sys import cflib.crtp from cflib.crazyflie.syncCrazyflie import SyncCrazyflie from cflib.positioning.motion_commander import MotionCommander -URI = 'radio://0/80/2M' +URI = '' + +if len(sys.argv) >= 2: + if sys.argv[1] == 'radio': + URI = 'radio://0/80/2M' + elif sys.argv[1] == 'prrt': + URI = 'prrt://10.8.0.208:5000' + elif sys.argv[1] == 'serial': + URI = 'serial://pi' + else: + sys.exit('Give a valid argument.') +else: + sys.exit('Give a commandline argument.') # Only output errors from the logging framework logging.basicConfig(level=logging.ERROR) @@ -21,43 +30,44 @@ if __name__ == '__main__': cflib.crtp.init_drivers(enable_debug_driver=False) with SyncCrazyflie(URI) as scf: + # n_points = 16 radius = 0.4 circle_time = 4 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.start_linear_motion(0.0, -0.121792748 , 0.6122934918 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, -0.3468364021 , 0.5190773581 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, -0.5190773581 , 0.3468364021 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, -0.6122934918 , 0.121792748 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, -0.6122934918 , -0.121792748 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, -0.5190773581 , -0.3468364021 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, -0.3468364021 , -0.5190773581 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, -0.121792748 , -0.6122934918 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, 0.121792748 , -0.6122934918 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, 0.3468364021 , -0.5190773581 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, 0.5190773581 , -0.3468364021 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, 0.6122934918 , -0.121792748 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, 0.6122934918 , 0.121792748 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, 0.5190773581 , 0.3468364021 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, 0.3468364021 , 0.5190773581 ) + time.sleep( 0.25 ) + mc.start_linear_motion(0.0, 0.121792748 , 0.6122934918 ) + time.sleep( 0.25 ) mc.stop() time.sleep(1.5) diff --git a/salt/drone/scripts/flightscript.py b/salt/drone/scripts/flightscript.py deleted file mode 100755 index bd59703bf603f25be7a925fd8e76642643b70f0e..0000000000000000000000000000000000000000 --- a/salt/drone/scripts/flightscript.py +++ /dev/null @@ -1,53 +0,0 @@ -""" -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: - # We take off when the commander is created - with MotionCommander(scf) as mc: - print('Taking off!') - time.sleep(1) - - # There is a set of functions that move a specific distance - # We can move in all directions - print('Moving forward 0.5m') - mc.forward(0.5) - # Wait a bit - time.sleep(1) - - print('Moving up 0.2m') - mc.up(0.2) - # Wait a bit - time.sleep(1) - - print('Doing a 180deg circle') - mc.circle_right(0.1, velocity=0.1, angle_degrees=180) - - print('Moving down 0.2m') - mc.down(0.2) - # Wait a bit - time.sleep(1) - - print('Moving forward 0.5m') - mc.forward(0.5) - - # We land when the MotionCommander goes out of scope - print('Landing!') diff --git a/salt/drone/scripts/line_flightscript.py b/salt/drone/scripts/line_flightscript.py new file mode 100755 index 0000000000000000000000000000000000000000..8edf647e6d16042afb6e7517b0cf28503a613053 --- /dev/null +++ b/salt/drone/scripts/line_flightscript.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 + +import logging +import time +import sys + +import cflib.crtp +from cflib.crazyflie.syncCrazyflie import SyncCrazyflie +from cflib.positioning.motion_commander import MotionCommander + +URI = '' + +if len(sys.argv) >= 2: + if sys.argv[1] == 'radio': + URI = 'radio://0/80/2M' + elif sys.argv[1] == 'prrt': + URI = 'prrt://10.8.0.208:5000' + elif sys.argv[1] == 'serial': + URI = 'serial://pi' + else: + sys.exit('Give a valid argument.') +else: + sys.exit('Give a commandline argument.') + +# 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: + # n_points = 2 radius = 0.25 circle_time = 2 + with MotionCommander(scf) as mc: + time.sleep(1.5) + + for i in range(5): + mc.start_linear_motion(0.0, -0.5 , 0.0 ) + time.sleep( 1.0 ) + mc.stop() + time.sleep(0.2) + mc.start_linear_motion(0.0, 0.5 , -0.0 ) + time.sleep( 1.0 ) + mc.stop() + time.sleep(0.2) + + time.sleep(1.3) diff --git a/salt/drone/scripts/log_gen_flightscript.py b/salt/drone/scripts/log_gen_flightscript.py new file mode 100755 index 0000000000000000000000000000000000000000..166d6906275fd6b877e4924267ed1b3e906b9c1c --- /dev/null +++ b/salt/drone/scripts/log_gen_flightscript.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 + +import logging +import time +import sys + +import cflib.crtp +from cflib.crazyflie.syncCrazyflie import SyncCrazyflie +from cflib.positioning.motion_commander import MotionCommander + +URI = '' + +if len(sys.argv) >= 2: + if sys.argv[1] == 'radio': + URI = 'radio://0/80/2M' + elif sys.argv[1] == 'prrt': + URI = 'prrt://10.8.0.208:5000' + elif sys.argv[1] == 'serial': + URI = 'serial://pi' + else: + sys.exit('Give a valid argument.') +else: + sys.exit('Give a commandline argument.') + +# 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: + print('Taking off!') + time.sleep(0.5) + + print('Moving forward') + mc.forward(0.3) + time.sleep(0.5) + + print('Moving up') + mc.up(0.2) + + print('Turn left') + mc.turn_left(90) + + print('Moving left') + mc.left(0.3) + time.sleep(0.5) + + print('Landing!') diff --git a/salt/drone/scripts/prrt_simple_flightscript.py b/salt/drone/scripts/prrt_simple_flightscript.py deleted file mode 100755 index 358937eb8123ceda993482c7b27f252abcf5aecb..0000000000000000000000000000000000000000 --- a/salt/drone/scripts/prrt_simple_flightscript.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -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 = 'prrt://10.8.0.208:5000' - -# 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: - # We take off when the commander is created - with MotionCommander(scf) as mc: - print('Taking off!') - time.sleep(0.1) - # We land when the MotionCommander goes out of scope - print('Landing!') diff --git a/salt/drone/scripts/simple_flightscript.py b/salt/drone/scripts/simple_flightscript.py index 8c10a178ed604592127adc9aa6f59f1e39af602e..d631228ab33642f60ae084f958be95e3c700c944 100755 --- a/salt/drone/scripts/simple_flightscript.py +++ b/salt/drone/scripts/simple_flightscript.py @@ -1,17 +1,26 @@ -""" -This script shows a simple scripted flight path using the MotionCommander class. +#!/usr/bin/env python3 -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 sys import cflib.crtp from cflib.crazyflie.syncCrazyflie import SyncCrazyflie from cflib.positioning.motion_commander import MotionCommander -URI = 'radio://0/80/2M' +URI = '' + +if len(sys.argv) >= 2: + if sys.argv[1] == 'radio': + URI = 'radio://0/80/2M' + elif sys.argv[1] == 'prrt': + URI = 'prrt://10.8.0.208:5000' + elif sys.argv[1] == 'serial': + URI = 'serial://pi' + else: + sys.exit('Give a valid argument.') +else: + sys.exit('Give a commandline argument.') # Only output errors from the logging framework logging.basicConfig(level=logging.ERROR) diff --git a/salt/drone/scripts/uart_flightscript.py b/salt/drone/scripts/uart_flightscript.py deleted file mode 100755 index fd302babbe275ec1a4e4264b386d80956eabf64d..0000000000000000000000000000000000000000 --- a/salt/drone/scripts/uart_flightscript.py +++ /dev/null @@ -1,53 +0,0 @@ -""" -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 = 'serial://pi' - -# 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: - # We take off when the commander is created - with MotionCommander(scf) as mc: - print('Taking off!') - time.sleep(1) - - # There is a set of functions that move a specific distance - # We can move in all directions - print('Moving forward 0.5m') - mc.forward(0.5) - # Wait a bit - time.sleep(1) - - print('Moving up 0.2m') - mc.up(0.2) - # Wait a bit - time.sleep(1) - - print('Doing a 180deg circle') - mc.circle_right(0.1, velocity=0.1, angle_degrees=180) - - print('Moving down 0.2m') - mc.down(0.2) - # Wait a bit - time.sleep(1) - - print('Moving forward 0.5m') - mc.forward(0.5) - - # We land when the MotionCommander goes out of scope - print('Landing!') \ No newline at end of file diff --git a/salt/drone/scripts/uart_simple_flightscript.py b/salt/drone/scripts/uart_simple_flightscript.py deleted file mode 100755 index 95c33fd33d09225cd66a9cc67089d7e880ec9e41..0000000000000000000000000000000000000000 --- a/salt/drone/scripts/uart_simple_flightscript.py +++ /dev/null @@ -1,29 +0,0 @@ -""" -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 = 'serial://pi' - -# 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: - # We take off when the commander is created - with MotionCommander(scf) as mc: - print('Taking off!') - time.sleep(0.1) - # We land when the MotionCommander goes out of scope - print('Landing!') diff --git a/salt/drone/scripts/velocity_point_generation.py b/salt/drone/scripts/velocity_point_generation.py index 8467fc5fc82166e6b8eca979823db6d032a909d8..9beb8ac8ef76e1723282279ff74c8971fe3b4f02 100644 --- a/salt/drone/scripts/velocity_point_generation.py +++ b/salt/drone/scripts/velocity_point_generation.py @@ -1,8 +1,9 @@ import numpy as np -n_points = 16 -radius = 0.4 -time_for_segment = 4/n_points +n_points = 2 +radius = 0.25 +circle_time = 2 +time_for_segment = circle_time/n_points y_points = np.arange(n_points+1, dtype=np.float64) z_points = np.arange(n_points+1, dtype=np.float64) @@ -13,8 +14,8 @@ 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_points = [x * radius for x in y_points] +z_points = [x * radius 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)] @@ -22,5 +23,8 @@ 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)] +y_velocity = np.around(y_velocity, 10) +z_velocity = np.around(z_velocity, 10) + 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 + print("mc.start_linear_motion(0.0,", y_velocity[i], ",", z_velocity[i], ")\ntime.sleep(", time_for_segment, ")") diff --git a/salt/prrt/files/PRRT b/salt/prrt/files/PRRT index f463a13086665594e6c103b03c9d98fce1e4424d..3063e8bc2078743196133e4d80748098daa61999 160000 --- a/salt/prrt/files/PRRT +++ b/salt/prrt/files/PRRT @@ -1 +1 @@ -Subproject commit f463a13086665594e6c103b03c9d98fce1e4424d +Subproject commit 3063e8bc2078743196133e4d80748098daa61999