跳至主要内容
版本: 3.0.8

逆向服务

Haply 反向服务是一个基础组件,它将 Haply 的触觉设备与交互式应用程序集成在一起,作为后台 Windows 服务运行,以实现实时交互。 其功能包括

  • 设备发现和管理:自动识别和配置已连接的 Haply 设备。
  • 所有权管理:管理多个应用程序的设备访问权限,确保运行顺畅。
  • 实时状态流:高频率更新设备状态,实现精确控制。
  • 指令处理:高保真地执行力或位置指令,增强触觉反馈。
  • 后台运行:在后台运行,无需用户干预即可保持设备就绪状态。

运行、停止、重新启动

在 Windows 上:

  • 打开 服务 桌面应用程序:按 Windows+R 打开 运行 框,输入 services.msc然后按 Enter 或选择 OK.

在 Ubuntu 上

  • 开始
    • systemctl start haply-inverse-service.service
  • 停止
    • systemctl stop haply-inverse-service.service
  • 启用
    • systemctl enable haply-inverse-service.service
  • 禁用
    • systemctl disable haply-inverse-service.service

重要文件

在 Windows 上:

  • 配置文件位于%PROGRAMDATA%\Haply\Inverse\*-config.json
  • 日志文件位于%PROGRAMDATA%\Haply\Inverse\*-log.log

在 Ubuntu 上

  • 配置文件位于/etc/haply-inverse-service/*-config.json
  • 日志文件位于/var/log/haply-inverse-service/*-log.log

在 OSX 上

  • 配置文件位于$TMPDIR/Haply/Inverse/*-config.json
  • 日志文件位于$TMPDIR/Haply/Inverse/*-log.log

接口

HTTP 和 Websocket 接口都使用 JSON 格式化的有效载荷。

超文本传输协定

默认情况下,HTTP 服务在 http://localhost:10000.注意:端口可在配置中更改。

仪表板

仪表盘可在以下网址获取: http://localhost:10000

版本

方法获取

URL: http://localhost:10000/3.0/version

回复示例:

{
"build_time": "2024-08-07T16:01:53Z",
"git_branch": "main",
"git_describe": "3.0.0-2-gce34c39e",
"git_hash": "ce34c39e",
"git_tag": "3.0.0",
"project_name": "haply-inverse-service",
"project_version": "3.0.0.0"
}

设备

方法获取

URL: http://localhost:10000/3.0/devices

回复示例:

{
"inverse3": {
"049D": {
"config": {
"device_info": {
"firmware_version": 1,
"hardware_version": 7,
"id": "049D",
"model": 4,
"uuid": "5A9F3AC02E085C078AD6A4A113DE049D"
},
"extended_device_id": "5A9F3AC02E085C078AD6A4A113DE049D",
"extended_firmware_version": "77488E4644CB6057D0920B0B919C8B82",
"gravity_compensation": {
"enabled": true,
"scaling_factor": 0.75
},
"handedness": "left",
"torque_scaling": {
"enabled": true
}
},
"device_id": "049D",
"state": {
"angular_position": {
"a0": 0.0,
"a1": 0.0,
"a2": 0.0
},
"angular_velocity": {
"a0": 0.0,
"a1": 0.0,
"a2": 0.0
},
"body_orientation": {
"w": 1.0,
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"calibrated": false,
"cursor_position": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"cursor_velocity": {
"x": 0.0,
"y": 0.0,
"z": 0.0
},
"in_use": false,
"mode": "idle",
"power_supply": false,
"ready": false,
"started": false
},
"status": {
"initialization_received": {
"body_orientation": true,
"device_handedness": true,
"device_info": true,
"extended_device_id": true,
"extended_firmware_version": true,
"gravity_compensation": true,
"torque_scaling": true
},
"port": "COM12"
}
}
},
"verse_grip": {
"61582": {
"button": false,
"device_id": "61582",
"error": 0,
"hall": 0,
"orientation": {
"w": 0.17022705078125,
"x": -0.24114990234375,
"y": -0.95538330078125,
"z": -0.001220703125
}
}
},
"wireless_verse_grip": {
"0": {
"battery_level": 0.6200001239776611,
"buttons": {
"a": false,
"b": false,
"c": false
},
"device_id": "0",
"hall": 15,
"orientation": {
"w": -0.906463623046875,
"x": -0.379058837890625,
"y": -0.111785888671875,
"z": -0.136688232421875
}
}
}
}

力标尺

方法邮寄

URL: http://localhost:10000/3.0/force_scale

身体示例:

{
"force_scale": 0.5
}

回复示例:

{
"ok": true
}

重力补偿

方法邮寄

URL: http://localhost:10000/3.0/gravity_compensation

身体示例:

{
"device_id": "049D",
"enable": true,
"gravity_scaling_factor": 0.8
}

回复示例:

{
"ok": true
}

扭矩缩放

方法邮寄

URL: http://localhost:10000/3.0/torque_scaling

身体示例:

{
"device_id": "049D",
"enable": true
}

回复示例:

{
"ok": true
}

设备便携性

方法邮寄

URL: http://localhost:10000/3.0/device_handedness

身体示例:

{
"device_id": "049D",
"handedness": "right"
}

回复示例:

{
"ok": true
}

保存配置

仅适用于 Inverse3 设备。警告避免过于频繁地保存配置,因为可应用于任何特定设备的保存次数是有限的。

方法邮寄

URL: http://localhost:10000/3.0/save_configuration

身体示例:

{
"device_id": "049D"
}

回复示例:

{
"ok": true
}

串行启用

启用或禁用所有串行通信。当串行通信被禁用时,将无法向设备发送命令。

方法邮寄

URL: http://localhost:10000/3.0/serial_enable

身体示例:

{
"enable": true
}

回复示例:

{
"ok": true
}

抓握式垂直塞

启用或禁用所有握把垂直止动功能。

方法邮寄

URL: http://localhost:10000/3.0/features/grip_dropped_simulation_stopper

身体示例:

{
"enable": true,
"hall_effect_threshold": 17
}

回复示例:

{
"ok": true
}

Websocket

默认 websocket URL 为 ws://localhost:10000.注意:端口可在配置中更改。

初始信息

当连接到 websocket 时,服务会发送一条包含完整设备列表的信息。初始信息如下 JSON 格式:

{
"inverse3": {
"049D": {
"config": {
"device_info": {
"firmware_version": 1,
"hardware_version": 7,
"id": "049D",
"model": 4,
"uuid": "5A9F3AC02E085C078AD6A4A113DE049D"
},
"extended_device_id": "5A9F3AC02E085C078AD6A4A113DE049D",
"extended_firmware_version": "77488E4644CB6057D0920B0B919C8B82",
"gravity_compensation": {
"enabled": true,
"scaling_factor": 0.75
},
"handedness": "left",
"torque_scaling": {
"enabled": true
}
},
"device_id": "049D",
"state": {
"angular_position": {
"a0": -90.40308380126953,
"a1": 3.390819549560547,
"a2": 0.8826223015785217
},
"angular_velocity": {
"a0": 0,
"a1": 0,
"a2": 0
},
"body_orientation": {
"w": 1,
"x": 0,
"y": 0,
"z": 0
},
"calibrated": false,
"cursor_position": {
"x": -0.022379431873559952,
"y": -0.011212021112442017,
"z": -0.11827600002288818
},
"cursor_velocity": {
"x": 0,
"y": 0,
"z": 0
},
"in_use": false,
"mode": "angle",
"power_supply": true,
"ready": true,
"started": true
},
"status": {
"initialization_received": {
"body_orientation": true,
"device_handedness": true,
"device_info": true,
"extended_device_id": true,
"extended_firmware_version": true,
"gravity_compensation": true,
"torque_scaling": true
},
"port": "COM12"
}
}
},
"verse_grip": {
"61582": {
"button": false,
"device_id": "61582",
"error": 0,
"hall": 0,
"orientation": {
"w": 0.156982421875,
"x": -0.24163818359375,
"y": -0.95751953125,
"z": -0.00079345703125
}
}
},
"wireless_verse_grip": {
"0": {
"battery_level": 0.5999999046325684,
"buttons": {
"a": false,
"b": false,
"c": false
},
"device_id": "0",
"hall": 15,
"orientation": {
"w": -0.91265869140625,
"x": -0.389984130859375,
"y": -0.075103759765625,
"z": -0.07635498046875
}
}
}
}

状态更新信息

无论何时 任何 发生变化时,服务将发送一条状态更新信息,其中包含 一应俱全 设备。状态更新信息如下 JSON 格式:

{
"inverse3": {
"049D": {
"state": {
"angular_position": {
"a0": 0,
"a1": 0,
"a2": 0
},
"angular_velocity": {
"a0": 0,
"a1": 0,
"a2": 0
},
"body_orientation": {
"w": 1,
"x": 0,
"y": 0,
"z": 0
},
"calibrated": true,
"cursor_position": {
"x": -0.022203030064702034,
"y": -0.027979673817753792,
"z": -0.1170499324798584
},
"cursor_velocity": {
"x": 0,
"y": 0,
"z": 0
},
"in_use": true,
"mode": "position",
"power_supply": false,
"ready": true,
"started": true
}
}
},
"verse_grip": {
"61582": {
"button": false,
"device_id": "61582",
"error": 0,
"hall": 0,
"orientation": {
"w": 0.15423583984375,
"x": -0.24176025390625,
"y": -0.95794677734375,
"z": -0.0015869140625
}
}
},
"wireless_verse_grip": {
"0": {
"battery_level": 0.5999999046325684,
"buttons": {
"a": false,
"b": false,
"c": false
},
"device_id": "0",
"hall": 15,
"orientation": {
"w": -0.3958740234375,
"x": 0.639190673828125,
"y": -0.404388427734375,
"z": -0.51739501953125
}
}
}
}

指令信息

为了向 inverse3 客户端必须发送命令信息。下面是一个例子:

{
"inverse3": {
"049D": [
{
"command": "set_cursor_force",
"values": {
"x": 0,
"y": 0,
"z": 0
}
}
]
}
}

此外,还可以在一条信息中向多个设备发送命令:

{
"inverse3": {
"049D": [
{
"command": "set_cursor_force",
"values": {
"x": 0,
"y": 0,
"z": 0
}
}
],
"049E": [
{
"command": "set_cursor_force",
"values": {
"x": 0,
"y": 0,
"z": 0
}
}
]
}
}

目前可在 inverse3:

设置光标位置
{
"command": "set_cursor_position",
"values": {
"x": 1.0,
"y": 2.0,
"z": 3.0
}
}
设置光标力
{
"command": "set_cursor_force",
"values": {
"x": 0.5,
"y": 0.5,
"z": 0.5
}
}
设置角度位置
{
"command": "set_angular_position",
"values": {
"a0": 1.0,
"a1": 2.0,
"a2": 3.0
}
}
设置角扭矩
{
"command": "set_angular_torque",
"values": {
"a0": 0.5,
"a1": 0.5,
"a2": 0.5
}
}