Hi everyone,
We just pushed a (beta) version of our Python Implementation on Pypi!
Installation:
We currently only have builds for Windows and Linux, on thoses platforms installation should be as simple as running:
pip install HaplyHardwareAPI
Example:
Extended documentation will soon be released, in order to get you started here is a basic example of how to connect and exchange data with the device.
import HaplyHardwareAPI
import serial
# list of all the ports
import serial.tools.list_ports
import time
ports = serial.tools.list_ports.comports()
for port, desc, hwid in sorted(ports):
print("{}: {} [{}]".format(port, desc, hwid))
# ask the user for the port to use:
port = input("Please enter the port to use: ")
try:
com = HaplyHardwareAPI.SerialStream(port)
except ValueError:
print("Error opening port: {}".format(ValueError))
Inverse3 = HaplyHardwareAPI.Inverse3(com)
Inverse3.SendDeviceWakeup()
device_id, device_model_num, hardware_version, firmware_version, quaternion = Inverse3.ReceiveDeviceInfo()
print("Device ID: {}".format(device_id))
print("Made Handshake with device")
positions = [0, 0, 0]
velocities = [0, 0, 0]
forces = [0, 0, 0]
start_time = time.perf_counter()
count = 0
while True:
count += 1
Inverse3.SendForce(forces)
positions, velocities = Inverse3.ReceiveState()
if count % 1000 == 0:
print("Positions: {}, Velocities: {}".format(
positions, velocities))
dt = time.perf_counter() - start_time
print("frequency = {} Hz".format(1000 / dt))
start_time = time.perf_counter()