我正在开发 sphero 应用程序并想添加一个基于陀螺仪的驾驶。据我了解,我需要创建CMMotionManager
、获取yaw
值并将其作为参数传递给RKTiltDriveAlgorithm
. 我不明白我在哪里传递RKTiltDriveAlgorithm
实例。文档说要传递RKRobotControl
似乎无法从任何地方访问的实例。RKRobotProvider
有一个属性,RKRobotControl
但它是不可分配的。到目前为止,这是我的代码
RKTiltDriveAlgorithm *tilt = [[RKTiltDriveAlgorithm alloc] initWithOrientation:[UIApplication sharedApplication].statusBarOrientation];
...
[self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) {
float yaw = (180/M_PI) * motion.attitude.yaw;
tilt.orientationAngle = yaw;
}];
不胜感激一些提示,谢谢:)