diff --git a/Assets/ESP8266Program.meta b/Assets/ESP8266Program.meta new file mode 100644 index 0000000..3873bda --- /dev/null +++ b/Assets/ESP8266Program.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 23c43abb7ffce3a49851d3bd8d426170 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/NodeMCU_PrintQuaternion_6050.lua b/Assets/ESP8266Program/NodeMCU_PrintQuaternion_6050.lua new file mode 100644 index 0000000..a7eed62 --- /dev/null +++ b/Assets/ESP8266Program/NodeMCU_PrintQuaternion_6050.lua @@ -0,0 +1,182 @@ +--------------------------------------------------------- +---MPU6050&NodeMCU&ESP8266&姿态融合算法整合脚本--- +---读取MPU6050原始数据(三轴加速度,三轴角速度,环境温度) +---融合四元数算法,该程序的输出值为六轴数据融合后的四元数 +---四元数转欧拉角需要在其他外接程序上进行实现 +--------------------------------------------------------- +id = 0 -- always 0 +scl = 6 -- set pin 6 as scl +sda = 7 -- set pin 7 as sda +MPU6050SlaveAddress = 0x68 +AK8963SlaveAddress = 0x0C + +AccelScaleFactor = 16384; -- sensitivity scale factor respective to full scale setting provided in datasheet +GyroScaleFactor = 131; + +MPU6050_REGISTER_SMPLRT_DIV = 0x19 +MPU6050_REGISTER_USER_CTRL = 0x6A +MPU6050_REGISTER_PWR_MGMT_1 = 0x6B +MPU6050_REGISTER_PWR_MGMT_2 = 0x6C +MPU6050_REGISTER_CONFIG = 0x1A +MPU6050_REGISTER_GYRO_CONFIG = 0x1B +MPU6050_REGISTER_ACCEL_CONFIG = 0x1C +AK_8963_CONFIG = 0x18 +MPU6050_REGISTER_FIFO_EN = 0x23 +MPU6050_REGISTER_INT_ENABLE = 0x38 +MPU6050_REGISTER_ACCEL_XOUT_H = 0x3B +MPU6050_REGISTER_SIGNAL_PATH_RESET = 0x68 + +function I2C_Write(deviceAddress, regAddress, data) + i2c.start(id) -- send start condition + if (i2c.address(id, deviceAddress, i2c.TRANSMITTER))-- set slave address and transmit direction + then + i2c.write(id, regAddress) -- write address to slave + i2c.write(id, data) -- write data to slave + i2c.stop(id) -- send stop condition + else + print("I2C_Write fails") + end +end + +function I2C_Read(deviceAddress, regAddress, SizeOfDataToRead) + response = 0; + i2c.start(id) -- send start condition + if (i2c.address(id, deviceAddress, i2c.TRANSMITTER))-- set slave address and transmit direction + then + i2c.write(id, regAddress) -- write address to slave + i2c.stop(id) -- send stop condition + i2c.start(id) -- send start condition + i2c.address(id, deviceAddress, i2c.RECEIVER)-- set slave address and receive direction + response = i2c.read(id, SizeOfDataToRead) -- read defined length response from slave + i2c.stop(id) -- send stop condition + return response + else + print("I2C_Read fails") + end + return response +end + +function unsignTosigned16bit(num) -- convert unsigned 16-bit no. to signed 16-bit no. + if num > 32768 then + num = num - 65536 + end + return num +end + +function MPU6050_Init() --configure MPU6050 + tmr.delay(150000) + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SMPLRT_DIV, 0x07) + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_1, 0x01) + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_PWR_MGMT_2, 0x00) + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_CONFIG, 0x00) + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_GYRO_CONFIG, 0x00)-- set +/-250 degree/second full scale + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_CONFIG, 0x00)-- set +/- 2g full scale + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_FIFO_EN, 0x00) + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_INT_ENABLE, 0x01) + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_SIGNAL_PATH_RESET, 0x00) + I2C_Write(MPU6050SlaveAddress, MPU6050_REGISTER_USER_CTRL, 0x00) +end + +i2c.setup(id, sda, scl, i2c.SLOW) -- initialize i2c +MPU6050_Init() +data = I2C_Read(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H, 14) +AccelX = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 1), 8), string.byte(data, 2)))) +AccelY = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 3), 8), string.byte(data, 4)))) +AccelZ = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 5), 8), string.byte(data, 6)))) +Temperature = unsignTosigned16bit(bit.bor(bit.lshift(string.byte(data,7), 8), string.byte(data,8))) +GyroX = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 9), 8), string.byte(data, 10)))) +GyroY = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 11), 8), string.byte(data, 12)))) +GyroZ = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 13), 8), string.byte(data, 14)))) +AccelX = AccelX/AccelScaleFactor -- divide each with their sensitivity scale factor +AccelY = AccelY/AccelScaleFactor +AccelZ = AccelZ/AccelScaleFactor +Temperature = Temperature/340+36.53-- temperature formula +--角速度的值会产生偏移,需要校准 +GyroX = GyroX/GyroScaleFactor+3 +GyroY = GyroY/GyroScaleFactor-0.45 +GyroZ = GyroZ/GyroScaleFactor+0.24 + +--姿态融合算法部分定义 +Kp = 100.0 +Ki = 0.002 +halfT = 0.001 +q0 = 1 +q1 = 0 +q2 = 0 +q3 = 0 +exInt = 0 +eyInt = 0 +ezInt = 0 +roll = 0.0 +pitch = 0.0 +yaw = 0.0 + + +function updateHardWareDatas() + data = I2C_Read(MPU6050SlaveAddress, MPU6050_REGISTER_ACCEL_XOUT_H, 14) + AccelX = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 1), 8), string.byte(data, 2)))) + AccelY = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 3), 8), string.byte(data, 4)))) + AccelZ = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 5), 8), string.byte(data, 6)))) + Temperature = unsignTosigned16bit(bit.bor(bit.lshift(string.byte(data,7), 8), string.byte(data,8))) + GyroX = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 9), 8), string.byte(data, 10)))) + GyroY = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 11), 8), string.byte(data, 12)))) + GyroZ = unsignTosigned16bit((bit.bor(bit.lshift(string.byte(data, 13), 8), string.byte(data, 14)))) + AccelX = AccelX/AccelScaleFactor -- divide each with their sensitivity scale factor + AccelY = AccelY/AccelScaleFactor + AccelZ = AccelZ/AccelScaleFactor + Temperature = Temperature/340+36.53-- temperature formula + GyroX = GyroX/GyroScaleFactor+3 + GyroY = GyroY/GyroScaleFactor-0.45 + GyroZ = GyroZ/GyroScaleFactor+0.24 +end + +function IMUupdate(gx,gy,gz,ax,ay,az) + -- body + -- 测量正常化 + norm = math.sqrt(ax*ax + ay*ay + az*az) + ax = ax / norm --单位化 + ay = ay / norm + az = az / norm + -- 估计方向的重力 + vx = 2*(q1*q3 - q0*q2) + vy = 2*(q0*q1 + q2*q3) + vz = q0*q0 - q1*q1 - q2*q2 + q3*q3 + -- 错误的领域和方向传感器测量参考方向之间的交叉乘积的总和 + ex = (ay*vz - az*vy) + ey = (az*vx - ax*vz) + ez = (ax*vy - ay*vx) + -- 积分误差比例积分增益 + exInt = exInt + ex*Ki + eyInt = eyInt + ey*Ki + ezInt = ezInt + ez*Ki + -- 调整后的陀螺仪测量 + gx = gx + Kp*ex + exInt + gy = gy + Kp*ey + eyInt + gz = gz + Kp*ez + ezInt + -- 整合四元数率和正常化 + q0 = q0 + (-q1*gx - q2*gy - q3*gz)*halfT + q1 = q1 + (q0*gx + q2*gz - q3*gy)*halfT + q2 = q2 + (q0*gy - q1*gz + q3*gx)*halfT + q3 = q3 + (q0*gz + q1*gy - q2*gx)*halfT + -- 正常化四元 + norm = math.sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3) + q0 = q0 / norm + q1 = q1 / norm + q2 = q2 / norm + q3 = q3 / norm + --pitch = math.asin(-2 * q1 * q3 + 2 * q0* q2) * 57.3 -- pitch ,转换为度数 + --roll = math.atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2* q2 + 1) * 57.3 -- rollv + --yaw = math.atan2(2*(q1*q2 + q0*q3),q0*q0+q1*q1-q2*q2-q3*q3) * 57.3 +end + + +while true do --read and print accelero, gyro and temperature value + updateHardWareDatas() + IMUupdate(GyroX,GyroY,GyroZ,AccelX,AccelY,AccelZ) + print(string.format("{'q0':%.3g,'q1':%.3g,'q2':%.3g,'q3':%.3g}",q0,q1,q2,q3)) + --输出原始数据 + --print(string.format("%.3g,%.3g,%.3g",GyroX,GyroY,GyroZ)) + --print(string.format("{'GyroX':%.3g,'GyroY':%.3g,'GyroZ':%.3g,'Temperature':%.3g,'AccelX':%.3g,'AccelY':%.3g,'AccelZ':%.3g}", + --GyroX, GyroY, GyroZ, Temperature, AccelX, AccelY, AccelZ)) + tmr.delay(100000) -- 100ms timer delay +end diff --git a/Assets/ESP8266Program/NodeMCU_PrintQuaternion_6050.lua.meta b/Assets/ESP8266Program/NodeMCU_PrintQuaternion_6050.lua.meta new file mode 100644 index 0000000..c88a2ea --- /dev/null +++ b/Assets/ESP8266Program/NodeMCU_PrintQuaternion_6050.lua.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 28a2a4a7fe17b9a47acc8267666b18fe +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/instruction.txt b/Assets/ESP8266Program/instruction.txt new file mode 100644 index 0000000..18df30d --- /dev/null +++ b/Assets/ESP8266Program/instruction.txt @@ -0,0 +1,5 @@ +该目录下存放ESP8266烧录用的相关程序 + +NodeMCU为lua格式的串口输出程序(仅原始数据和四元数) + +MicroPython为py格式的串口输出程序(原始数据、四元数和欧拉角) \ No newline at end of file diff --git a/Assets/ESP8266Program/instruction.txt.meta b/Assets/ESP8266Program/instruction.txt.meta new file mode 100644 index 0000000..384d175 --- /dev/null +++ b/Assets/ESP8266Program/instruction.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5e0a4b5e826b6694f8f0b567ef165250 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250.meta b/Assets/ESP8266Program/microPython_9250.meta new file mode 100644 index 0000000..6709613 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7cf5aae60260a064884fdf3bdba01c76 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250/CHANGELOG.md b/Assets/ESP8266Program/microPython_9250/CHANGELOG.md new file mode 100644 index 0000000..def5361 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/CHANGELOG.md @@ -0,0 +1,41 @@ +# Changelog + +All notable changes to this project will be documented in this file, in reverse chronological order by release. + +## [0.3.0](https://github.com/tuupola/micropython-mpu9250/compare/0.2.1...0.3.0) - 2020-03-22 +### Added + +- Support for internal temperature sensor ([#1](https://github.com/tuupola/micropython-mpu9250/issues/1), [#9](https://github.com/tuupola/micropython-mpu9250/pull/9), [#18](https://github.com/tuupola/micropython-mpu9250/pull/18)) +- Support for gyro calibration ([#5](https://github.com/tuupola/micropython-mpu9250/issues/5), [#10](https://github.com/tuupola/micropython-mpu9250/pull/10)) + +### Fixed +- Support for standalone MPU6500 sensors ([#15](https://github.com/tuupola/micropython-mpu9250/issues/15), [#16](https://github.com/tuupola/micropython-mpu9250/pull/16)) + +### Changed + +- Move I2C bypass initialisation from MPU6500 to MPU9250 ([#17](https://github.com/tuupola/micropython-mpu9250/issues/17)) + +## [0.2.1](https://github.com/tuupola/micropython-mpu9250/compare/0.2.0...0.2.1) - 2019-02-07 +### Fixed +- Gyro degrees to radians conversion ([#8](https://github.com/tuupola/micropython-mpu9250/pull/8)). + +## [0.2.0](https://github.com/tuupola/micropython-mpu9250/compare/0.1.0...0.2.0)- 2018-04-08 +### Added +- Support for magnetometer factory sensitivity adjustement values `ASAX`, `ASAY` and `ASAZ`. +- Support for setting magnetometer offset and scale calibration values. + ``` + ak8963 = AK8963( + i2c, + offset=(-136.8931640625, -160.482421875, 59.02880859375), + scale=(1.18437220840483, 0.923895823933424, 0.931707933618979) + ) + ``` +- Method for retrieving the magnetometer offset and scale calibration values. + ``` + ak8963 = AK8963(i2c) + offset, scale = ak8963.calibrate(count=256, delay=200) + ``` + +## 0.1.0 - 2018-02-17 + +Initial working release. \ No newline at end of file diff --git a/Assets/ESP8266Program/microPython_9250/CHANGELOG.md.meta b/Assets/ESP8266Program/microPython_9250/CHANGELOG.md.meta new file mode 100644 index 0000000..61bdb93 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/CHANGELOG.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: dc3b63a3470513a48aed558db38e8d11 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250/LICENSE.txt b/Assets/ESP8266Program/microPython_9250/LICENSE.txt new file mode 100644 index 0000000..b19f51b --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018-2020 Mika Tuupola + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Assets/ESP8266Program/microPython_9250/LICENSE.txt.meta b/Assets/ESP8266Program/microPython_9250/LICENSE.txt.meta new file mode 100644 index 0000000..de09835 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/LICENSE.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 222d46ef59dd2ce4e86e1a35c9fdf484 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250/Makefile b/Assets/ESP8266Program/microPython_9250/Makefile new file mode 100644 index 0000000..3a719b4 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/Makefile @@ -0,0 +1,31 @@ +.DEFAULT_GOAL := help + +help: + @echo "" + @echo "Available tasks:" + @echo " watch Upload changed library files to board automagically" + @echo " sync Upload library files to board" + @echo " reset Soft reboot the board" + @echo " repl Start a repl session" + @echo " deps Install dependencies with upip" + @echo "" + +watch: + find . -name "*.py" | entr -c sh -c 'make sync && make reset' + +sync: + ampy --port /dev/tty.SLAB_USBtoUART put mpu6500.py + ampy --port /dev/tty.SLAB_USBtoUART put mpu9250.py + ampy --port /dev/tty.SLAB_USBtoUART put ak8963.py + +repl: + screen /dev/tty.SLAB_USBtoUART 115200 + +reset: + ampy --port /dev/cu.SLAB_USBtoUART reset + +dist: + python3 setup.py sdist + # twine upload dist/filename.tar.gz + +.PHONY: help watch shell repl reset sync dist diff --git a/Assets/ESP8266Program/microPython_9250/Makefile.meta b/Assets/ESP8266Program/microPython_9250/Makefile.meta new file mode 100644 index 0000000..f10a5df --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/Makefile.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 61ade8775a795d944b524ace6c9d8266 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250/QueryFunction b/Assets/ESP8266Program/microPython_9250/QueryFunction new file mode 100644 index 0000000..528154a --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/QueryFunction @@ -0,0 +1,61 @@ +#define Kp 100.0f // 比例增益支配率收敛到加速度计/磁强计 +#define Ki 0.002f // 积分增益支配率的陀螺仪偏见的衔接 +#define halfT 0.001f // 采样周期的一半 + +float q0 = 1, q1 = 0, q2 = 0, q3 = 0; // 四元数的元素,代表估计方向 +float exInt = 0, eyInt = 0, ezInt = 0; // 按比例缩小积分误差 + +float Yaw,Pitch,Roll; //偏航角,俯仰角,翻滚角 + +void IMUupdate(float gx, float gy, float gz, float ax, float ay, float az) +{ + float norm; + float vx, vy, vz; + float ex, ey, ez; + + // 测量正常化 + norm = sqrt(ax*ax + ay*ay + az*az); + ax = ax / norm; //单位化 + ay = ay / norm; + az = az / norm; + + // 估计方向的重力 + vx = 2*(q1*q3 - q0*q2); + vy = 2*(q0*q1 + q2*q3); + vz = q0*q0 - q1*q1 - q2*q2 + q3*q3; + + // 错误的领域和方向传感器测量参考方向之间的交叉乘积的总和 + ex = (ay*vz - az*vy); + ey = (az*vx - ax*vz); + ez = (ax*vy - ay*vx); + + // 积分误差比例积分增益 + exInt = exInt + ex*Ki; + eyInt = eyInt + ey*Ki; + ezInt = ezInt + ez*Ki; + + // 调整后的陀螺仪测量 + gx = gx + Kp*ex + exInt; + gy = gy + Kp*ey + eyInt; + gz = gz + Kp*ez + ezInt; + + // 整合四元数率和正常化 + q0 = q0 + (-q1*gx - q2*gy - q3*gz)*halfT; + q1 = q1 + (q0*gx + q2*gz - q3*gy)*halfT; + q2 = q2 + (q0*gy - q1*gz + q3*gx)*halfT; + q3 = q3 + (q0*gz + q1*gy - q2*gx)*halfT; + + // 正常化四元 + norm = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3); + q0 = q0 / norm; + q1 = q1 / norm; + q2 = q2 / norm; + q3 = q3 / norm; + + Pitch = asin(-2 * q1 * q3 + 2 * q0* q2)* 57.3; // pitch ,转换为度数 + Roll = atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2* q2 + 1)* 57.3; // rollv + //Yaw = atan2(2*(q1*q2 + q0*q3),q0*q0+q1*q1-q2*q2-q3*q3) * 57.3; //此处没有价值,注掉 +} +———————————————— +版权声明:本文为CSDN博主「Fred_1986」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 +原文链接:https://blog.csdn.net/fred_1986/article/details/108522529 \ No newline at end of file diff --git a/Assets/ESP8266Program/microPython_9250/QueryFunction.c b/Assets/ESP8266Program/microPython_9250/QueryFunction.c new file mode 100644 index 0000000..8a52f13 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/QueryFunction.c @@ -0,0 +1,58 @@ +#define Kp 100.0f // 比例增益支配率收敛到加速度计/磁强计 +#define Ki 0.002f // 积分增益支配率的陀螺仪偏见的衔接 +#define halfT 0.001f // 采样周期的一半 + +float q0 = 1, q1 = 0, q2 = 0, q3 = 0; // 四元数的元素,代表估计方向 +float exInt = 0, eyInt = 0, ezInt = 0; // 按比例缩小积分误差 + +float Yaw,Pitch,Roll; //偏航角,俯仰角,翻滚角 + +void IMUupdate(float gx, float gy, float gz, float ax, float ay, float az) +{ + float norm; + float vx, vy, vz; + float ex, ey, ez; + + // 测量正常化 + norm = sqrt(ax*ax + ay*ay + az*az); + ax = ax / norm; //单位化 + ay = ay / norm; + az = az / norm; + + // 估计方向的重力 + vx = 2*(q1*q3 - q0*q2); + vy = 2*(q0*q1 + q2*q3); + vz = q0*q0 - q1*q1 - q2*q2 + q3*q3; + + // 错误的领域和方向传感器测量参考方向之间的交叉乘积的总和 + ex = (ay*vz - az*vy); + ey = (az*vx - ax*vz); + ez = (ax*vy - ay*vx); + + // 积分误差比例积分增益 + exInt = exInt + ex*Ki; + eyInt = eyInt + ey*Ki; + ezInt = ezInt + ez*Ki; + + // 调整后的陀螺仪测量 + gx = gx + Kp*ex + exInt; + gy = gy + Kp*ey + eyInt; + gz = gz + Kp*ez + ezInt; + + // 整合四元数率和正常化 + q0 = q0 + (-q1*gx - q2*gy - q3*gz)*halfT; + q1 = q1 + (q0*gx + q2*gz - q3*gy)*halfT; + q2 = q2 + (q0*gy - q1*gz + q3*gx)*halfT; + q3 = q3 + (q0*gz + q1*gy - q2*gx)*halfT; + + // 正常化四元 + norm = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3); + q0 = q0 / norm; + q1 = q1 / norm; + q2 = q2 / norm; + q3 = q3 / norm; + + Pitch = asin(-2 * q1 * q3 + 2 * q0* q2)* 57.3; // pitch ,转换为度数 + Roll = atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2* q2 + 1)* 57.3; // rollv + //Yaw = atan2(2*(q1*q2 + q0*q3),q0*q0+q1*q1-q2*q2-q3*q3) * 57.3; //此处没有价值,注掉 +} \ No newline at end of file diff --git a/Assets/ESP8266Program/microPython_9250/QueryFunction.c.meta b/Assets/ESP8266Program/microPython_9250/QueryFunction.c.meta new file mode 100644 index 0000000..63c2a1a --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/QueryFunction.c.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: 9d32cc185bcc035468484db493275736 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250/QueryFunction.meta b/Assets/ESP8266Program/microPython_9250/QueryFunction.meta new file mode 100644 index 0000000..2779661 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/QueryFunction.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2f84164ba96a10e46a2f81831df04c90 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250/README.md b/Assets/ESP8266Program/microPython_9250/README.md new file mode 100644 index 0000000..2bd6d4f --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/README.md @@ -0,0 +1,122 @@ +# MicroPython MPU-9250 (MPU-6500 + AK8963) I2C driver + +MPU-9250 is a System in Package (SiP) which combines two chips: MPU-6500 which contains 3-axis gyroscope and 3-axis accelerometer and an AK8963 which is a 3-axis digital compass. + +## Usage + +Simple test with never ending loop. + +```python +import utime +from machine import I2C, Pin +from mpu9250 import MPU9250 + +i2c = I2C(scl=Pin(22), sda=Pin(21)) +sensor = MPU9250(i2c) + +print("MPU9250 id: " + hex(sensor.whoami)) + +while True: + print(sensor.acceleration) + print(sensor.gyro) + print(sensor.magnetic) + print(sensor.temperature) + + utime.sleep_ms(1000) +``` + +By default the library returns 3-tuple of X, Y, Z axis values for either acceleration, gyroscope and magnetometer ie compass. Default units are `m/s^2`, `rad/s`, `uT` and `°C`. It is possible to also get acceleration values in `g` and gyro values `deg/s`. See the example below. Note that both the MPU6500 and the AK8963 drivers are available as separate classes. MPU9250 is actually a composite of those two. + +```python +import utime +from machine import I2C, Pin +from mpu9250 import MPU9250 +from mpu6500 import MPU6500, SF_G, SF_DEG_S + +i2c = I2C(scl=Pin(22), sda=Pin(21)) +mpu6500 = MPU6500(i2c, accel_sf=SF_G, gyro_sf=SF_DEG_S) +sensor = MPU9250(i2c, mpu6500=mpu6500) + +print("MPU9250 id: " + hex(sensor.whoami)) + +while True: + print(sensor.acceleration) + print(sensor.gyro) + print(sensor.magnetic) + print(sensor.temperature) + + utime.sleep_ms(1000) +``` + +More realistic example usage with timer. If you get `OSError: 26` or `i2c driver install error` after soft reboot do a hard reboot. + +```python +import micropython +from machine import I2C, Pin, Timer +from mpu9250 import MPU9250 + +micropython.alloc_emergency_exception_buf(100) + +i2c = I2C(scl=Pin(22), sda=Pin(21)) +sensor = MPU9250(i2c) + +def read_sensor(timer): + print(sensor.acceleration) + print(sensor.gyro) + print(sensor.magnetic) + print(sensor.temperature) + +print("MPU9250 id: " + hex(sensor.whoami)) + +timer_0 = Timer(0) +timer_0.init(period=1000, mode=Timer.PERIODIC, callback=read_sensor) +``` + +## Magnetometer Calibration + +For real life applications you should almost always [calibrate the magnetometer](https://appelsiini.net/2018/calibrate-magnetometer/). The AK8963 driver supports both hard and soft iron correction. Calibration function takes two parameters: `count` is the number of samples to collect and `delay` is the delay in millisecods between the samples. + +With the default values of `256` and `200` calibration takes aproximately one minute. While calibration function is running the sensor should be rotated multiple times around each axis. + +NOTE! If using MPU9250 you will first need to open the I2C bypass access to AK8963. This is not needed when using a standalone AK8963 sensor. + +```python +from machine import I2C, Pin +from mpu9250 import MPU9250 +from ak8963 import AK8963 + +i2c = I2C(scl=Pin(22), sda=Pin(21)) + +dummy = MPU9250(i2c) # this opens the bybass to access to the AK8963 +ak8963 = AK8963(i2c) +offset, scale = ak8963.calibrate(count=256, delay=200) + +sensor = MPU9250(i2c, ak8963=ak8963) +``` + +After finishing calibration the `calibrate()` method also returns tuples for both hard iron `offset` and soft iron `scale`. To avoid calibrating after each startup it would make sense to strore these values in NVRAM or config file and pass them to the AK8963 constructor. Below example only illustrates how to use the constructor. + +```python +from machine import I2C, Pin +from mpu9250 import MPU9250 +from ak8963 import AK8963 + +i2c = I2C(scl=Pin(22), sda=Pin(21)) +dummy = MPU9250(i2c) # this opens the bybass to access to the AK8963 + +ak8963 = AK8963( + i2c, + offset=(-136.8931640625, -160.482421875, 59.02880859375), + scale=(1.18437220840483, 0.923895823933424, 0.931707933618979) +) + +sensor = MPU9250(i2c, ak8963=ak8963) +``` + +## Gyro Calibration + +TODO + +## License + +The MIT License (MIT). Please see [License File](LICENSE.txt) for more information. \ No newline at end of file diff --git a/Assets/ESP8266Program/microPython_9250/README.md.meta b/Assets/ESP8266Program/microPython_9250/README.md.meta new file mode 100644 index 0000000..3c6fdd5 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 58ac5f7fe29992445bb6e3a83141290e +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250/ak8963.py b/Assets/ESP8266Program/microPython_9250/ak8963.py new file mode 100644 index 0000000..1eb3c2e --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/ak8963.py @@ -0,0 +1,207 @@ +# Copyright (c) 2018-2020 Mika Tuupola +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copied of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# https://github.com/tuupola/micropython-mpu9250 +# https://www.akm.com/akm/en/file/datasheet/AK8963C.pdf + +""" +MicroPython I2C driver for AK8963 magnetometer +""" + +__version__ = "0.3.0" + +# pylint: disable=import-error +import ustruct +import utime +from machine import I2C, Pin +from micropython import const +# pylint: enable=import-error + +_WIA = const(0x00) +_HXL = const(0x03) +_HXH = const(0x04) +_HYL = const(0x05) +_HYH = const(0x06) +_HZL = const(0x07) +_HZH = const(0x08) +_ST2 = const(0x09) +_CNTL1 = const(0x0a) +_ASAX = const(0x10) +_ASAY = const(0x11) +_ASAZ = const(0x12) + +_MODE_POWER_DOWN = 0b00000000 +MODE_SINGLE_MEASURE = 0b00000001 +MODE_CONTINOUS_MEASURE_1 = 0b00000010 # 8Hz +MODE_CONTINOUS_MEASURE_2 = 0b00000110 # 100Hz +MODE_EXTERNAL_TRIGGER_MEASURE = 0b00000100 +_MODE_SELF_TEST = 0b00001000 +_MODE_FUSE_ROM_ACCESS = 0b00001111 + +OUTPUT_14_BIT = 0b00000000 +OUTPUT_16_BIT = 0b00010000 + +_SO_14BIT = 0.6 # μT per digit when 14bit mode +_SO_16BIT = 0.15 # μT per digit when 16bit mode + +class AK8963: + """Class which provides interface to AK8963 magnetometer.""" + def __init__( + self, i2c, address=0x0c, + mode=MODE_CONTINOUS_MEASURE_1, output=OUTPUT_16_BIT, + offset=(0, 0, 0), scale=(1, 1, 1) + ): + self.i2c = i2c + self.address = address + self._offset = offset + self._scale = scale + + if 0x48 != self.whoami: + raise RuntimeError("AK8963 not found in I2C bus.") + + # Sensitivity adjustement values + self._register_char(_CNTL1, _MODE_FUSE_ROM_ACCESS) + asax = self._register_char(_ASAX) + asay = self._register_char(_ASAY) + asaz = self._register_char(_ASAZ) + self._register_char(_CNTL1, _MODE_POWER_DOWN) + + # Should wait atleast 100us before next mode + self._adjustement = ( + (0.5 * (asax - 128)) / 128 + 1, + (0.5 * (asay - 128)) / 128 + 1, + (0.5 * (asaz - 128)) / 128 + 1 + ) + + # Power on + self._register_char(_CNTL1, (mode | output)) + + if output is OUTPUT_16_BIT: + self._so = _SO_16BIT + else: + self._so = _SO_14BIT + + @property + def magnetic(self): + """ + X, Y, Z axis micro-Tesla (uT) as floats. + """ + xyz = list(self._register_three_shorts(_HXL)) + self._register_char(_ST2) # Enable updating readings again + + # Apply factory axial sensitivy adjustements + xyz[0] *= self._adjustement[0] + xyz[1] *= self._adjustement[1] + xyz[2] *= self._adjustement[2] + + # Apply output scale determined in constructor + so = self._so + xyz[0] *= so + xyz[1] *= so + xyz[2] *= so + + # Apply hard iron ie. offset bias from calibration + xyz[0] -= self._offset[0] + xyz[1] -= self._offset[1] + xyz[2] -= self._offset[2] + + # Apply soft iron ie. scale bias from calibration + xyz[0] *= self._scale[0] + xyz[1] *= self._scale[1] + xyz[2] *= self._scale[2] + + return tuple(xyz) + + @property + def adjustement(self): + return self._adjustement + + @property + def whoami(self): + """ Value of the whoami register. """ + return self._register_char(_WIA) + + def calibrate(self, count=256, delay=200): + self._offset = (0, 0, 0) + self._scale = (1, 1, 1) + + reading = self.magnetic + minx = maxx = reading[0] + miny = maxy = reading[1] + minz = maxz = reading[2] + + while count: + utime.sleep_ms(delay) + reading = self.magnetic + minx = min(minx, reading[0]) + maxx = max(maxx, reading[0]) + miny = min(miny, reading[1]) + maxy = max(maxy, reading[1]) + minz = min(minz, reading[2]) + maxz = max(maxz, reading[2]) + count -= 1 + + # Hard iron correction + offset_x = (maxx + minx) / 2 + offset_y = (maxy + miny) / 2 + offset_z = (maxz + minz) / 2 + + self._offset = (offset_x, offset_y, offset_z) + + # Soft iron correction + avg_delta_x = (maxx - minx) / 2 + avg_delta_y = (maxy - miny) / 2 + avg_delta_z = (maxz - minz) / 2 + + avg_delta = (avg_delta_x + avg_delta_y + avg_delta_z) / 3 + + scale_x = avg_delta / avg_delta_x + scale_y = avg_delta / avg_delta_y + scale_z = avg_delta / avg_delta_z + + self._scale = (scale_x, scale_y, scale_z) + + return self._offset, self._scale + + def _register_short(self, register, value=None, buf=bytearray(2)): + if value is None: + self.i2c.readfrom_mem_into(self.address, register, buf) + return ustruct.unpack(" + +//------------------------------------------------------------------------------------------- +// Definitions + +#define DEFAULT_SAMPLE_FREQ 512.0f // sample frequency in Hz +#define twoKpDef (2.0f * 0.5f) // 2 * proportional gain +#define twoKiDef (2.0f * 0.0f) // 2 * integral gain + + +//============================================================================================ +// Functions + +//------------------------------------------------------------------------------------------- +// AHRS algorithm update + +Mahony::Mahony() +{ + twoKp = twoKpDef; // 2 * proportional gain (Kp) + twoKi = twoKiDef; // 2 * integral gain (Ki) + q0 = 1.0f; + q1 = 0.0f; + q2 = 0.0f; + q3 = 0.0f; + integralFBx = 0.0f; + integralFBy = 0.0f; + integralFBz = 0.0f; + anglesComputed = 0; + invSampleFreq = 1.0f / DEFAULT_SAMPLE_FREQ; +} + +void Mahony::update(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz) +{ + float recipNorm; + float q0q0, q0q1, q0q2, q0q3, q1q1, q1q2, q1q3, q2q2, q2q3, q3q3; + float hx, hy, bx, bz; + float halfvx, halfvy, halfvz, halfwx, halfwy, halfwz; + float halfex, halfey, halfez; + float qa, qb, qc; + + // Use IMU algorithm if magnetometer measurement invalid + // (avoids NaN in magnetometer normalisation) + if((mx == 0.0f) && (my == 0.0f) && (mz == 0.0f)) { + updateIMU(gx, gy, gz, ax, ay, az); + return; + } + + // Convert gyroscope degrees/sec to radians/sec + gx *= 0.0174533f; + gy *= 0.0174533f; + gz *= 0.0174533f; + + // Compute feedback only if accelerometer measurement valid + // (avoids NaN in accelerometer normalisation) + if(!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) { + + // Normalise accelerometer measurement + recipNorm = invSqrt(ax * ax + ay * ay + az * az); + ax *= recipNorm; + ay *= recipNorm; + az *= recipNorm; + + // Normalise magnetometer measurement + recipNorm = invSqrt(mx * mx + my * my + mz * mz); + mx *= recipNorm; + my *= recipNorm; + mz *= recipNorm; + + // Auxiliary variables to avoid repeated arithmetic + q0q0 = q0 * q0; + q0q1 = q0 * q1; + q0q2 = q0 * q2; + q0q3 = q0 * q3; + q1q1 = q1 * q1; + q1q2 = q1 * q2; + q1q3 = q1 * q3; + q2q2 = q2 * q2; + q2q3 = q2 * q3; + q3q3 = q3 * q3; + + // Reference direction of Earth's magnetic field + hx = 2.0f * (mx * (0.5f - q2q2 - q3q3) + my * (q1q2 - q0q3) + mz * (q1q3 + q0q2)); + hy = 2.0f * (mx * (q1q2 + q0q3) + my * (0.5f - q1q1 - q3q3) + mz * (q2q3 - q0q1)); + bx = sqrtf(hx * hx + hy * hy); + bz = 2.0f * (mx * (q1q3 - q0q2) + my * (q2q3 + q0q1) + mz * (0.5f - q1q1 - q2q2)); + + // Estimated direction of gravity and magnetic field + halfvx = q1q3 - q0q2; + halfvy = q0q1 + q2q3; + halfvz = q0q0 - 0.5f + q3q3; + halfwx = bx * (0.5f - q2q2 - q3q3) + bz * (q1q3 - q0q2); + halfwy = bx * (q1q2 - q0q3) + bz * (q0q1 + q2q3); + halfwz = bx * (q0q2 + q1q3) + bz * (0.5f - q1q1 - q2q2); + + // Error is sum of cross product between estimated direction + // and measured direction of field vectors + halfex = (ay * halfvz - az * halfvy) + (my * halfwz - mz * halfwy); + halfey = (az * halfvx - ax * halfvz) + (mz * halfwx - mx * halfwz); + halfez = (ax * halfvy - ay * halfvx) + (mx * halfwy - my * halfwx); + + // Compute and apply integral feedback if enabled + if(twoKi > 0.0f) { + // integral error scaled by Ki + integralFBx += twoKi * halfex * invSampleFreq; + integralFBy += twoKi * halfey * invSampleFreq; + integralFBz += twoKi * halfez * invSampleFreq; + gx += integralFBx; // apply integral feedback + gy += integralFBy; + gz += integralFBz; + } else { + integralFBx = 0.0f; // prevent integral windup + integralFBy = 0.0f; + integralFBz = 0.0f; + } + + // Apply proportional feedback + gx += twoKp * halfex; + gy += twoKp * halfey; + gz += twoKp * halfez; + } + + // Integrate rate of change of quaternion + gx *= (0.5f * invSampleFreq); // pre-multiply common factors + gy *= (0.5f * invSampleFreq); + gz *= (0.5f * invSampleFreq); + qa = q0; + qb = q1; + qc = q2; + q0 += (-qb * gx - qc * gy - q3 * gz); + q1 += (qa * gx + qc * gz - q3 * gy); + q2 += (qa * gy - qb * gz + q3 * gx); + q3 += (qa * gz + qb * gy - qc * gx); + + // Normalise quaternion + recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); + q0 *= recipNorm; + q1 *= recipNorm; + q2 *= recipNorm; + q3 *= recipNorm; + anglesComputed = 0; +} + +//------------------------------------------------------------------------------------------- +// IMU algorithm update + +void Mahony::updateIMU(float gx, float gy, float gz, float ax, float ay, float az) +{ + float recipNorm; + float halfvx, halfvy, halfvz; + float halfex, halfey, halfez; + float qa, qb, qc; + + // Convert gyroscope degrees/sec to radians/sec + gx *= 0.0174533f; + gy *= 0.0174533f; + gz *= 0.0174533f; + + // Compute feedback only if accelerometer measurement valid + // (avoids NaN in accelerometer normalisation) + if(!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) { + + // Normalise accelerometer measurement + recipNorm = invSqrt(ax * ax + ay * ay + az * az); + ax *= recipNorm; + ay *= recipNorm; + az *= recipNorm; + + // Estimated direction of gravity + halfvx = q1 * q3 - q0 * q2; + halfvy = q0 * q1 + q2 * q3; + halfvz = q0 * q0 - 0.5f + q3 * q3; + + // Error is sum of cross product between estimated + // and measured direction of gravity + halfex = (ay * halfvz - az * halfvy); + halfey = (az * halfvx - ax * halfvz); + halfez = (ax * halfvy - ay * halfvx); + + // Compute and apply integral feedback if enabled + if(twoKi > 0.0f) { + // integral error scaled by Ki + integralFBx += twoKi * halfex * invSampleFreq; + integralFBy += twoKi * halfey * invSampleFreq; + integralFBz += twoKi * halfez * invSampleFreq; + gx += integralFBx; // apply integral feedback + gy += integralFBy; + gz += integralFBz; + } else { + integralFBx = 0.0f; // prevent integral windup + integralFBy = 0.0f; + integralFBz = 0.0f; + } + + // Apply proportional feedback + gx += twoKp * halfex; + gy += twoKp * halfey; + gz += twoKp * halfez; + } + + // Integrate rate of change of quaternion + gx *= (0.5f * invSampleFreq); // pre-multiply common factors + gy *= (0.5f * invSampleFreq); + gz *= (0.5f * invSampleFreq); + qa = q0; + qb = q1; + qc = q2; + q0 += (-qb * gx - qc * gy - q3 * gz); + q1 += (qa * gx + qc * gz - q3 * gy); + q2 += (qa * gy - qb * gz + q3 * gx); + q3 += (qa * gz + qb * gy - qc * gx); + + // Normalise quaternion + recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); + q0 *= recipNorm; + q1 *= recipNorm; + q2 *= recipNorm; + q3 *= recipNorm; + anglesComputed = 0; +} + +//------------------------------------------------------------------------------------------- +// Fast inverse square-root +// See: http://en.wikipedia.org/wiki/Fast_inverse_square_root + +float Mahony::invSqrt(float x) +{ + float halfx = 0.5f * x; + float y = x; + long i = *(long*)&y; + i = 0x5f3759df - (i>>1); + y = *(float*)&i; + y = y * (1.5f - (halfx * y * y)); + y = y * (1.5f - (halfx * y * y)); + return y; +} + +//------------------------------------------------------------------------------------------- + +void Mahony::computeAngles() +{ + roll = atan2f(q0*q1 + q2*q3, 0.5f - q1*q1 - q2*q2); + pitch = asinf(-2.0f * (q1*q3 - q0*q2)); + yaw = atan2f(q1*q2 + q0*q3, 0.5f - q2*q2 - q3*q3); + anglesComputed = 1; +} + + +//============================================================================================ +// END OF CODE +//============================================================================================ +© 2021 GitHub, Inc. \ No newline at end of file diff --git a/Assets/ESP8266Program/microPython_9250/angleQuery.c.meta b/Assets/ESP8266Program/microPython_9250/angleQuery.c.meta new file mode 100644 index 0000000..78a91e3 --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/angleQuery.c.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: 4b10b79676f245846bf68004b1d87fa7 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ESP8266Program/microPython_9250/mpu6500.py b/Assets/ESP8266Program/microPython_9250/mpu6500.py new file mode 100644 index 0000000..658286e --- /dev/null +++ b/Assets/ESP8266Program/microPython_9250/mpu6500.py @@ -0,0 +1,217 @@ +# Copyright (c) 2018-2020 Mika Tuupola +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copied of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# https://github.com/tuupola/micropython-mpu9250 + +""" +MicroPython I2C driver for MPU6500 6-axis motion tracking device +""" + +__version__ = "0.3.0" + +# pylint: disable=import-error +import ustruct +import utime +from machine import I2C, Pin +from micropython import const +# pylint: enable=import-error + +_GYRO_CONFIG = const(0x1b) +_ACCEL_CONFIG = const(0x1c) +_ACCEL_CONFIG2 = const(0x1d) +_ACCEL_XOUT_H = const(0x3b) +_ACCEL_XOUT_L = const(0x3c) +_ACCEL_YOUT_H = const(0x3d) +_ACCEL_YOUT_L = const(0x3e) +_ACCEL_ZOUT_H = const(0x3f) +_ACCEL_ZOUT_L= const(0x40) +_TEMP_OUT_H = const(0x41) +_TEMP_OUT_L = const(0x42) +_GYRO_XOUT_H = const(0x43) +_GYRO_XOUT_L = const(0x44) +_GYRO_YOUT_H = const(0x45) +_GYRO_YOUT_L = const(0x46) +_GYRO_ZOUT_H = const(0x47) +_GYRO_ZOUT_L = const(0x48) +_WHO_AM_I = const(0x75) + +#_ACCEL_FS_MASK = const(0b00011000) +ACCEL_FS_SEL_2G = const(0b00000000) +ACCEL_FS_SEL_4G = const(0b00001000) +ACCEL_FS_SEL_8G = const(0b00010000) +ACCEL_FS_SEL_16G = const(0b00011000) + +_ACCEL_SO_2G = 16384 # 1 / 16384 ie. 0.061 mg / digit +_ACCEL_SO_4G = 8192 # 1 / 8192 ie. 0.122 mg / digit +_ACCEL_SO_8G = 4096 # 1 / 4096 ie. 0.244 mg / digit +_ACCEL_SO_16G = 2048 # 1 / 2048 ie. 0.488 mg / digit + +#_GYRO_FS_MASK = const(0b00011000) +GYRO_FS_SEL_250DPS = const(0b00000000) +GYRO_FS_SEL_500DPS = const(0b00001000) +GYRO_FS_SEL_1000DPS = const(0b00010000) +GYRO_FS_SEL_2000DPS = const(0b00011000) + +_GYRO_SO_250DPS = 131 +_GYRO_SO_500DPS = 62.5 +_GYRO_SO_1000DPS = 32.8 +_GYRO_SO_2000DPS = 16.4 + +_TEMP_SO = 333.87 +_TEMP_OFFSET = 21 + +SF_G = 1 +SF_M_S2 = 9.80665 # 1 g = 9.80665 m/s2 ie. standard gravity +SF_DEG_S = 1 +SF_RAD_S = 0.017453292519943 # 1 deg/s is 0.017453292519943 rad/s + +class MPU6500: + """Class which provides interface to MPU6500 6-axis motion tracking device.""" + def __init__( + self, i2c, address=0x68, + accel_fs=ACCEL_FS_SEL_2G, gyro_fs=GYRO_FS_SEL_250DPS, + accel_sf=SF_M_S2, gyro_sf=SF_RAD_S, + gyro_offset=(0, 0, 0) + ): + self.i2c = i2c + self.address = address + + # 0x70 = standalone MPU6500, 0x71 = MPU6250 SIP + if self.whoami not in [0x71, 0x70]: + raise RuntimeError("MPU6500 not found in I2C bus.") + + self._accel_so = self._accel_fs(accel_fs) + self._gyro_so = self._gyro_fs(gyro_fs) + self._accel_sf = accel_sf + self._gyro_sf = gyro_sf + self._gyro_offset = gyro_offset + + @property + def acceleration(self): + """ + Acceleration measured by the sensor. By default will return a + 3-tuple of X, Y, Z axis acceleration values in m/s^2 as floats. Will + return values in g if constructor was provided `accel_sf=SF_M_S2` + parameter. + """ + so = self._accel_so + sf = self._accel_sf + + xyz = self._register_three_shorts(_ACCEL_XOUT_H) + return tuple([value / so * sf for value in xyz]) + + @property + def gyro(self): + """ + X, Y, Z radians per second as floats. + """ + so = self._gyro_so + sf = self._gyro_sf + ox, oy, oz = self._gyro_offset + + xyz = self._register_three_shorts(_GYRO_XOUT_H) + xyz = [value / so * sf for value in xyz] + + xyz[0] -= ox + xyz[1] -= oy + xyz[2] -= oz + + return tuple(xyz) + + @property + def temperature(self): + """ + Die temperature in celcius as a float. + """ + temp = self._register_short(_TEMP_OUT_H) + return ((temp - _TEMP_OFFSET) / _TEMP_SO) + _TEMP_OFFSET + + @property + def whoami(self): + """ Value of the whoami register. """ + return self._register_char(_WHO_AM_I) + + def calibrate(self, count=256, delay=0): + ox, oy, oz = (0.0, 0.0, 0.0) + self._gyro_offset = (0.0, 0.0, 0.0) + n = float(count) + + while count: + utime.sleep_ms(delay) + gx, gy, gz = self.gyro + ox += gx + oy += gy + oz += gz + count -= 1 + + self._gyro_offset = (ox / n, oy / n, oz / n) + return self._gyro_offset + + def _register_short(self, register, value=None, buf=bytearray(2)): + if value is None: + self.i2c.readfrom_mem_into(self.address, register, buf) + return ustruct.unpack(">h", buf)[0] + + ustruct.pack_into(">h", buf, 0, value) + return self.i2c.writeto_mem(self.address, register, buf) + + def _register_three_shorts(self, register, buf=bytearray(6)): + self.i2c.readfrom_mem_into(self.address, register, buf) + return ustruct.unpack(">hhh", buf) + + def _register_char(self, register, value=None, buf=bytearray(1)): + if value is None: + self.i2c.readfrom_mem_into(self.address, register, buf) + return buf[0] + + ustruct.pack_into(" listReceive = new List(); + public string jsonData = ""; + public Transform MpuBoardTrans; + + + // Use this for initialization + void Start () { + //Application.targetFrameRate = 120; + try + { + serialPort = new SerialPort("COM4", 115200); + serialPort.ReadTimeout = 500; + if (!serialPort.IsOpen) + { + serialPort.Open(); + } + readPortData = new Thread(new ThreadStart(readData)); + readPortData.IsBackground = true; + readPortData.Start(); + } + catch (Exception) + { + throw; + } + } + + // Update is called once per frame + void Update () { + if (jsonData != "") { + MPUQuaternion mpudata_ = JsonMapper.ToObject(jsonData); + MpuBoardTrans.transform.localEulerAngles = TransQuaternionToEularAngles((float)mpudata_.q0, (float)mpudata_.q1, (float)mpudata_.q2, (float)mpudata_.q3); + } + } + + + + + + //结束后关闭串口 + private void OnDestroy() + { + if (serialPort.IsOpen) + serialPort.Close(); + readPortData.Abort(); + } + + //弧度转角度 + private float TransRadToAngle(double rad) + { + //return -(float)rad * 180 / Mathf.PI; + return (float)rad * 90; + } + //Double转Float + private float TransDoubleToFloat(double angle) + { + //return -(float)rad * 180 / Mathf.PI; + return (float)angle; + } + /// + /// 读取数据 + /// + private void readData() + { + try + { + while (serialPort != null && serialPort.IsOpen) + { + byte addr = Convert.ToByte(serialPort.ReadByte()); + serialPort.DiscardInBuffer(); + //listReceive.Add(addr); + //print("{"+serialPort.ReadLine()); + jsonData = "{" + serialPort.ReadLine(); + } + } + catch (Exception) + { + throw; + } + } + + //将四元数转换为欧拉角(pitch,yaw取负数的情况) + public Vector3 TransQuaternionToEularAngles(float q0, float q1, float q2, float q3) + { + float pitch = -Mathf.Asin(-2 * q1 * q3 + 2 * q0 * q2) * 57.3f; + float roll = Mathf.Atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2 * q2 + 1) * 57.3f; + float yaw = -Mathf.Atan2(2 * (q1 * q2 + q0 * q3), q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3) * 57.3f; + Vector3 eularAngles = new Vector3(pitch, yaw, roll); + return eularAngles; + } +} diff --git a/Assets/script/MyUnitySerialPort.cs.meta b/Assets/script/MyUnitySerialPort.cs.meta new file mode 100644 index 0000000..63a60b4 --- /dev/null +++ b/Assets/script/MyUnitySerialPort.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 124ab28672a6a104cab21f951dbdcc9c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/SerialPort.meta b/Assets/script/SerialPort.meta new file mode 100644 index 0000000..22d94b5 --- /dev/null +++ b/Assets/script/SerialPort.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f069669f196b83645a25c2fc7e3266fc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/SerialPort/My9AxisSerialPort.cs b/Assets/script/SerialPort/My9AxisSerialPort.cs new file mode 100644 index 0000000..8d89c9b --- /dev/null +++ b/Assets/script/SerialPort/My9AxisSerialPort.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO.Ports; +using System.Threading; +using UnityEngine; +using LitJson; +using AHRS; + +public class My9AxisSerialPort : MonoBehaviour { + private SerialPort serialPort; + private Thread readPortData; + //public List listReceive = new List(); + public string jsonData = ""; + public Transform MpuBoardTrans; + private MahonyAHRS ahrsObj = new MahonyAHRS(0.016f); + + + // Use this for initialization + void Start() + { + //Application.targetFrameRate = 120; + try + { + serialPort = new SerialPort("COM4", 115200); + serialPort.ReadTimeout = 500; + if (!serialPort.IsOpen) + { + serialPort.Open(); + } + readPortData = new Thread(new ThreadStart(readData)); + readPortData.IsBackground = true; + readPortData.Start(); + } + catch (Exception) + { + throw; + } + } + + // Update is called once per frame + void Update() + { + if (jsonData != "") + { + MPU9250Data mpudata_ = JsonMapper.ToObject(jsonData); + ahrsObj.Update((float)mpudata_.GyroX, (float)mpudata_.GyroY, (float)mpudata_.GyroZ, (float)mpudata_.AccelX, (float)mpudata_.AccelY, (float)mpudata_.AccelZ, (float)mpudata_.MagneticX, (float)mpudata_.MagneticY, (float)mpudata_.MagneticZ); + MpuBoardTrans.transform.localEulerAngles = TransQuaternionToEularAngles(ahrsObj.Quaternion[0], ahrsObj.Quaternion[1], ahrsObj.Quaternion[2], ahrsObj.Quaternion[3]); + } + } + + + + + + //结束后关闭串口 + private void OnDestroy() + { + if (serialPort.IsOpen) + serialPort.Close(); + readPortData.Abort(); + } + + //弧度转角度 + private float TransRadToAngle(double rad) + { + //return -(float)rad * 180 / Mathf.PI; + return (float)rad * 90; + } + //Double转Float + private float TransDoubleToFloat(double angle) + { + //return -(float)rad * 180 / Mathf.PI; + return (float)angle; + } + /// + /// 读取数据 + /// + private void readData() + { + try + { + while (serialPort != null && serialPort.IsOpen) + { + byte addr = Convert.ToByte(serialPort.ReadByte()); + serialPort.DiscardInBuffer(); + //listReceive.Add(addr); + //print("{"+serialPort.ReadLine()); + jsonData = "{" + serialPort.ReadLine(); + } + } + catch (Exception) + { + throw; + } + } + + //将四元数转换为欧拉角(pitch,yaw取负数的情况) + public Vector3 TransQuaternionToEularAngles(float q0, float q1, float q2, float q3) + { + float pitch = -Mathf.Asin(-2 * q1 * q3 + 2 * q0 * q2) * 57.3f; + float roll = Mathf.Atan2(2 * q2 * q3 + 2 * q0 * q1, -2 * q1 * q1 - 2 * q2 * q2 + 1) * 57.3f; + float yaw = -Mathf.Atan2(2 * (q1 * q2 + q0 * q3), q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3) * 57.3f; + Vector3 eularAngles = new Vector3(pitch, yaw, roll); + return eularAngles; + } +} diff --git a/Assets/script/SerialPort/My9AxisSerialPort.cs.meta b/Assets/script/SerialPort/My9AxisSerialPort.cs.meta new file mode 100644 index 0000000..ed931f8 --- /dev/null +++ b/Assets/script/SerialPort/My9AxisSerialPort.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ab7d50adce3c662469fbc3ea36ba0b1a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/SerialPort/MyAccelSerialPort.cs b/Assets/script/SerialPort/MyAccelSerialPort.cs new file mode 100644 index 0000000..928281c --- /dev/null +++ b/Assets/script/SerialPort/MyAccelSerialPort.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO.Ports; +using System.Threading; +using UnityEngine; +using LitJson; + +public class MyAccelSerialPort : MonoBehaviour +{ + private SerialPort serialPort; + private Thread readPortData; + //public List listReceive = new List(); + public string jsonData = ""; + //根据受力情况设置小球的位置 + public Transform AccelBall; + + + // Use this for initialization + void Start() + { + //Application.targetFrameRate = 120; + try + { + serialPort = new SerialPort("COM4", 115200); + serialPort.ReadTimeout = 500; + if (!serialPort.IsOpen) + { + serialPort.Open(); + } + readPortData = new Thread(new ThreadStart(readData)); + readPortData.IsBackground = true; + readPortData.Start(); + } + catch (Exception) + { + throw; + } + } + + // Update is called once per frame + void Update() + { + if (jsonData != "") + { + MPUAccelData mpudata_ = JsonMapper.ToObject(jsonData); + AccelBall.localPosition = new Vector3((float)mpudata_.AccelX/2, (float)mpudata_.AccelY/2 - 2.3f, (float)mpudata_.AccelZ/2 + 1.2f); + //Debug.LogWarning("Temperature = " + mpudata_.Temperature); + //print("x=" + mpudata_.GyroX + "||y=" + mpudata_.GyroY + "||z=" + mpudata_.GyroZ + "____Ax=" + mpudata_.AccelX + "||Ay=" + mpudata_.AccelY + "||Az=" + mpudata_.AccelZ + "-----" + Time.deltaTime); + //MpuBoardTrans.transform.localPosition += new Vector3(speedX/1000, 0, 0); + //print("speed="+speedY); + } + } + + + + + + //结束后关闭串口 + private void OnDestroy() + { + if (serialPort.IsOpen) + serialPort.Close(); + readPortData.Abort(); + } + + //弧度转角度 + private float TransRadToAngle(double rad) + { + //return -(float)rad * 180 / Mathf.PI; + return (float)rad * 90; + } + /// + /// 读取数据 + /// + private void readData() + { + try + { + while (serialPort != null && serialPort.IsOpen) + { + byte addr = Convert.ToByte(serialPort.ReadByte()); + serialPort.DiscardInBuffer(); + //listReceive.Add(addr); + //print("{"+serialPort.ReadLine()); + jsonData = "{" + serialPort.ReadLine(); + } + } + catch (Exception) + { + throw; + } + } + + + private void caculateSpeed(float accelSpeed) + { + + } +} diff --git a/Assets/script/SerialPort/MyAccelSerialPort.cs.meta b/Assets/script/SerialPort/MyAccelSerialPort.cs.meta new file mode 100644 index 0000000..02868f9 --- /dev/null +++ b/Assets/script/SerialPort/MyAccelSerialPort.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a0061e86cc4079144b3748956df78ad9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/SerialPort/MyAngleSerialPort.cs b/Assets/script/SerialPort/MyAngleSerialPort.cs new file mode 100644 index 0000000..6c5ce8f --- /dev/null +++ b/Assets/script/SerialPort/MyAngleSerialPort.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class MyAngleSerialPort : MonoBehaviour { + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/Assets/script/SerialPort/MyAngleSerialPort.cs.meta b/Assets/script/SerialPort/MyAngleSerialPort.cs.meta new file mode 100644 index 0000000..70a1eca --- /dev/null +++ b/Assets/script/SerialPort/MyAngleSerialPort.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4a0ac8ac7b846b04c820bc886a63fe18 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/SerialPort/MyMagneticSerialPort.cs b/Assets/script/SerialPort/MyMagneticSerialPort.cs new file mode 100644 index 0000000..33f1288 --- /dev/null +++ b/Assets/script/SerialPort/MyMagneticSerialPort.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO.Ports; +using System.Threading; +using UnityEngine; +using LitJson; + +public class MyMagneticSerialPort : MonoBehaviour +{ + private SerialPort serialPort; + private Thread readPortData; + //public List listReceive = new List(); + public string jsonData = ""; + //根据磁场数据反射磁场针转向 + public Transform MagneticNeedle; + + + // Use this for initialization + void Start() + { + //Application.targetFrameRate = 120; + try + { + serialPort = new SerialPort("COM4", 115200); + serialPort.ReadTimeout = 500; + if (!serialPort.IsOpen) + { + serialPort.Open(); + } + readPortData = new Thread(new ThreadStart(readData)); + readPortData.IsBackground = true; + readPortData.Start(); + } + catch (Exception) + { + throw; + } + } + + // Update is called once per frame + void Update() + { + if (jsonData != "") + { + MPUMagneticData mpudata_ = JsonMapper.ToObject(jsonData); + MagneticNeedle.localEulerAngles = new Vector3(((float)mpudata_.MagneticX-5)*4, ((float)mpudata_.MagneticY-67)*4, ((float)mpudata_.MagneticZ - 5) * 4); + //Debug.LogWarning("Temperature = " + mpudata_.Temperature); + //print("x=" + mpudata_.GyroX + "||y=" + mpudata_.GyroY + "||z=" + mpudata_.GyroZ + "____Ax=" + mpudata_.AccelX + "||Ay=" + mpudata_.AccelY + "||Az=" + mpudata_.AccelZ + "-----" + Time.deltaTime); + //MpuBoardTrans.transform.localPosition += new Vector3(speedX/1000, 0, 0); + //print("speed="+speedY); + } + } + + + + + + //结束后关闭串口 + private void OnDestroy() + { + if (serialPort.IsOpen) + serialPort.Close(); + readPortData.Abort(); + } + + //弧度转角度 + private float TransRadToAngle(double rad) + { + //return -(float)rad * 180 / Mathf.PI; + return (float)rad * 90; + } + /// + /// 读取数据 + /// + private void readData() + { + try + { + while (serialPort != null && serialPort.IsOpen) + { + byte addr = Convert.ToByte(serialPort.ReadByte()); + serialPort.DiscardInBuffer(); + //listReceive.Add(addr); + //print("{"+serialPort.ReadLine()); + jsonData = "{" + serialPort.ReadLine(); + } + } + catch (Exception) + { + throw; + } + } + + + private void caculateSpeed(float accelSpeed) + { + + } +} + diff --git a/Assets/script/SerialPort/MyMagneticSerialPort.cs.meta b/Assets/script/SerialPort/MyMagneticSerialPort.cs.meta new file mode 100644 index 0000000..b3c264e --- /dev/null +++ b/Assets/script/SerialPort/MyMagneticSerialPort.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b3600f1e1e53b4643bb94c8917c9999e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/UI.meta b/Assets/script/UI.meta new file mode 100644 index 0000000..a3bec97 --- /dev/null +++ b/Assets/script/UI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6644dc02366c0c7488f80fdddb6370ac +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/UI/MyDataBar.cs b/Assets/script/UI/MyDataBar.cs new file mode 100644 index 0000000..36efb99 --- /dev/null +++ b/Assets/script/UI/MyDataBar.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class MyDataBar : MonoBehaviour { + public Image BarImgPostive; + public Image BarImgNagetive; + [Range(-100f,100f)] + public float values; + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () { + if (values >= 0) + { + BarImgPostive.fillAmount = values / 100; + BarImgNagetive.fillAmount = 0; + } + else { + BarImgPostive.fillAmount = 0; + BarImgNagetive.fillAmount = -values / 100; + } + } +} diff --git a/Assets/script/UI/MyDataBar.cs.meta b/Assets/script/UI/MyDataBar.cs.meta new file mode 100644 index 0000000..03dd131 --- /dev/null +++ b/Assets/script/UI/MyDataBar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 72fa529d1dea2a845b05e00a99658d71 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/UnitySerialPort.cs b/Assets/script/UnitySerialPort.cs new file mode 100644 index 0000000..a114018 --- /dev/null +++ b/Assets/script/UnitySerialPort.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO.Ports; +using System.Threading; +using UnityEngine; + +public class UnitySerialPort : MonoBehaviour +{ + private SerialPort serialPort; + private Thread readPortData; + + public int[] SpeedValueArr; + int ClientCount = 2; + + public List listReceive = new List(); + + private void Start() + { + SpeedValueArr = new int[ClientCount]; + try + { + serialPort = new SerialPort("COM4", 115200); + serialPort.ReadTimeout = 500; + if (!serialPort.IsOpen) + { + serialPort.Open(); + } + + readPortData = new Thread(new ThreadStart(readData)); + readPortData.IsBackground = true; + readPortData.Start(); + } + catch (Exception) + { + throw; + } + } + + private void OnDestroy() + { + if (serialPort.IsOpen) + serialPort.Close(); + readPortData.Abort(); + } + + + /// + /// 读取数据 + /// + private void readData() + { + try + { + while (serialPort != null && serialPort.IsOpen) + { + byte addr = Convert.ToByte(serialPort.ReadByte()); + serialPort.DiscardInBuffer(); + listReceive.Add(addr); + ParseReceive(); + PrintData(); + print(serialPort.ReadLine()); + } + } + catch (Exception) + { + throw; + } + } + + /// + /// 打印数据 + /// + void PrintData() + { + string str = string.Empty; + for (int i = 0; i < listReceive.Count; i++) + { + str += listReceive[i].ToString("X2"); //这里只会得到数据 FC + } + + string Data = System.Text.Encoding.Default.GetString(listReceive.ToArray()); + //print(Data); + } + + private void ParseReceive() + { + if (listReceive.Count < ClientCount + 2) + { + return; + } + for (int i = 0; i < ClientCount; i++) + { + SpeedValueArr[i] = listReceive[listReceive.Count - 1 - i]; //这里只会得到数据 252 + } + listReceive.RemoveRange(0, ClientCount + 2); + } + + void _serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + Debug.Log("???"); + try + { + System.Threading.Thread.Sleep(20); + byte[] _data = new byte[serialPort.BytesToRead]; + serialPort.Read(_data, 0, _data.Length); + if (_data.Length == 0) { return; } + if (serialPort != null) + { + print(_data); + } + //_serialPort.DiscardInBuffer(); //清空接收缓冲区 + } + catch (Exception ex) + { + throw ex; + } + } +} \ No newline at end of file diff --git a/Assets/script/UnitySerialPort.cs.meta b/Assets/script/UnitySerialPort.cs.meta new file mode 100644 index 0000000..62e4187 --- /dev/null +++ b/Assets/script/UnitySerialPort.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 515906fa9ddd85348a21b04413a87281 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/mathTransForm.meta b/Assets/script/mathTransForm.meta new file mode 100644 index 0000000..11f7689 --- /dev/null +++ b/Assets/script/mathTransForm.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 66455f740ef69224e8529c8ee2456205 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/mathTransForm/MahonyAHRS.cs b/Assets/script/mathTransForm/MahonyAHRS.cs new file mode 100644 index 0000000..6e28de1 --- /dev/null +++ b/Assets/script/mathTransForm/MahonyAHRS.cs @@ -0,0 +1,293 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AHRS +{ + /// + /// MahonyAHRS class. Madgwick's implementation of Mayhony's AHRS algorithm. + /// + /// + /// See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms + /// + public class MahonyAHRS + { + /// + /// Gets or sets the sample period. + /// + public float SamplePeriod { get; set; } + + /// + /// Gets or sets the algorithm proportional gain. + /// + public float Kp { get; set; } + + /// + /// Gets or sets the algorithm integral gain. + /// + public float Ki { get; set; } + + /// + /// Gets or sets the Quaternion output. + /// + public float[] Quaternion { get; set; } + + /// + /// Gets or sets the integral error. + /// + private float[] eInt { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Sample period. + /// + public MahonyAHRS(float samplePeriod) + : this(samplePeriod, 1f, 0f) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Sample period. + /// + /// + /// Algorithm proportional gain. + /// + public MahonyAHRS(float samplePeriod, float kp) + : this(samplePeriod, kp, 0f) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Sample period. + /// + /// + /// Algorithm proportional gain. + /// + /// + /// Algorithm integral gain. + /// + public MahonyAHRS(float samplePeriod, float kp, float ki) + { + SamplePeriod = samplePeriod; + Kp = kp; + Ki = ki; + Quaternion = new float[] { 1f, 0f, 0f, 0f }; + eInt = new float[] { 0f, 0f, 0f }; + } + + /// + /// Algorithm AHRS update method. Requires only gyroscope and accelerometer data. + /// + /// + /// Gyroscope x axis measurement in radians/s. + /// + /// + /// Gyroscope y axis measurement in radians/s. + /// + /// + /// Gyroscope z axis measurement in radians/s. + /// + /// + /// Accelerometer x axis measurement in any calibrated units. + /// + /// + /// Accelerometer y axis measurement in any calibrated units. + /// + /// + /// Accelerometer z axis measurement in any calibrated units. + /// + /// + /// Magnetometer x axis measurement in any calibrated units. + /// + /// + /// Magnetometer y axis measurement in any calibrated units. + /// + /// + /// Magnetometer z axis measurement in any calibrated units. + /// + /// + /// Optimised for minimal arithmetic. + /// + public void Update(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz) + { + float q1 = Quaternion[0], q2 = Quaternion[1], q3 = Quaternion[2], q4 = Quaternion[3]; // short name local variable for readability + float norm; + float hx, hy, bx, bz; + float vx, vy, vz, wx, wy, wz; + float ex, ey, ez; + float pa, pb, pc; + + // Auxiliary variables to avoid repeated arithmetic + float q1q1 = q1 * q1; + float q1q2 = q1 * q2; + float q1q3 = q1 * q3; + float q1q4 = q1 * q4; + float q2q2 = q2 * q2; + float q2q3 = q2 * q3; + float q2q4 = q2 * q4; + float q3q3 = q3 * q3; + float q3q4 = q3 * q4; + float q4q4 = q4 * q4; + + // Normalise accelerometer measurement + norm = (float)Math.Sqrt(ax * ax + ay * ay + az * az); + if (norm == 0f) return; // handle NaN + norm = 1 / norm; // use reciprocal for division + ax *= norm; + ay *= norm; + az *= norm; + + // Normalise magnetometer measurement + norm = (float)Math.Sqrt(mx * mx + my * my + mz * mz); + if (norm == 0f) return; // handle NaN + norm = 1 / norm; // use reciprocal for division + mx *= norm; + my *= norm; + mz *= norm; + + // Reference direction of Earth's magnetic field + hx = 2f * mx * (0.5f - q3q3 - q4q4) + 2f * my * (q2q3 - q1q4) + 2f * mz * (q2q4 + q1q3); + hy = 2f * mx * (q2q3 + q1q4) + 2f * my * (0.5f - q2q2 - q4q4) + 2f * mz * (q3q4 - q1q2); + bx = (float)Math.Sqrt((hx * hx) + (hy * hy)); + bz = 2f * mx * (q2q4 - q1q3) + 2f * my * (q3q4 + q1q2) + 2f * mz * (0.5f - q2q2 - q3q3); + + // Estimated direction of gravity and magnetic field + vx = 2f * (q2q4 - q1q3); + vy = 2f * (q1q2 + q3q4); + vz = q1q1 - q2q2 - q3q3 + q4q4; + wx = 2f * bx * (0.5f - q3q3 - q4q4) + 2f * bz * (q2q4 - q1q3); + wy = 2f * bx * (q2q3 - q1q4) + 2f * bz * (q1q2 + q3q4); + wz = 2f * bx * (q1q3 + q2q4) + 2f * bz * (0.5f - q2q2 - q3q3); + + // Error is cross product between estimated direction and measured direction of gravity + ex = (ay * vz - az * vy) + (my * wz - mz * wy); + ey = (az * vx - ax * vz) + (mz * wx - mx * wz); + ez = (ax * vy - ay * vx) + (mx * wy - my * wx); + if (Ki > 0f) + { + eInt[0] += ex; // accumulate integral error + eInt[1] += ey; + eInt[2] += ez; + } + else + { + eInt[0] = 0.0f; // prevent integral wind up + eInt[1] = 0.0f; + eInt[2] = 0.0f; + } + + // Apply feedback terms + gx = gx + Kp * ex + Ki * eInt[0]; + gy = gy + Kp * ey + Ki * eInt[1]; + gz = gz + Kp * ez + Ki * eInt[2]; + + // Integrate rate of change of quaternion + pa = q2; + pb = q3; + pc = q4; + q1 = q1 + (-q2 * gx - q3 * gy - q4 * gz) * (0.5f * SamplePeriod); + q2 = pa + (q1 * gx + pb * gz - pc * gy) * (0.5f * SamplePeriod); + q3 = pb + (q1 * gy - pa * gz + pc * gx) * (0.5f * SamplePeriod); + q4 = pc + (q1 * gz + pa * gy - pb * gx) * (0.5f * SamplePeriod); + + // Normalise quaternion + norm = (float)Math.Sqrt(q1 * q1 + q2 * q2 + q3 * q3 + q4 * q4); + norm = 1.0f / norm; + Quaternion[0] = q1 * norm; + Quaternion[1] = q2 * norm; + Quaternion[2] = q3 * norm; + Quaternion[3] = q4 * norm; + } + + /// + /// Algorithm IMU update method. Requires only gyroscope and accelerometer data. + /// + /// + /// Gyroscope x axis measurement in radians/s. + /// + /// + /// Gyroscope y axis measurement in radians/s. + /// + /// + /// Gyroscope z axis measurement in radians/s. + /// + /// + /// Accelerometer x axis measurement in any calibrated units. + /// + /// + /// Accelerometer y axis measurement in any calibrated units. + /// + /// + /// Accelerometer z axis measurement in any calibrated units. + /// + public void Update(float gx, float gy, float gz, float ax, float ay, float az) + { + float q1 = Quaternion[0], q2 = Quaternion[1], q3 = Quaternion[2], q4 = Quaternion[3]; // short name local variable for readability + float norm; + float vx, vy, vz; + float ex, ey, ez; + float pa, pb, pc; + + // Normalise accelerometer measurement + norm = (float)Math.Sqrt(ax * ax + ay * ay + az * az); + if (norm == 0f) return; // handle NaN + norm = 1 / norm; // use reciprocal for division + ax *= norm; + ay *= norm; + az *= norm; + + // Estimated direction of gravity + vx = 2.0f * (q2 * q4 - q1 * q3); + vy = 2.0f * (q1 * q2 + q3 * q4); + vz = q1 * q1 - q2 * q2 - q3 * q3 + q4 * q4; + + // Error is cross product between estimated direction and measured direction of gravity + ex = (ay * vz - az * vy); + ey = (az * vx - ax * vz); + ez = (ax * vy - ay * vx); + if (Ki > 0f) + { + eInt[0] += ex; // accumulate integral error + eInt[1] += ey; + eInt[2] += ez; + } + else + { + eInt[0] = 0.0f; // prevent integral wind up + eInt[1] = 0.0f; + eInt[2] = 0.0f; + } + + // Apply feedback terms + gx = gx + Kp * ex + Ki * eInt[0]; + gy = gy + Kp * ey + Ki * eInt[1]; + gz = gz + Kp * ez + Ki * eInt[2]; + + // Integrate rate of change of quaternion + pa = q2; + pb = q3; + pc = q4; + q1 = q1 + (-q2 * gx - q3 * gy - q4 * gz) * (0.5f * SamplePeriod); + q2 = pa + (q1 * gx + pb * gz - pc * gy) * (0.5f * SamplePeriod); + q3 = pb + (q1 * gy - pa * gz + pc * gx) * (0.5f * SamplePeriod); + q4 = pc + (q1 * gz + pa * gy - pb * gx) * (0.5f * SamplePeriod); + + // Normalise quaternion + norm = (float)Math.Sqrt(q1 * q1 + q2 * q2 + q3 * q3 + q4 * q4); + norm = 1.0f / norm; + Quaternion[0] = q1 * norm; + Quaternion[1] = q2 * norm; + Quaternion[2] = q3 * norm; + Quaternion[3] = q4 * norm; + } + } +} \ No newline at end of file diff --git a/Assets/script/mathTransForm/MahonyAHRS.cs.meta b/Assets/script/mathTransForm/MahonyAHRS.cs.meta new file mode 100644 index 0000000..4abe877 --- /dev/null +++ b/Assets/script/mathTransForm/MahonyAHRS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 90c8ca4eebb769845af91ba5c15587c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/script/mathTransForm/QuaternionTrans.cs b/Assets/script/mathTransForm/QuaternionTrans.cs new file mode 100644 index 0000000..ab48d18 --- /dev/null +++ b/Assets/script/mathTransForm/QuaternionTrans.cs @@ -0,0 +1,7 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class QuaternionTrans : MonoBehaviour { + +} diff --git a/Assets/script/mathTransForm/QuaternionTrans.cs.meta b/Assets/script/mathTransForm/QuaternionTrans.cs.meta new file mode 100644 index 0000000..e92e99e --- /dev/null +++ b/Assets/script/mathTransForm/QuaternionTrans.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 59caa8ef48be5f3419a9ac1e4a4b442d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json new file mode 100644 index 0000000..1342d0a --- /dev/null +++ b/Packages/manifest.json @@ -0,0 +1,39 @@ +{ + "dependencies": { + "com.unity.ads": "2.0.8", + "com.unity.analytics": "2.0.16", + "com.unity.package-manager-ui": "1.9.11", + "com.unity.purchasing": "2.0.3", + "com.unity.textmeshpro": "1.2.4", + "com.unity.modules.ai": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } +} diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset new file mode 100644 index 0000000..4f31e74 --- /dev/null +++ b/ProjectSettings/AudioManager.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!11 &1 +AudioManager: + m_ObjectHideFlags: 0 + m_Volume: 1 + Rolloff Scale: 1 + Doppler Factor: 1 + Default Speaker Mode: 2 + m_SampleRate: 0 + m_DSPBufferSize: 1024 + m_VirtualVoiceCount: 512 + m_RealVoiceCount: 32 + m_SpatializerPlugin: + m_AmbisonicDecoderPlugin: + m_DisableAudio: 0 + m_VirtualizeEffects: 1 diff --git a/ProjectSettings/ClusterInputManager.asset b/ProjectSettings/ClusterInputManager.asset new file mode 100644 index 0000000..e7886b2 --- /dev/null +++ b/ProjectSettings/ClusterInputManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!236 &1 +ClusterInputManager: + m_ObjectHideFlags: 0 + m_Inputs: [] diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset new file mode 100644 index 0000000..78992f0 --- /dev/null +++ b/ProjectSettings/DynamicsManager.asset @@ -0,0 +1,29 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!55 &1 +PhysicsManager: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_Gravity: {x: 0, y: -9.81, z: 0} + m_DefaultMaterial: {fileID: 0} + m_BounceThreshold: 2 + m_SleepThreshold: 0.005 + m_DefaultContactOffset: 0.01 + m_DefaultSolverIterations: 6 + m_DefaultSolverVelocityIterations: 1 + m_QueriesHitBackfaces: 0 + m_QueriesHitTriggers: 1 + m_EnableAdaptiveForce: 0 + m_ClothInterCollisionDistance: 0 + m_ClothInterCollisionStiffness: 0 + m_ContactsGeneration: 1 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_AutoSimulation: 1 + m_AutoSyncTransforms: 1 + m_ClothInterCollisionSettingsToggle: 0 + m_ContactPairsMode: 0 + m_BroadphaseType: 0 + m_WorldBounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 250, y: 250, z: 250} + m_WorldSubdivisions: 8 diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 0000000..ea88784 --- /dev/null +++ b/ProjectSettings/EditorBuildSettings.asset @@ -0,0 +1,11 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1045 &1 +EditorBuildSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Scenes: + - enabled: 1 + path: Assets/Scenes/SampleScene.unity + guid: 99c9720ab356a0642a771bea13969a05 + m_configObjects: {} diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset new file mode 100644 index 0000000..29dea52 --- /dev/null +++ b/ProjectSettings/EditorSettings.asset @@ -0,0 +1,21 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!159 &1 +EditorSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_ExternalVersionControlSupport: Visible Meta Files + m_SerializationMode: 2 + m_LineEndingsForNewScripts: 2 + m_DefaultBehaviorMode: 0 + m_SpritePackerMode: 0 + m_SpritePackerPaddingPower: 1 + m_EtcTextureCompressorBehavior: 1 + m_EtcTextureFastCompressor: 1 + m_EtcTextureNormalCompressor: 2 + m_EtcTextureBestCompressor: 4 + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd + m_ProjectGenerationRootNamespace: + m_UserGeneratedProjectSuffix: + m_CollabEditorSettings: + inProgressEnabled: 1 diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 0000000..cd1c3d6 --- /dev/null +++ b/ProjectSettings/GraphicsSettings.asset @@ -0,0 +1,62 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!30 &1 +GraphicsSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_Deferred: + m_Mode: 1 + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} + m_DeferredReflections: + m_Mode: 1 + m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} + m_ScreenSpaceShadows: + m_Mode: 1 + m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} + m_LegacyDeferred: + m_Mode: 1 + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} + m_DepthNormals: + m_Mode: 1 + m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} + m_MotionVectors: + m_Mode: 1 + m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} + m_LightHalo: + m_Mode: 1 + m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} + m_LensFlare: + m_Mode: 1 + m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} + m_AlwaysIncludedShaders: + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} + m_PreloadedShaders: [] + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, + type: 0} + m_CustomRenderPipeline: {fileID: 0} + m_TransparencySortMode: 0 + m_TransparencySortAxis: {x: 0, y: 0, z: 1} + m_DefaultRenderingPath: 1 + m_DefaultMobileRenderingPath: 1 + m_TierSettings: [] + m_LightmapStripping: 0 + m_FogStripping: 0 + m_InstancingStripping: 0 + m_LightmapKeepPlain: 1 + m_LightmapKeepDirCombined: 1 + m_LightmapKeepDynamicPlain: 1 + m_LightmapKeepDynamicDirCombined: 1 + m_LightmapKeepShadowMask: 1 + m_LightmapKeepSubtractive: 1 + m_FogKeepLinear: 1 + m_FogKeepExp: 1 + m_FogKeepExp2: 1 + m_AlbedoSwatchInfos: [] + m_LightsUseLinearIntensity: 0 + m_LightsUseColorTemperature: 0 diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset new file mode 100644 index 0000000..17c8f53 --- /dev/null +++ b/ProjectSettings/InputManager.asset @@ -0,0 +1,295 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left shift + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: return + altNegativeButton: + altPositiveButton: joystick button 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: enter + altNegativeButton: + altPositiveButton: space + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Cancel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: escape + altNegativeButton: + altPositiveButton: joystick button 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/ProjectSettings/NavMeshAreas.asset b/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 0000000..3b0b7c3 --- /dev/null +++ b/ProjectSettings/NavMeshAreas.asset @@ -0,0 +1,91 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshProjectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + areas: + - name: Walkable + cost: 1 + - name: Not Walkable + cost: 1 + - name: Jump + cost: 2 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + m_LastAgentTypeID: -887442657 + m_Settings: + - serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.75 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_SettingNames: + - Humanoid diff --git a/ProjectSettings/NetworkManager.asset b/ProjectSettings/NetworkManager.asset new file mode 100644 index 0000000..5dc6a83 --- /dev/null +++ b/ProjectSettings/NetworkManager.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!149 &1 +NetworkManager: + m_ObjectHideFlags: 0 + m_DebugLevel: 0 + m_Sendrate: 15 + m_AssetToPrefab: {} diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 0000000..132ee6b --- /dev/null +++ b/ProjectSettings/Physics2DSettings.asset @@ -0,0 +1,37 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!19 &1 +Physics2DSettings: + m_ObjectHideFlags: 0 + serializedVersion: 3 + m_Gravity: {x: 0, y: -9.81} + m_DefaultMaterial: {fileID: 0} + m_VelocityIterations: 8 + m_PositionIterations: 3 + m_VelocityThreshold: 1 + m_MaxLinearCorrection: 0.2 + m_MaxAngularCorrection: 8 + m_MaxTranslationSpeed: 100 + m_MaxRotationSpeed: 360 + m_BaumgarteScale: 0.2 + m_BaumgarteTimeOfImpactScale: 0.75 + m_TimeToSleep: 0.5 + m_LinearSleepTolerance: 0.01 + m_AngularSleepTolerance: 2 + m_DefaultContactOffset: 0.01 + m_AutoSimulation: 1 + m_QueriesHitTriggers: 1 + m_QueriesStartInColliders: 1 + m_ChangeStopsCallbacks: 0 + m_CallbacksOnDisable: 1 + m_AutoSyncTransforms: 1 + m_AlwaysShowColliders: 0 + m_ShowColliderSleep: 1 + m_ShowColliderContacts: 0 + m_ShowColliderAABB: 0 + m_ContactArrowScale: 0.2 + m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} + m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} + m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} + m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/ProjectSettings/PresetManager.asset b/ProjectSettings/PresetManager.asset new file mode 100644 index 0000000..820e662 --- /dev/null +++ b/ProjectSettings/PresetManager.asset @@ -0,0 +1,27 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1386491679 &1 +PresetManager: + m_ObjectHideFlags: 0 + m_DefaultList: + - type: + m_NativeTypeID: 108 + m_ManagedTypePPtr: {fileID: 0} + m_ManagedTypeFallback: + defaultPresets: + - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, + type: 2} + - type: + m_NativeTypeID: 1020 + m_ManagedTypePPtr: {fileID: 0} + m_ManagedTypeFallback: + defaultPresets: + - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, + type: 2} + - type: + m_NativeTypeID: 1006 + m_ManagedTypePPtr: {fileID: 0} + m_ManagedTypeFallback: + defaultPresets: + - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, + type: 2} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset new file mode 100644 index 0000000..0b208df --- /dev/null +++ b/ProjectSettings/ProjectSettings.asset @@ -0,0 +1,659 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!129 &1 +PlayerSettings: + m_ObjectHideFlags: 0 + serializedVersion: 15 + productGUID: f912f5fc81be36844af06ef23254e231 + AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 + defaultScreenOrientation: 4 + targetDevice: 2 + useOnDemandResources: 0 + accelerometerFrequency: 60 + companyName: DefaultCompany + productName: GPIOTest + defaultCursor: {fileID: 0} + cursorHotspot: {x: 0, y: 0} + m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} + m_ShowUnitySplashScreen: 1 + m_ShowUnitySplashLogo: 1 + m_SplashScreenOverlayOpacity: 1 + m_SplashScreenAnimation: 1 + m_SplashScreenLogoStyle: 1 + m_SplashScreenDrawMode: 0 + m_SplashScreenBackgroundAnimationZoom: 1 + m_SplashScreenLogoAnimationZoom: 1 + m_SplashScreenBackgroundLandscapeAspect: 1 + m_SplashScreenBackgroundPortraitAspect: 1 + m_SplashScreenBackgroundLandscapeUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenBackgroundPortraitUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenLogos: [] + m_VirtualRealitySplashScreen: {fileID: 0} + m_HolographicTrackingLossScreen: {fileID: 0} + defaultScreenWidth: 1024 + defaultScreenHeight: 768 + defaultScreenWidthWeb: 960 + defaultScreenHeightWeb: 600 + m_StereoRenderingPath: 0 + m_ActiveColorSpace: 0 + m_MTRendering: 1 + m_StackTraceTypes: 010000000100000001000000010000000100000001000000 + iosShowActivityIndicatorOnLoading: -1 + androidShowActivityIndicatorOnLoading: -1 + iosAppInBackgroundBehavior: 0 + displayResolutionDialog: 1 + iosAllowHTTPDownload: 1 + allowedAutorotateToPortrait: 1 + allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToLandscapeRight: 1 + allowedAutorotateToLandscapeLeft: 1 + useOSAutorotation: 1 + use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 + disableDepthAndStencilBuffers: 0 + androidBlitType: 0 + defaultIsNativeResolution: 1 + macRetinaSupport: 1 + runInBackground: 1 + captureSingleScreen: 0 + muteOtherAudioSources: 0 + Prepare IOS For Recording: 0 + Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 + submitAnalytics: 1 + usePlayerLog: 1 + bakeCollisionMeshes: 0 + forceSingleInstance: 0 + resizableWindow: 0 + useMacAppStoreValidation: 0 + macAppStoreCategory: public.app-category.games + gpuSkinning: 1 + graphicsJobs: 0 + xboxPIXTextureCapture: 0 + xboxEnableAvatar: 0 + xboxEnableKinect: 0 + xboxEnableKinectAutoTracking: 0 + xboxEnableFitness: 0 + visibleInBackground: 1 + allowFullscreenSwitch: 1 + graphicsJobMode: 0 + fullscreenMode: 1 + xboxSpeechDB: 0 + xboxEnableHeadOrientation: 0 + xboxEnableGuest: 0 + xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 + n3dsDisableStereoscopicView: 0 + n3dsEnableSharedListOpt: 1 + n3dsEnableVSync: 0 + xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 + xboxOneMonoLoggingLevel: 0 + xboxOneLoggingLevel: 1 + xboxOneDisableEsram: 0 + xboxOnePresentImmediateThreshold: 0 + switchQueueCommandMemory: 0 + videoMemoryForVertexBuffers: 0 + psp2PowerMode: 0 + psp2AcquireBGM: 1 + vulkanEnableSetSRGBWrite: 0 + vulkanUseSWCommandBuffers: 0 + m_SupportedAspectRatios: + 4:3: 1 + 5:4: 1 + 16:10: 1 + 16:9: 1 + Others: 1 + bundleVersion: 0.1 + preloadedAssets: [] + metroInputSource: 0 + wsaTransparentSwapchain: 0 + m_HolographicPauseOnTrackingLoss: 1 + xboxOneDisableKinectGpuReservation: 0 + xboxOneEnable7thCore: 0 + isWsaHolographicRemotingEnabled: 0 + vrSettings: + cardboard: + depthFormat: 0 + enableTransitionView: 0 + daydream: + depthFormat: 0 + useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 + hololens: + depthFormat: 1 + depthBufferSharingEnabled: 0 + oculus: + sharedDepthBuffer: 0 + dashSupport: 0 + enable360StereoCapture: 0 + protectGraphicsMemory: 0 + useHDRDisplay: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 + resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 + applicationIdentifier: {} + buildNumber: {} + AndroidBundleVersionCode: 1 + AndroidMinSdkVersion: 16 + AndroidTargetSdkVersion: 0 + AndroidPreferredInstallLocation: 1 + aotOptions: + stripEngineCode: 1 + iPhoneStrippingLevel: 0 + iPhoneScriptCallOptimization: 0 + ForceInternetPermission: 0 + ForceSDCardPermission: 0 + CreateWallpaper: 0 + APKExpansionFiles: 0 + keepLoadedShadersAlive: 0 + StripUnusedMeshComponents: 1 + VertexChannelCompressionMask: 4054 + iPhoneSdkVersion: 988 + iOSTargetOSVersionString: 8.0 + tvOSSdkVersion: 0 + tvOSRequireExtendedGameController: 0 + tvOSTargetOSVersionString: 9.0 + uIPrerenderedIcon: 0 + uIRequiresPersistentWiFi: 0 + uIRequiresFullScreen: 1 + uIStatusBarHidden: 1 + uIExitOnSuspend: 0 + uIStatusBarStyle: 0 + iPhoneSplashScreen: {fileID: 0} + iPhoneHighResSplashScreen: {fileID: 0} + iPhoneTallHighResSplashScreen: {fileID: 0} + iPhone47inSplashScreen: {fileID: 0} + iPhone55inPortraitSplashScreen: {fileID: 0} + iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} + iPadPortraitSplashScreen: {fileID: 0} + iPadHighResPortraitSplashScreen: {fileID: 0} + iPadLandscapeSplashScreen: {fileID: 0} + iPadHighResLandscapeSplashScreen: {fileID: 0} + appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} + tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] + tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] + tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] + tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] + iOSLaunchScreenType: 0 + iOSLaunchScreenPortrait: {fileID: 0} + iOSLaunchScreenLandscape: {fileID: 0} + iOSLaunchScreenBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreenFillPct: 100 + iOSLaunchScreenSize: 100 + iOSLaunchScreenCustomXibPath: + iOSLaunchScreeniPadType: 0 + iOSLaunchScreeniPadImage: {fileID: 0} + iOSLaunchScreeniPadBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreeniPadFillPct: 100 + iOSLaunchScreeniPadSize: 100 + iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: + iOSDeviceRequirements: [] + iOSURLSchemes: [] + iOSBackgroundModes: 0 + iOSMetalForceHardShadows: 0 + metalEditorSupport: 1 + metalAPIValidation: 1 + iOSRenderExtraFrameOnPause: 0 + appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 + appleEnableAutomaticSigning: 0 + iOSRequireARKit: 0 + appleEnableProMotion: 0 + vulkanEditorSupport: 0 + clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea + templatePackageId: com.unity.3d@1.0.2 + templateDefaultScene: Assets/Scenes/SampleScene.unity + AndroidTargetArchitectures: 5 + AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} + AndroidKeystoreName: + AndroidKeyaliasName: + AndroidBuildApkPerCpuArchitecture: 0 + AndroidTVCompatibility: 1 + AndroidIsGame: 1 + AndroidEnableTango: 0 + androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 + m_AndroidBanners: + - width: 320 + height: 180 + banner: {fileID: 0} + androidGamepadSupportLevel: 0 + resolutionDialogBanner: {fileID: 0} + m_BuildTargetIcons: [] + m_BuildTargetPlatformIcons: [] + m_BuildTargetBatching: + - m_BuildTarget: Standalone + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: tvOS + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: Android + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: iPhone + m_StaticBatching: 1 + m_DynamicBatching: 0 + - m_BuildTarget: WebGL + m_StaticBatching: 0 + m_DynamicBatching: 0 + m_BuildTargetGraphicsAPIs: + - m_BuildTarget: AndroidPlayer + m_APIs: 0b00000015000000 + m_Automatic: 1 + - m_BuildTarget: iOSSupport + m_APIs: 10000000 + m_Automatic: 1 + - m_BuildTarget: AppleTVSupport + m_APIs: 10000000 + m_Automatic: 0 + - m_BuildTarget: WebGLSupport + m_APIs: 0b000000 + m_Automatic: 1 + m_BuildTargetVRSettings: + - m_BuildTarget: Standalone + m_Enabled: 0 + m_Devices: + - Oculus + - OpenVR + m_BuildTargetEnableVuforiaSettings: [] + openGLRequireES31: 0 + openGLRequireES31AEP: 0 + m_TemplateCustomTags: {} + mobileMTRendering: + Android: 1 + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: [] + m_BuildTargetGroupLightmapSettings: [] + playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 + actionOnDotNetUnhandledException: 1 + enableInternalProfiler: 0 + logObjCUncaughtExceptions: 1 + enableCrashReportAPI: 0 + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + switchNetLibKey: + switchSocketMemoryPoolSize: 6144 + switchSocketAllocatorPoolSize: 128 + switchSocketConcurrencyLimit: 14 + switchScreenResolutionBehavior: 2 + switchUseCPUProfiler: 0 + switchApplicationID: 0x01004b9000490000 + switchNSODependencies: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: + switchIcons_0: {fileID: 0} + switchIcons_1: {fileID: 0} + switchIcons_2: {fileID: 0} + switchIcons_3: {fileID: 0} + switchIcons_4: {fileID: 0} + switchIcons_5: {fileID: 0} + switchIcons_6: {fileID: 0} + switchIcons_7: {fileID: 0} + switchIcons_8: {fileID: 0} + switchIcons_9: {fileID: 0} + switchIcons_10: {fileID: 0} + switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} + switchSmallIcons_0: {fileID: 0} + switchSmallIcons_1: {fileID: 0} + switchSmallIcons_2: {fileID: 0} + switchSmallIcons_3: {fileID: 0} + switchSmallIcons_4: {fileID: 0} + switchSmallIcons_5: {fileID: 0} + switchSmallIcons_6: {fileID: 0} + switchSmallIcons_7: {fileID: 0} + switchSmallIcons_8: {fileID: 0} + switchSmallIcons_9: {fileID: 0} + switchSmallIcons_10: {fileID: 0} + switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: + switchMainThreadStackSize: 1048576 + switchPresenceGroupId: + switchLogoHandling: 0 + switchReleaseVersion: 0 + switchDisplayVersion: 1.0.0 + switchStartupUserAccount: 0 + switchTouchScreenUsage: 0 + switchSupportedLanguagesMask: 0 + switchLogoType: 0 + switchApplicationErrorCodeCategory: + switchUserAccountSaveDataSize: 0 + switchUserAccountSaveDataJournalSize: 0 + switchApplicationAttribute: 0 + switchCardSpecSize: -1 + switchCardSpecClock: -1 + switchRatingsMask: 0 + switchRatingsInt_0: 0 + switchRatingsInt_1: 0 + switchRatingsInt_2: 0 + switchRatingsInt_3: 0 + switchRatingsInt_4: 0 + switchRatingsInt_5: 0 + switchRatingsInt_6: 0 + switchRatingsInt_7: 0 + switchRatingsInt_8: 0 + switchRatingsInt_9: 0 + switchRatingsInt_10: 0 + switchRatingsInt_11: 0 + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: + switchParentalControl: 0 + switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 + switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 + switchSupportedNpadStyles: 3 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 + switchSocketConfigEnabled: 0 + switchTcpInitialSendBufferSize: 32 + switchTcpInitialReceiveBufferSize: 64 + switchTcpAutoSendBufferSizeMax: 256 + switchTcpAutoReceiveBufferSizeMax: 256 + switchUdpSendBufferSize: 9 + switchUdpReceiveBufferSize: 42 + switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 + ps4NPAgeRating: 12 + ps4NPTitleSecret: + ps4NPTrophyPackPath: + ps4ParentalLevel: 11 + ps4ContentID: ED1633-NPXX51362_00-0000000000000000 + ps4Category: 0 + ps4MasterVersion: 01.00 + ps4AppVersion: 01.00 + ps4AppType: 0 + ps4ParamSfxPath: + ps4VideoOutPixelFormat: 0 + ps4VideoOutInitialWidth: 1920 + ps4VideoOutBaseModeInitialWidth: 1920 + ps4VideoOutReprojectionRate: 60 + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4NPtitleDatPath: + ps4RemotePlayKeyAssignment: -1 + ps4RemotePlayKeyMappingDir: + ps4PlayTogetherPlayerCount: 0 + ps4EnterButtonAssignment: 1 + ps4ApplicationParam1: 0 + ps4ApplicationParam2: 0 + ps4ApplicationParam3: 0 + ps4ApplicationParam4: 0 + ps4DownloadDataSize: 0 + ps4GarlicHeapSize: 2048 + ps4ProGarlicHeapSize: 2560 + ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ + ps4pnSessions: 1 + ps4pnPresence: 1 + ps4pnFriends: 1 + ps4pnGameCustomData: 1 + playerPrefsSupport: 0 + enableApplicationExit: 0 + restrictedAudioUsageRights: 0 + ps4UseResolutionFallback: 0 + ps4ReprojectionSupport: 0 + ps4UseAudio3dBackend: 0 + ps4SocialScreenEnabled: 0 + ps4ScriptOptimizationLevel: 0 + ps4Audio3dVirtualSpeakerCount: 14 + ps4attribCpuUsage: 0 + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: + ps4PatchDayOne: 0 + ps4attribUserManagement: 0 + ps4attribMoveSupport: 0 + ps4attrib3DSupport: 0 + ps4attribShareSupport: 0 + ps4attribExclusiveVR: 0 + ps4disableAutoHideSplash: 0 + ps4videoRecordingFeaturesUsed: 0 + ps4contentSearchFeaturesUsed: 0 + ps4attribEyeToEyeDistanceSettingVR: 0 + ps4IncludedModules: [] + monoEnv: + psp2Splashimage: {fileID: 0} + psp2NPTrophyPackPath: + psp2NPSupportGBMorGJP: 0 + psp2NPAgeRating: 12 + psp2NPTitleDatPath: + psp2NPCommsID: + psp2NPCommunicationsID: + psp2NPCommsPassphrase: + psp2NPCommsSig: + psp2ParamSfxPath: + psp2ManualPath: + psp2LiveAreaGatePath: + psp2LiveAreaBackroundPath: + psp2LiveAreaPath: + psp2LiveAreaTrialPath: + psp2PatchChangeInfoPath: + psp2PatchOriginalPackage: + psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui + psp2KeystoneFile: + psp2MemoryExpansionMode: 0 + psp2DRMType: 0 + psp2StorageType: 0 + psp2MediaCapacity: 0 + psp2DLCConfigPath: + psp2ThumbnailPath: + psp2BackgroundPath: + psp2SoundPath: + psp2TrophyCommId: + psp2TrophyPackagePath: + psp2PackagedResourcesPath: + psp2SaveDataQuota: 10240 + psp2ParentalLevel: 1 + psp2ShortTitle: Not Set + psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF + psp2Category: 0 + psp2MasterVersion: 01.00 + psp2AppVersion: 01.00 + psp2TVBootMode: 0 + psp2EnterButtonAssignment: 2 + psp2TVDisableEmu: 0 + psp2AllowTwitterDialog: 1 + psp2Upgradable: 0 + psp2HealthWarning: 0 + psp2UseLibLocation: 0 + psp2InfoBarOnStartup: 0 + psp2InfoBarColor: 0 + psp2ScriptOptimizationLevel: 0 + splashScreenBackgroundSourceLandscape: {fileID: 0} + splashScreenBackgroundSourcePortrait: {fileID: 0} + spritePackerPolicy: + webGLMemorySize: 256 + webGLExceptionSupport: 1 + webGLNameFilesAsHashes: 0 + webGLDataCaching: 1 + webGLDebugSymbols: 0 + webGLEmscriptenArgs: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 + webGLUseEmbeddedResources: 0 + webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + scriptingDefineSymbols: {} + platformArchitecture: {} + scriptingBackend: {} + il2cppCompilerConfiguration: {} + incrementalIl2cppBuild: {} + allowUnsafeCode: 0 + additionalIl2CppArgs: + scriptingRuntimeVersion: 0 + apiCompatibilityLevelPerPlatform: + Standalone: 1 + m_RenderingPath: 1 + m_MobileRenderingPath: 1 + metroPackageName: Template_3D + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: + metroCertificateNotAfter: 0000000000000000 + metroApplicationDescription: Template_3D + wsaImages: {} + metroTileShortName: + metroTileShowName: 0 + metroMediumTileShowName: 0 + metroLargeTileShowName: 0 + metroWideTileShowName: 0 + metroDefaultTileSize: 1 + metroTileForegroundText: 2 + metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} + metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, + a: 1} + metroSplashScreenUseBackgroundColor: 0 + platformCapabilities: {} + metroFTAName: + metroFTAFileTypes: [] + metroProtocolName: + metroCompilationOverrides: 1 + n3dsUseExtSaveData: 0 + n3dsCompressStaticMem: 1 + n3dsExtSaveDataNumber: 0x12345 + n3dsStackSize: 131072 + n3dsTargetPlatform: 2 + n3dsRegion: 7 + n3dsMediaSize: 0 + n3dsLogoStyle: 3 + n3dsTitle: GameName + n3dsProductCode: + n3dsApplicationId: 0xFF3FF + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 + XboxOnePackageEncryption: 0 + XboxOnePackageUpdateGranularity: 2 + XboxOneDescription: + XboxOneLanguage: + - enus + XboxOneCapability: [] + XboxOneGameRating: {} + XboxOneIsContentPackage: 0 + XboxOneEnableGPUVariability: 0 + XboxOneSockets: {} + XboxOneSplashScreen: {fileID: 0} + XboxOneAllowedProductIds: [] + XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 + xboxOneScriptCompiler: 0 + vrEditorSettings: + daydream: + daydreamIconForeground: {fileID: 0} + daydreamIconBackground: {fileID: 0} + cloudServicesEnabled: + UNet: 1 + facebookSdkVersion: 7.9.4 + apiCompatibilityLevel: 2 + cloudProjectId: 3e3a8277-3954-4f7c-a349-7e440ef5c772 + projectName: GPIOTest + organizationId: 1031139173-qq-com + cloudEnabled: 0 + enableNativePlatformBackendsForNewInputSystem: 0 + disableOldInputManagerSupport: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt new file mode 100644 index 0000000..f1fda1a --- /dev/null +++ b/ProjectSettings/ProjectVersion.txt @@ -0,0 +1 @@ +m_EditorVersion: 2018.2.14f1 diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset new file mode 100644 index 0000000..b02e48b --- /dev/null +++ b/ProjectSettings/QualitySettings.asset @@ -0,0 +1,217 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!47 &1 +QualitySettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_CurrentQuality: 4 + m_QualitySettings: + - serializedVersion: 2 + name: Very Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 15 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 1 + textureQuality: 1 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.3 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 4 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.4 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 16 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Medium + pixelLightCount: 1 + shadows: 1 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 1 + lodBias: 0.7 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 64 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: High + pixelLightCount: 2 + shadows: 2 + shadowResolution: 1 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 2 + softParticles: 0 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 256 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Very High + pixelLightCount: 3 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 4 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 0 + lodBias: 1.5 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 1024 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Ultra + pixelLightCount: 4 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 4 + shadowDistance: 150 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 4 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 2 + maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 + particleRaycastBudget: 4096 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + m_PerPlatformDefaultQuality: + Android: 0 + Standalone: 0 + WebGL: 0 + iPhone: 0 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset new file mode 100644 index 0000000..17cb803 --- /dev/null +++ b/ProjectSettings/TagManager.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!78 &1 +TagManager: + serializedVersion: 2 + tags: [] + layers: + - Default + - TransparentFX + - Ignore Raycast + - + - Water + - UI + - + - + - PostProcessing + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + m_SortingLayers: + - name: Default + uniqueID: 0 + locked: 0 diff --git a/ProjectSettings/TimeManager.asset b/ProjectSettings/TimeManager.asset new file mode 100644 index 0000000..06bcc6d --- /dev/null +++ b/ProjectSettings/TimeManager.asset @@ -0,0 +1,9 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!5 &1 +TimeManager: + m_ObjectHideFlags: 0 + Fixed Timestep: 0.02 + Maximum Allowed Timestep: 0.1 + m_TimeScale: 1 + Maximum Particle Timestep: 0.03 diff --git a/ProjectSettings/UnityConnectSettings.asset b/ProjectSettings/UnityConnectSettings.asset new file mode 100644 index 0000000..863581f --- /dev/null +++ b/ProjectSettings/UnityConnectSettings.asset @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!310 &1 +UnityConnectSettings: + m_ObjectHideFlags: 0 + m_Enabled: 1 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + m_TestInitMode: 0 + CrashReportingSettings: + m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes + m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate + m_Enabled: 0 + m_CaptureEditorExceptions: 1 + UnityPurchasingSettings: + m_Enabled: 0 + m_TestMode: 0 + UnityAnalyticsSettings: + m_Enabled: 1 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + UnityAdsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_IosGameId: + m_AndroidGameId: + m_GameIds: {} + m_GameId: + PerformanceReportingSettings: + m_Enabled: 0 diff --git a/README.md b/README.md index d6d9915..4adab1d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ -# MPU6050_ESP8266_Unity - -陀螺仪结合Unity姿态孪生Demo演示 -硬件使用:MPU6050,MPU9250。 -MCU使用:ESP8266。 -自备串口TTL读取工具。 -固件选择:MicroPython&NodeMCU。 +# MPU6050_ESP8266_Unity + +## 陀螺仪结合Unity姿态孪生Demo演示 + + + + +| 硬件使用 | MPU6050,MPU9250 | +| ----- | ------------------- | +| MCU使用 | ESP8266 | +| 串口使用 | TTL转USB串口工具 | +| 固件选择 | MicroPython&NodeMCU | + +自备杜邦线若干用于连接串口 + 拷贝Assets\ESP8266Program中对应脚本到MCU内存中运行即可,连接串口后,串口收到消息时,打开Unity运行对应程序即可看到陀螺仪模块的姿态孪生(旋转角度会和陀螺仪保持一致) \ No newline at end of file