Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
WitMotion Wifi传感器
WitMotion 蓝牙传感器
根据官方wit-sdk和Android工程,导出.aar文件提供给unity使用
有线划船机: X-board V3 + OMRON编码器E6B2-CWZ6C X 2
获取外设运动时的角速度、加速度等值。
健身运动外设(自行车、椭圆机、划船机等),传感器(WitMotion蓝牙/Wifi传感器、有线自行车传感器及主控板),路由器,移动终端(头盔)
下载并导入 WFramework
2.1 在 WFramework 中下载插件,插件名称为:GyroSensor
(当前版本为V1.2.3)
2.2 插件导入后
1、将GyroSensor文件夹中的Plugins,移动到Assert文件夹中
2、配置unity设置
1.修改gradleTemplate.properties文件, 允许Unity引擎打包时添加AndroidX依赖。
文件地址:unity安装路径下
\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\GradleTemplates\gradleTemplate.properties
添加代码
android.useAndroidX=true
android.enableJetifier=true
2.在Unity项目的mainTemplate.gradle配置文件中添加AndroidX依赖
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
3.PlayerSettings->Player->PublishingSettings->Build->CustomMainGradleTemplate 勾选
DemoScene:Assets\GyroSensor\GyroSensor\Example\TestGame.unity
1、选择设备类型:Device Type
使用设备为主动控制骑马机时,需要使用骑马机IP进行初始化
horseControlManager.Init(HorseIP);
使用有线自行车/有线划船机时,需要写入设备主控板IP
ES3.Save<string>("HWIP", "192.168.1.200");
2、当前全部设备类型
public enum DeviceType
{
// 自行车
Bicycle,
// 儿童自行车
ChildrenBicycle,
// 椭圆机
Elliptica,
// 划船机
Rowing,
// 双桨划船机
DoubleRowing,
// 骑马机
HorseRiding,
// 儿童小马
ChildrenHorse,
// 平衡球
BalanceBall,
// 儿童摇摆木马
ChildrenRockingHorse,
// 主动控制骑马机
HorseControl,
// 亚克力自行车
BicycleWired,
// 冲浪机
Surfing,
// 有线划船机
RowingWired,
}
3、当前全部传感器类型
public enum GyroSensorType
{
// WIFI传感器
WIFI,
// 蓝牙传感器
BLE,
// 亚克力自行车、有线划船机
Wired
}
1、在初始化的脚本中,继承IController,ICanGetUtility,ICanSendEvent
2、确定设备类型和相关设备接口
DeviceType _deviceType = DeviceType.HorseControl 时,使用IHorseControlManager,并需要骑马机IP
DeviceType _deviceType = DeviceType.其他时,使用IDeviceManager
_deviceType == DeviceType.BicycleWired || _deviceType == DeviceType.RowingWired 时,需要提前设置IP(ES3.Save("HWIP", "192.168.1.200");)
3、在初始化脚本中添加函数
public IArchitecture GetArchitecture()
{
return TestInit.Interface;
}
4、在初始化脚本的Start()函数中,先发送设备类型
this.SendEvent(new DeviceManagerEvent() { deviceType = _deviceType });
4.1.1 获取IDeviceManager
deviceManager = this.GetUtility<IDeviceManager>();
4.1.2 根据传感器类型初始化
deviceManager.Init(GyroSensorType.Wired);
4.2 若为主动控制骑马机(_deviceType == DeviceType.HorseControl)
4.2.1 获取IHorseControlManager
horseControlManager = this.GetUtility<IHorseControlManager>();
4.2.2 根据骑马机IP初始化
horseControlManager.Init(HorseIP);
5、获取速度值
deviceManager.GetSpeed()
6、主动控制骑马机
/// <summary>
/// 获取当前速度挡位
/// </summary>
/// <returns></returns>
float GetSpeed();
/// <summary>
/// 加速
/// </summary>
void AddSpeed();
/// <summary>
/// 减速
/// </summary>
void SubSpeed();
/// <summary>
/// 停止
/// </summary>
void Stop();
无线版(witmotion)
解决方法:PlayerSettings->OtherSetting->Configuration->Api Compatibility Level,不要选择.NET Standard 2.1