Metadata-Version: 2.4
Name: am-sdk
Version: 0.2.0
Summary: Host SDK for Artificial Motion joints: control API, simulator, EtherCAT and CAN-FD backends
Author: Artificial Motion
License: Apache-2.0
Project-URL: Homepage, https://artificialmotion.com
Project-URL: Source, https://github.com/artificialmotion/am-sdk
Project-URL: Documentation, https://github.com/artificialmotion/am-sdk/blob/main/docs/API.md
Project-URL: Changelog, https://github.com/artificialmotion/am-sdk/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/artificialmotion/am-sdk/issues
Keywords: robotics,actuator,humanoid,ethercat,can-fd,cia402,simulation,torque-estimation,collision-detection
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Software Development :: Libraries
Classifier: Development Status :: 3 - Alpha
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Provides-Extra: can
Requires-Dist: python-can>=4.3; extra == "can"
Provides-Extra: ecat
Requires-Dist: pysoem>=1.1; extra == "ecat"
Provides-Extra: mujoco
Requires-Dist: mujoco>=3.0; extra == "mujoco"
Provides-Extra: batch
Requires-Dist: numpy>=1.22; extra == "batch"
Provides-Extra: pinn
Requires-Dist: numpy>=1.22; extra == "pinn"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Dynamic: license-file

# am-sdk for Python

The Python side of the Artificial Motion host SDK. Same calls as the C library, same simulator.

```
pip install -e ".[dev]"            # from this folder
pip install -e ".[can]"            # CAN-FD through python-can
pip install -e ".[ecat]"           # EtherCAT through pysoem
pip install -e ".[mujoco]"         # MuJoCo coupling
pip install -e ".[batch]"          # numpy, for the batched actuator model
pip install -e ".[pinn]"           # numpy, for the optional PINN residual
```

```python
import math
import am_sdk as am

s = am.am_init(am.AmSessionConfig(interface="sim:M"))
joint = am.am_open_joint(s, 0)
am.am_start(s)
am.am_set_mode(joint, am.AmMode.IMPEDANCE)
am.am_enable(joint, timeout_ms=1000)

for k in range(3000):
    q_ref = 0.5 * math.sin(2 * math.pi * 0.5 * k * 1e-3)
    am.am_set_impedance(joint, am.AmImpedance(q_ref_rad=q_ref, kp_Nm_per_rad=150.0, kd_Nm_s_per_rad=6.0))
    am.am_cycle(s)
    t = am.am_read_telemetry(joint)

am.am_deinit(s)
```

A negative C status becomes an `AmError` with the status in `.status`.

Interfaces:

| `interface` | Backend |
|---|---|
| `sim`, `sim:M,H-F` | built-in simulator, one joint per unit |
| `ecat:<nic>` | EtherCAT (pysoem); set `bus=AmBus.ETHERCAT` |
| `can:<python-can interface>:<channel>[@nominal/data]` | CAN-FD (python-can); set `bus=AmBus.CANFD` |

Your own master: implement `am_sdk.Transport` (process-data exchange plus object read and write) and pass
`AmSessionConfig(backend=am_sdk.TransportBackend(your_transport))`. `am_sdk.SimWireTransport` is the
simulator behind that same interface, byte for byte.

Torque estimation and collision detection (simulated, pre-hardware): `am_sdk.estimation`, see
[docs/ESTIMATION.md](https://github.com/artificialmotion/am-sdk/blob/main/docs/ESTIMATION.md) and
`examples/05_torque_estimation_collision.py`.

Examples are in `examples/`, tests in `tests/` (`python -m pytest`). The tests include a cross-check
against the C library when it is built (see the top-level README).

Python runs the cycle with the host clock. Use it for development, commissioning and identification.
Run 1 kHz control on hardware from C.

Apache-2.0 for the code, the unit data and the specs (LICENSE, NOTICE). See the [top-level README](https://github.com/artificialmotion/am-sdk) for the full picture.

Actuator model for any actuator (MuJoCo, Isaac Lab, your own simulator): `am_sdk.actuator_model`,
documented in [docs/ACTUATOR_MODEL.md](https://github.com/artificialmotion/am-sdk/blob/main/docs/ACTUATOR_MODEL.md).

The API reference is [docs/API.md](https://github.com/artificialmotion/am-sdk/blob/main/docs/API.md). The joints are
not built yet: every unit value in this package is a simulated typical design value, not a measurement.
