Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
一、硬件部署
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.调用方式还可以参考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冲突,两种解决办法: