Skip to content

Commit c19a7c3

Browse files
authored
Merge pull request #213 from bitcraze/bug-sys-type-overwrite
Make system_type in LighthouseConfigWriter.write_and_store_config() optional
2 parents 3665934 + 33b4521 commit c19a7c3

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

cflib/localization/lighthouse_config_manager.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ def __init__(self, cf, nr_of_base_stations=16):
118118
self._write_failed_for_one_or_more_objects = False
119119
self._nr_of_base_stations = nr_of_base_stations
120120

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

147146
self._write_failed_for_one_or_more_objects = False
148147

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

160160
self._next()
161161

0 commit comments

Comments
 (0)