Update mock SDKs

This commit is contained in:
Simon Alibert
2025-03-15 22:26:47 +01:00
parent f6a2396484
commit 8d659a6aa9
2 changed files with 59 additions and 4 deletions

View File

@@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
"""Mocked classes and functions from dynamixel_sdk to allow for continuous integration # ruff: noqa: N802, E741
and testing code logic that requires hardware and devices (e.g. robot arms, cameras)
"""
Mocked classes and functions from dynamixel_sdk to allow for testing DynamixelMotorsBus code.
Warning: These mocked versions are minimalist. They do not exactly mock every behaviors Warning: These mocked versions are minimalist. They do not exactly mock every behaviors
from the original classes and functions (e.g. return types might be None instead of boolean). from the original classes and functions (e.g. return types might be None instead of boolean).
@@ -43,6 +45,31 @@ def get_default_motor_values(motor_index):
} }
# Macro for Control Table Value
def DXL_MAKEWORD(a, b):
return (a & 0xFF) | ((b & 0xFF) << 8)
def DXL_MAKEDWORD(a, b):
return (a & 0xFFFF) | (b & 0xFFFF) << 16
def DXL_LOWORD(l):
return l & 0xFFFF
def DXL_HIWORD(l):
return (l >> 16) & 0xFFFF
def DXL_LOBYTE(w):
return w & 0xFF
def DXL_HIBYTE(w):
return (w >> 8) & 0xFF
class PortHandler: class PortHandler:
def __init__(self, port): def __init__(self, port):
self.port = port self.port = port

View File

@@ -11,8 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
"""Mocked classes and functions from dynamixel_sdk to allow for continuous integration
and testing code logic that requires hardware and devices (e.g. robot arms, cameras) # ruff: noqa: N802, E741
"""
Mocked classes and functions from scservo_sdk to allow for testing FeetechMotorsBus code.
Warning: These mocked versions are minimalist. They do not exactly mock every behaviors Warning: These mocked versions are minimalist. They do not exactly mock every behaviors
from the original classes and functions (e.g. return types might be None instead of boolean). from the original classes and functions (e.g. return types might be None instead of boolean).
@@ -52,6 +55,31 @@ def get_default_motor_values(motor_index):
} }
# Macro for Control Table Value
def SCS_MAKEWORD(a, b):
return (a & 0xFF) | ((b & 0xFF) << 8)
def SCS_MAKEDWORD(a, b):
return (a & 0xFFFF) | (b & 0xFFFF) << 16
def SCS_LOWORD(l):
return l & 0xFFFF
def SCS_HIWORD(l):
return (l >> 16) & 0xFFFF
def SCS_LOBYTE(w):
return w & 0xFF
def SCS_HIBYTE(w):
return (w >> 8) & 0xFF
class PortHandler: class PortHandler:
def __init__(self, port): def __init__(self, port):
self.port = port self.port = port