Skip to content

Commit ec721c6

Browse files
Merge pull request #493 from neurobionics/IMU_debugging
Making MSCL IMU import works across different mscl versions
2 parents 1bcc2d4 + b7bbb07 commit ec721c6

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

opensourceleg/sensors/imu.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,25 @@ def __init__(
9595
"""
9696
# Attempt to import the MSCL library and add its path.
9797
try:
98-
import sys
98+
try:
99+
import mscl
100+
except (ImportError, ModuleNotFoundError):
101+
# Falling back to old method of appending to sys.path for importing older versions of mscl
102+
import sys
99103

100-
sys.path.append("/usr/share/python3-mscl")
101-
102-
import mscl
104+
legacy_path = "/usr/share/python3-mscl"
105+
if legacy_path not in sys.path:
106+
sys.path.append(legacy_path)
107+
import mscl
103108

104109
self.mscl = mscl
105110
except ImportError:
106111
LOGGER.warning(
107112
"Failed to import mscl. Please install the MSCL library from Lord Microstrain and append the path "
108113
"to the PYTHONPATH or sys.path. Checkout https://github.com/LORD-MicroStrain/MSCL/tree/master "
109114
"and https://lord-microstrain.github.io/MSCL/Documentation/MSCL%20API%20Documentation/index.html"
115+
"If you are using a newer version of MSCL, you may need to add /usr/lib/python3.version/dist-packages \
116+
to PYTHONPATH"
110117
)
111118

112119
if not offline:

0 commit comments

Comments
 (0)