I am trying to run the simple hover program from another thread, but the parameter 'flightmode.althold' is not being set.
From 'basicparam.py', I can see the 'flightmode' parameter with althold as the first option. How can I make the hover program work?
Here is the hover program output:
Code: Select all
hold
sending initial thrust of 0
putting in althold
Unable to find variable [flightmode.althold]
Cannot set value for [flightmode.althold], it's not in the TOC!
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/miles/projects/crazyflie-lib-python/examples/alt_hold.py", line 13, in <module>
cf.param.set_value("flightmode.althold","True")
File "/home/miles/projects/crazyflie-lib-python/cflib/crazyflie/param.py", line 265, in set_value
raise KeyError('{} not in param TOC'.format(complete_name))
KeyError: 'flightmode.althold not in param TOC'
Code: Select all
import time
from cflib.crazyflie import Crazyflie
cf = Crazyflie()
print("sending initial thrust of 0")
cf.commander.send_setpoint(0,0,0,0);
time.sleep(0.5);
print("putting in althold")
cf.param.set_value("flightmode.althold","True")
print("Stay in althold for 7s")
it=0
while it<700:
cf.commander.send_setpoint(0,0,0,32767)
cf.param.set_value("flightmode.althold","True")
time.sleep(0.01)
it+=1
print("Close connection")
cf.commander.send_setpoint(0,0,0,0)
cf.close_link()