From 6b1190381570ccf6929aec9d107c017b3f3bb8a8 Mon Sep 17 00:00:00 2001 From: Ember Chow Date: Wed, 20 Jul 2022 17:48:25 -0400 Subject: [PATCH 1/6] mock the runtime loaded libraries for sphinx build --- forcedimension/runtime.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/forcedimension/runtime.py b/forcedimension/runtime.py index ae1a70c..446a103 100644 --- a/forcedimension/runtime.py +++ b/forcedimension/runtime.py @@ -88,6 +88,14 @@ def version_tuple(version_string: str): @lru_cache def load(lib_name, search_dirs=(), silent=False): + + try: + if __sphinx_build__: + from mock import Mock + return Mock() + except NameError: + pass + if (sys.platform == "win32"): lib_ext = ".dll" lib_dir = "bin" From bcc953b34131295f7c9c25e3cc99e8f4d2c64eed Mon Sep 17 00:00:00 2001 From: Ember Chow Date: Wed, 20 Jul 2022 18:06:48 -0400 Subject: [PATCH 2/6] add version --- forcedimension/__init__.py | 145 +++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 71 deletions(-) diff --git a/forcedimension/__init__.py b/forcedimension/__init__.py index 7f48135..12a4a25 100644 --- a/forcedimension/__init__.py +++ b/forcedimension/__init__.py @@ -1,29 +1,30 @@ -from threading import Thread, Lock, Condition -from typing import MutableSequence, Optional, Callable, List -from typing import cast from math import nan - -from time import sleep, monotonic +from threading import Condition, Lock, Thread +from time import monotonic, sleep +from typing import Callable, List, MutableSequence, Optional +from typing import cast import forcedimension.dhd as dhd +from forcedimension.dhd import DeviceType +from forcedimension.dhd.adaptors import ( + DHDErrorNoDeviceFound, + DHDIOError, + ErrorNum, + StatusTuple, + errno_to_exception, +) import forcedimension.drd as drd from forcedimension.typing import IntVectorLike - from forcedimension.util import ( EuclidianVector, - JacobianMatrix, ImmutableWrapper, + JacobianMatrix, UpdateOpts, ) -from forcedimension.dhd import DeviceType -from forcedimension.dhd.adaptors import ( - StatusTuple, - DHDIOError, - DHDErrorNoDeviceFound, - ErrorNum, - errno_to_exception -) + +__version__ = '0.1.1' + DefaultVecType = EuclidianVector @@ -48,6 +49,7 @@ class HapticDevice: dhd and provides a peformant portable Pythonic interface for doing high-level control. """ + def __init__( self, ID: Optional[int] = None, @@ -385,6 +387,7 @@ def calculate_angular_velocity(self): self.calculate_jacobian() """ + def update_enc_and_calculate(self) -> None: self.update_enc() self.calculate_joint_angles() @@ -401,16 +404,16 @@ def update_enc(self) -> None: """ _, err = dhd.expert.getDeltaEncoders( - ID=cast(int, self._id), - out=self._enc - ) + ID=cast(int, self._id), + out=self._enc + ) if err and err != dhd.TIMEGUARD: raise errno_to_exception( ErrorNum(dhd.errorGetLast()))( ID=cast(int, self.ID), feature=dhd.expert.getDeltaEncoders - ) + ) def update_position(self) -> None: """ @@ -428,7 +431,7 @@ def update_position(self) -> None: ErrorNum(dhd.errorGetLast()))( ID=cast(int, self.ID), feature=dhd.getPosition - ) + ) def update_velocity(self) -> None: """ @@ -458,8 +461,8 @@ def update_angular_velocity(self): :rtype: None """ _, err = dhd.getAngularVelocityRad( - ID=cast(int, self._id), - out=self._w + ID=cast(int, self._id), + out=self._w ) if (err): @@ -487,7 +490,7 @@ def update_force(self): dhd.errorGetLast()))( ID=cast(int, self._id), feature=dhd.getForce - ) + ) def update_force_and_torque(self): """ @@ -505,9 +508,9 @@ def update_force_and_torque(self): if (err): raise errno_to_exception(dhd.errorGetLast())( - ID=cast(int, self._id), - feature=dhd.getForceAndTorque - ) + ID=cast(int, self._id), + feature=dhd.getForceAndTorque + ) def update_force_and_torque_and_gripper_force(self): """ @@ -555,19 +558,19 @@ def submit(self): """ self._req = False err = dhd.setForceAndTorque( - self._f_req, - self._t_req, - cast(int, self._id) - ) + self._f_req, + self._t_req, + cast(int, self._id) + ) if err: if err == dhd.MOTOR_SATURATED: pass else: raise errno_to_exception(ErrorNum(dhd.errorGetLast()))( - ID=cast(int, self._id), - feature=dhd.setForceAndTorqueAndGripperForce - ) + ID=cast(int, self._id), + feature=dhd.setForceAndTorqueAndGripperForce + ) def req( self, @@ -635,19 +638,19 @@ def stop(self): def submit_vibration(self): err = dhd.setVibration( - ID=cast(int, self._id), - f=self._vibration_req[0], - A=self._vibration_req[1], - device_type=self.devtype - ) + ID=cast(int, self._id), + f=self._vibration_req[0], + A=self._vibration_req[1], + device_type=self.devtype + ) if err: if err == dhd.MOTOR_SATURATED: pass raise errno_to_exception(ErrorNum(dhd.errorGetLast()))( - ID=cast(int, self._id), - feature=dhd.setVibration - ) + ID=cast(int, self._id), + feature=dhd.setVibration + ) def submit_enc(self): _, err = dhd.expert.getEnc( @@ -658,9 +661,9 @@ def submit_enc(self): if err: raise errno_to_exception(ErrorNum(dhd.errorGetLast()))( - ID=cast(int, self._id), - feature=dhd.expert.getEnc - ) + ID=cast(int, self._id), + feature=dhd.expert.getEnc + ) def enable_force(self, enabled: bool = True): """ @@ -680,9 +683,9 @@ def enable_brakes(self, enabled: bool = True): err = dhd.setBrakes(enabled) if err: raise errno_to_exception(ErrorNum(dhd.errorGetLast()))( - ID=cast(int, self._id), - feature=dhd.setVibration - ) + ID=cast(int, self._id), + feature=dhd.setVibration + ) def get_max_force(self) -> Optional[float]: """ @@ -907,9 +910,9 @@ def set_max_force(self, limit: Optional[float]) -> None: raise ValueError err = dhd.setMaxGripperForce( - ID=cast(int, self._id), - limit=limit - ) + ID=cast(int, self._id), + limit=limit + ) if err: raise errno_to_exception(ErrorNum(dhd.errorGetLast())) @@ -952,25 +955,25 @@ def fg(self): def calculate_gap(self): if self._enc is not None: self._gap = dhd.expert.gripperEncoderToGap( - ID=cast(int, self._id), - enc=self._enc - ) + ID=cast(int, self._id), + enc=self._enc + ) else: raise ValueError def calculate_angle(self): if self._enc is not None: self._angle = dhd.expert.gripperEncoderToAngleRad( - ID=cast(int, self._id), - enc=self._enc - ) + ID=cast(int, self._id), + enc=self._enc + ) else: raise ValueError def update_enc(self): self._enc, err = dhd.expert.getGripperEncoder( - ID=cast(int, self._id) - ) + ID=cast(int, self._id) + ) if err and err != dhd.TIMEGUARD: raise errno_to_exception(dhd.errorGetLast()) @@ -987,8 +990,8 @@ def update_linear_velocity(self): def update_angular_velocity(self): self._w, err = dhd.getGripperAngularVelocityRad( - ID=cast(int, self._id) - ) + ID=cast(int, self._id) + ) if err and err != dhd.TIMEGUARD: raise errno_to_exception(dhd.errorGetLast()) @@ -1005,18 +1008,18 @@ def update_gap(self): def update_thumb_pos(self): _, err = dhd.getGripperThumbPos( - cast(int, self._id), - out=self._thumb_pos - ) + cast(int, self._id), + out=self._thumb_pos + ) if err and err != dhd.TIMEGUARD: raise errno_to_exception(dhd.errorGetLast()) def update_finger_pos(self): _, err = dhd.getGripperFingerPos( - cast(int, self._id), - out=self._finger_pos - ) + cast(int, self._id), + out=self._finger_pos + ) if err and err != dhd.TIMEGUARD: raise errno_to_exception(dhd.errorGetLast()) @@ -1093,11 +1096,11 @@ def run(self): class HapticDaemon(Thread): def __init__( - self, - dev: HapticDevice, - update_list: UpdateOpts = UpdateOpts(), - forceon=False - ): + self, + dev: HapticDevice, + update_list: UpdateOpts = UpdateOpts(), + forceon=False + ): super().__init__() From 715778d60f00a447ab3f70573b6cfe444f18d2aa Mon Sep 17 00:00:00 2001 From: Ember Chow Date: Wed, 20 Jul 2022 18:24:59 -0400 Subject: [PATCH 3/6] update to match version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9218428..5f8deb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "forcedimension" -version = "0.0.1" +version = "0.1.2" authors = [ { name="Ember Chow", email="emberchow.business@gmail.com" }, ] From 05b7f9280b9cbacd3d38e6fd354dcf60d887ecd5 Mon Sep 17 00:00:00 2001 From: Ember Chow Date: Wed, 20 Jul 2022 18:29:09 -0400 Subject: [PATCH 4/6] update to match version in module --- forcedimension/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forcedimension/__init__.py b/forcedimension/__init__.py index 12a4a25..96fda0f 100644 --- a/forcedimension/__init__.py +++ b/forcedimension/__init__.py @@ -23,7 +23,7 @@ ) -__version__ = '0.1.1' +__version__ = '0.1.2' DefaultVecType = EuclidianVector From 91966bf2e435a65b58569963ef5a3c8b12fd5f63 Mon Sep 17 00:00:00 2001 From: Ember Chow Date: Wed, 20 Jul 2022 18:24:59 -0400 Subject: [PATCH 5/6] update to match version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9218428..5f8deb1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "forcedimension" -version = "0.0.1" +version = "0.1.2" authors = [ { name="Ember Chow", email="emberchow.business@gmail.com" }, ] From 896d33d9cbeb780ea254851330b411ee67ef2046 Mon Sep 17 00:00:00 2001 From: Ember Chow Date: Wed, 20 Jul 2022 18:29:09 -0400 Subject: [PATCH 6/6] update to match version in module --- forcedimension/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forcedimension/__init__.py b/forcedimension/__init__.py index 12a4a25..96fda0f 100644 --- a/forcedimension/__init__.py +++ b/forcedimension/__init__.py @@ -23,7 +23,7 @@ ) -__version__ = '0.1.1' +__version__ = '0.1.2' DefaultVecType = EuclidianVector