Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

有线划船机SDK使用相关事项

一、硬件部署

1.划船机

2.传感器及主控板:一个X-board V3主控板/STM32F407+两个OMRON编码器E6B2-CWZ6C

3.编码器接线方式和主控板接线方式

左传感器 V3引脚 STM32引脚 右传感器 V3引脚 STM32引脚
D2 D1 D3 D2
A0 D3 D4 D4
A1 D5 D5 D6
GND GND GND GND
5V 5V 5V 5V

4.设置主控板IP

使用插件中SetIpAndMAC.unity设置主控板IP

COM:使用MicroUSB线连接电脑后,在设备管理器->端口中查看
串口波特率:根据中控版中的一致(一般为9600/115200)
硬件IP:即写入设置给主控板的IP地址
设备MAC:即写入主控板的MAC地址

点确定按钮后,显示IPOK即完成设置,重新插拔数据线并插入网线后,能ping通即可

5.连接方式

主控板及传感器安装在划船机上,主控板通过网线连接路由器,pico头盔通过WiFi连接路由器

二、软件

1.下载 GyroSensor 插件V1.2.3版本

2.单独的使用场景示例

在 GyroSensor\WiredSensor\RowingWired\RowingWiredDemo.unity 场景中:

相机上挂载RowingWiredDemo.cs

相机下放置一个名为IDSInputManager的空物体,该物体上挂在脚本AcrylicEncoderGyroSensorManager.cs

在场景中添加需要控制的物体Cube,给Cube田间RigBody组件,其中Drag=1,Angular Drag=30

3.使用说明

RowingWiredDemo.cs 中:

设置划船机IP(上述写入主控板的IP)

ES3.Save("HWIP", "192.168.1.100");

获取inputManager

inputManager = transform.Find("IDSInputManager").GetComponent();
inputManager.launchState += InputManager_launchState;

inputManager.GetSpeed:获取加速度,并施加给刚体;
inputManager.GetAngle:获取扭矩,并施加给刚体,负责控制方向

cube.AddTorque(inputManager.GetAngle);
cube.AddRelativeForce(Vector3.forward * inputManager.GetSpeed, ForceMode.Acceleration);

三、流程说明

  1. 在传感其中获取单位时间编码器转过的值,分别向unity传递左侧变化值、右侧变化值、间隔时间;
  2. 划船机向后拉时,传感器数值增加,获取前进的力;放回时和停在某位置不动时,不提供前进的力;
  3. 在unity中,通过左侧变化值、右侧变化值、间隔时间分别计算左侧、右侧加速度;
  4. 获取左右加速度在水平方向的差值,并与速度的比值作为旋转系数。

四、补充说明

1.调用方式还可以参考VR健身运动外设使用说明 V1.2.1

在TestGame.unity场景中,Main Camera上挂载脚本在TestGame.cs

在该脚本中

  • 脚本需要继承 IController,ICanGetUtility,ICanSendEvent 接口

  • _deviceType 设置为 DeviceType.RowingWired

  • Start()函数中先设置主控板IP(之前写入主控板的IP):
    ES3.Save<string>("HWIP", "192.168.1.200");

  • Start()函数中发送设备类型:
    this.SendEvent(new DeviceManagerEvent() { deviceType = _deviceType });

  • Start()函数中获取IDeviceManager:
    deviceManager = this.GetUtility<IDeviceManager>();

  • Start()函数中初始化IDeviceManager:
    deviceManager.Init(GyroSensorType.Wired);

  • Start()函数中函数中获取IDeviceManager添加事件,可以在DeviceManager_LogState函数中获取速度:
    deviceManager.logState += DeviceManager_LogState;

  • 需要有该函数:
    public IArchitecture GetArchitecture()

2.如果打包pico应用时出现 allowbackup 相关的错误,原因是Plugins中的app-debug.arr和PICO SDK冲突,两种解决办法:

留下评论

您的电子邮箱地址不会被公开。 必填项已用*标注