当前位置: 首页>>代码示例>>C++>>正文


C++ Actuator::Activate方法代码示例

本文整理汇总了C++中Actuator::Activate方法的典型用法代码示例。如果您正苦于以下问题:C++ Actuator::Activate方法的具体用法?C++ Actuator::Activate怎么用?C++ Actuator::Activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Actuator的用法示例。


在下文中一共展示了Actuator::Activate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setup

//-----------------------------------------------------------------------------
//
void setup()
{
    Serial.begin(9600);
    Wire.begin();
    i2cData[0] = 7; // Set the sample rate to 1000Hz - 8kHz/(7+1) = 1000Hz
    i2cData[1] = 0x00; // Disable FSYNC and set 260 Hz Acc filtering, 256 Hz Gyro filtering, 8 KHz sampling
    i2cData[2] = 0x00; // Set Gyro Full Scale Range to ±250deg/s
    i2cData[3] = 0x00; // Set Accelerometer Full Scale Range to ±2g
    while(i2cWrite(0x19,i2cData,4,false)); // Write to all four registers at once
    while(i2cWrite(0x6B,0x01,true)); // PLL with X axis gyroscope reference and disable sleep mode

    while(i2cRead(0x75,i2cData,1));
    if(i2cData[0] != 0x68)   // Read "WHO_AM_I" register
    {
        Serial.print(F("Error reading sensor"));
        while(1);
    }

    delay(100); // Wait for sensor to stabilize

    /* Set kalman and gyro starting angle */
    while(i2cRead(0x3B,i2cData,6));
    accX = ((i2cData[0] << 8) | i2cData[1]);
    accY = ((i2cData[2] << 8) | i2cData[3]);
    accZ = ((i2cData[4] << 8) | i2cData[5]);
    // atan2 outputs the value of -π to π (radians) - see http://en.wikipedia.org/wiki/Atan2
    // We then convert it to 0 to 2π and then from radians to degrees
    accYangle = (atan2(accX,accZ)+PI)*RAD_TO_DEG;
    accXangle = (atan2(accY,accZ)+PI)*RAD_TO_DEG;

    kalmanX.setAngle(accXangle); // Set starting angle
    kalmanY.setAngle(accYangle);
    gyroXangle = accXangle;
    gyroYangle = accYangle;
    compAngleX = accXangle;
    compAngleY = accYangle;

    TCCR2B = TCCR2B & 0b11111000 | 0x05;

    m1.Initialize();
    m2.Initialize();

    m1.Activate();
    m2.Activate();

    timer = micros();
}
开发者ID:biodynamical,项目名称:Embedded,代码行数:49,代码来源:main.cpp


注:本文中的Actuator::Activate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。