Skip to content

Commit

Permalink
Merge pull request #213 from bitcraze/bug-sys-type-overwrite
Browse files Browse the repository at this point in the history
Make system_type in LighthouseConfigWriter.write_and_store_config() optional
  • Loading branch information
knmcguire authored Mar 18, 2021
2 parents 3665934 + 33b4521 commit c19a7c3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions cflib/localization/lighthouse_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def __init__(self, cf, nr_of_base_stations=16):
self._write_failed_for_one_or_more_objects = False
self._nr_of_base_stations = nr_of_base_stations

def write_and_store_config(self, data_stored_cb, geos=None, calibs=None,
system_type=LighthouseConfigFileManager.SYSTEM_TYPE_V2):
def write_and_store_config(self, data_stored_cb, geos=None, calibs=None, system_type=None):
"""
Transfer geometry and calibration data to the Crazyflie and persist to permanent storage.
The callback is called when done.
Expand All @@ -146,16 +145,17 @@ def write_and_store_config(self, data_stored_cb, geos=None, calibs=None,

self._write_failed_for_one_or_more_objects = False

# Change system type first as this will erase calib and geo data in the CF.
# Changing system type may trigger a lengthy operation (up to 0.5 s) if the persistant memory requires defrag.
# Setting a param is an asynchronous operataion, and it is not possible to know if the system swich is finished
# before we continue.
self._cf.param.set_value('lighthouse.systemType', system_type)

# We add a sleep here to make sure the change of system type is finished. It is dirty but will have to do for
# now. A more propper solution would be to add support for Remote Procedure Calls (RPC) with synchronous
# function calls.
time.sleep(0.8)
if system_type is not None:
# Change system type first as this will erase calib and geo data in the CF.
# Changing system type may trigger a lengthy operation (up to 0.5 s) if the persistant memory requires
# defrag. Setting a param is an asynchronous operataion, and it is not possible to know if the system
# swich is finished before we continue.
self._cf.param.set_value('lighthouse.systemType', system_type)

# We add a sleep here to make sure the change of system type is finished. It is dirty but will have to
# do for now. A more propper solution would be to add support for Remote Procedure Calls (RPC) with
# synchronous function calls.
time.sleep(0.8)

self._next()

Expand Down

0 comments on commit c19a7c3

Please sign in to comment.