Skip to content

Commit

Permalink
Removing wild binary file. @shreyhas
Browse files Browse the repository at this point in the history
  • Loading branch information
senthurayyappan committed Oct 9, 2024
1 parent 3eb2812 commit 5f847fc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 30 deletions.
Binary file removed .coverage 2
Binary file not shown.
39 changes: 19 additions & 20 deletions opensourceleg/robots/osl.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
from typing import Union

from opensourceleg.actuators.base import ActuatorBase
import time

import numpy as np

from opensourceleg.actuators.base import CONTROL_MODES, ActuatorBase
from opensourceleg.actuators.dephy import DephyLegacyActuator
from opensourceleg.logging import LOGGER
from opensourceleg.robots.base import RobotBase, TActuator, TSensor
from opensourceleg.sensors.base import IMUBase, LoadcellBase, SensorBase
from opensourceleg.sensors.imu import LordMicrostrainIMU

from opensourceleg.actuators.base import CONTROL_MODES
from opensourceleg.sensors.loadcell import SRILoadcell

import time
import numpy as np



class OpenSourceLeg(RobotBase[TActuator, TSensor]):
def start(self):
Expand Down Expand Up @@ -88,23 +86,25 @@ def joint_encoder_ankle(self) -> Union[TSensor, SensorBase]:

LOADCELL_MATRIX = np.array(
[
(-5.45598,-1317.68604,27.14505,22.8468,-11.1176,1283.02856),
(-20.23942,773.01343,-9.44841,-1546.70923,21.78232,744.52325),
(-811.76398,-16.82792,-825.67261,2.93904,-829.06409,7.45233),
(16.38306,0.22658,-0.50331,-0.23233,-17.0822,-0.03632),
(-9.81471,-0.03671,19.47362,-0.161,-9.76819,0.25571),
(-0.51744,-20.6571,0.18245,-20.42393,0.01944,-20.38067),
(-5.45598, -1317.68604, 27.14505, 22.8468, -11.1176, 1283.02856),
(-20.23942, 773.01343, -9.44841, -1546.70923, 21.78232, 744.52325),
(-811.76398, -16.82792, -825.67261, 2.93904, -829.06409, 7.45233),
(16.38306, 0.22658, -0.50331, -0.23233, -17.0822, -0.03632),
(-9.81471, -0.03671, 19.47362, -0.161, -9.76819, 0.25571),
(-0.51744, -20.6571, 0.18245, -20.42393, 0.01944, -20.38067),
]
)

osl = OpenSourceLeg[DephyLegacyActuator, SensorBase](
tag="opensourceleg",
actuators={
"knee": DephyLegacyActuator("knee", offline=False, frequency=frequency, gear_ratio=9 * (83/18)),
"knee": DephyLegacyActuator(
"knee", offline=False, frequency=frequency, gear_ratio=9 * (83 / 18)
),
},
sensors={
"imu": LordMicrostrainIMU(frequency=frequency, port="/dev/ttyS0"),
"loadcell": SRILoadcell(calibration_matrix=LOADCELL_MATRIX)
"loadcell": SRILoadcell(calibration_matrix=LOADCELL_MATRIX),
},
)

Expand All @@ -114,14 +114,13 @@ def joint_encoder_ankle(self) -> Union[TSensor, SensorBase]:
osl.knee.set_control_mode(CONTROL_MODES.POSITION)
osl.knee.set_position_gains()
osl.knee.set_output_position(osl.knee.output_position + np.deg2rad(10))
osl.loadcell.calibrate()
# osl.loadcell.calibrate()

while True:
try:
osl.update()
print(osl.sensors["loadcell"].fz)
time.sleep(1/frequency)
# print(osl.sensors["loadcell"].fz)
time.sleep(1 / frequency)

except KeyboardInterrupt:
exit()

22 changes: 13 additions & 9 deletions opensourceleg/sensors/imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

try:
import sys
sys.path.append('/usr/share/python3-mscl')

sys.path.append("/usr/share/python3-mscl")
import mscl
except ImportError:
LOGGER.error(
Expand All @@ -19,11 +20,11 @@
try:
import adafruit_bno055
import board
import busio
import busio
except ImportError:
LOGGER.error(
"Failed to import adafruit libs. Please install them using pip"
)
LOGGER.error("Failed to import adafruit libs. Please install them using pip")


class LordMicrostrainIMU(IMUBase):
"""
Sensor class for the Lord Microstrain IMU.
Expand Down Expand Up @@ -182,18 +183,21 @@ def acc_y(self) -> float:
def acc_z(self) -> float:
"""Returns estimated linear acceleration along the z-axis (m/s^2)."""
return self._data["estLinearAccelZ"]

@property
def gyro_x(self) -> float:
pass
LOGGER.warning("Gyro data not available for Lord Microstrain IMU")
return 0.0

@property
def gyro_y(self) -> float:
pass
LOGGER.warning("Gyro data not available for Lord Microstrain IMU")
return 0.0

@property
def gyro_z(self) -> float:
pass
LOGGER.warning("Gyro data not available for Lord Microstrain IMU")
return 0.0

@property
def timestamp(self) -> float:
Expand Down
2 changes: 1 addition & 1 deletion opensourceleg/sensors/loadcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def calibrate(
LOGGER.info(
f"[{self.__repr__()}] Initiating zeroing routine, please ensure that there is no ground contact force."
)
input('Press any key to start.')
input("Press any key to start.")

self.update(data_callback=data_callback)
self._calibration_offset = self._data
Expand Down

0 comments on commit 5f847fc

Please sign in to comment.