Metadata-Version: 2.4
Name: py-ap200-simple-interface
Version: 0.1.0
Summary: a simple interface package for aimooe AP-200.
License: MIT
License-File: LICENSE
Author: GGN_2015
Author-email: neko@jlulug.org
Requires-Python: >=3.10
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
Description-Content-Type: text/markdown

# py_ap200_simple_interface
a simple interface package for aimooe AP-200.

## Installation

> [!WARNING]
> This package can only be installed under windows10/11 and x86-64 ISA.

```bash
pip install py_ap200_simple_interface
```

## Usage

```python
from py_ap200_simple_interface import AimooeExtDrive, I_ConnectionMethod

# Initialize AimooeExtDrive
drive = AimooeExtDrive()

# Connect Methods
# Select from I_USB, I_ETHERNET and I_WIFI
connect_method = I_ConnectionMethod.I_WIFI

# USB:
if connect_method == I_ConnectionMethod.I_USB:
    drive.connect(I_ConnectionMethod.I_USB)

# Ethernets:
#     An IP address should be given for ethernet connection
#     before connecting device with ethernet, you need to confirm that
#     your ethernet adaptor is in the same IP address segment with the device
#     and shutdown all proxy service on your computer which may affect the connection
if connect_method == I_ConnectionMethod.I_ETHERNET:
    drive.connect(I_ConnectionMethod.I_ETHERNET, "192.168.1.10")

# Wifi:
#     The wifi name of Aimooe Device is `AimPosition-XXXXXX`
#     The password of that wireless connection is `aimooe8888`
if connect_method == I_ConnectionMethod.I_WIFI:
    drive.connect(I_ConnectionMethod.I_WIFI)

# Some basic information
print(drive.get_connect_method())
print(drive.get_device_type())
print(drive.get_ip_address())
print(drive.get_manufacture_info())
print(drive.get_physical_address())

# BONE-1 is a sample specific tool
# path and toolname should not contain special characters
print(drive.get_specific_tool_info("./py_ap200_simple_interface/AimooeExt/AimToolsSample/", ["BONE-1"]))

# You can reconnect after disconnect
# After disconnect, you must reconnect before next use
drive.disconnect()
```

### Return value of `drive.get_specific_tool_info`

- `_ToolPath`: The selected tool folder.
- `_DiscretePoints`: The discrete points which do not lie in any tool listed.
- `_TimeCost`: The length of time between the begin and end of the device call.
- `<tool_name>`: Gives the specific infomation of a tool.
  - `MeanError` and `RMSError`: Error for markers.
  - `Origin`: The translation vector from tool space to camera space.
    - i.e. The position of gravity point of markers in camera space, if your tool file is generated by aimooe system.
  - `Tooltip`: If tooltip is defined, it shows the coordination of tooltip, otherwise the same as `Origin`.
  - `rMatrix`: The rotation matrix from tool coordination to camera coordination.
  - `qRotation`: Quaternion form in order $(x, y, z, w) = w + xi + yj + zk$ of the rotation matrix .
  - `MarkerCoordinates`: The marker coordinates (in camera space) in this tool.

```
{
	'_ToolPath': './py_ap200_simple_interface/AimooeExt/AimToolsSample/\\', 
	'BONE-1': {
		'MeanError': 0.1138331070542336, 
		'RMSError': 0.0003674850158859, 
		'Origin': [-137.575927734375, 120.42643737792969, 793.1155395507812], 
		'Tooltip': [-137.575927734375, 120.42643737792969, 793.1155395507812], 
		'Rotation': [2.061613082885742, 1.6536511182785034, -0.4304990470409393], 
		'qRotation': [0.7492992877960205, 0.601024329662323, -0.1564661413431168, 0.2298665046691895], 
		'rMatrix': [
			[0.2285761088132858, 0.9726269245147705, 0.0418308153748512], 
			[0.828761637210846, -0.1718621850013733, -0.5325575470924377], 
			[-0.5107907056808472, 0.1563977003097534, -0.8453594446182251]
		], 
		'MarkerCoordinates': {
			'0': [-132.94031926182967, 137.4289669332182, 782.6069181107938], 
			'1': [-164.12739196778332, 120.93405919807722, 791.4971644346351], 
			'2': [-115.37230320753432, 126.89401508498568, 790.1637162115628], 
			'3': [-137.8636773243661, 96.44871350623225, 808.1944560570211]
		}
	}, 
	'_DiscretePoints': {
		'0': [-144.17166590597648, -200.3791638982969, 1135.5793169583249], 
		'1': [-198.36308760690474, -156.32112285976535, 1102.102245959862], 
		'2': [-150.24065470212915, -126.80431827909578, 1094.3467438475025]
	}, 
	'_TimeCost': 0.006980419158935547
}
```

