Skip to content

Commit 4fd8b57

Browse files
making mscl import robust across mscl verions
1 parent ec02d00 commit 4fd8b57

4 files changed

Lines changed: 15 additions & 10 deletions

File tree

opensourceleg/sensors/encoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def encoder_map(self) -> Optional[np.polynomial.polynomial.Polynomial]:
397397
knee_enc = AS5048B(
398398
tag="knee",
399399
bus="/dev/i2c-2",
400-
A1_adr_pin=True,
400+
A1_adr_pin=False,
401401
A2_adr_pin=False,
402402
zero_position=0,
403403
)
@@ -406,7 +406,7 @@ def encoder_map(self) -> Optional[np.polynomial.polynomial.Polynomial]:
406406
tag="ankle",
407407
bus="/dev/i2c-3",
408408
A1_adr_pin=False,
409-
A2_adr_pin=True,
409+
A2_adr_pin=False,
410410
zero_position=0,
411411
)
412412

opensourceleg/sensors/imu.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,16 @@ def __init__(
9595
"""
9696
# Attempt to import the MSCL library and add its path.
9797
try:
98-
import sys
99-
100-
sys.path.append("/usr/share/python3-mscl")
101-
102-
import mscl
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
103+
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:

tutorials/sensors/reading_encoder_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
clock = SoftRealtimeLoop(dt=DT)
1414
encoder = AS5048B(
1515
tag="encoder1",
16-
bus="/dev/i2c-1",
16+
bus="/dev/i2c-2",
1717
A1_adr_pin=False,
18-
A2_adr_pin=True,
18+
A2_adr_pin=False,
1919
zero_position=0,
2020
enable_diagnostics=False,
2121
)

tutorials/sensors/reading_imu_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
clock = SoftRealtimeLoop(dt=DT)
1414
imu = LordMicrostrainIMU(
1515
tag="LordMicrostrainIMU",
16-
port=r"/dev/ttyS0",
16+
port=r"/dev/ttyAMA1",
1717
baud_rate=921600,
1818
frequency=FREQUENCY,
1919
update_timeout=500,

0 commit comments

Comments
 (0)