【问题标题】:Gyroscope driven sphero陀螺仪驱动球体
【发布时间】:2014-07-14 09:21:49
【问题描述】:

我正在开发 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;
}];

不胜感激,谢谢:)

【问题讨论】:

    标签: ios iphone sphero-api sphero


    【解决方案1】:

    对于这方面的困惑,我深表歉意。实际上,我们一直在简化倾斜控制以使集成更容易。请参阅 RobotUISample [https://github.com/orbotix/Sphero-iOS-SDK/tree/master/samples/RobotUISample],了解如何使用新系统的示例。

    简而言之,我们将 Tilt 移到了 RKDriveControl [https://github.com/orbotix/Sphero-iOS-SDK/blob/master/frameworks/RobotKit.framework/Headers/RKDriveControl.h],这是一个单例的引擎盖下。现在,您只需创建并使用这个单例实例来驱动 Sphero。我们现在甚至直接为您接入 CMMotionManager。您需要提供的只是驱动器类型并告诉它开始驱动。

    /*Call when Robot is connected*/
    - (void)startDriving {    
        //Drive with Tilt
        [[RKDriveControl sharedDriveControl] startDriving:RKDriveControlTilt];
    }
    

    【讨论】:

    • 感谢您的回复。似乎仍然不适合我。我在示例应用程序中将 RKDriveControlJoyStick 替换为 RKDriveControlTilt,但 sphero 根本不动。我做错了吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多