本文整理汇总了C++中LSM303::readAcc方法的典型用法代码示例。如果您正苦于以下问题:C++ LSM303::readAcc方法的具体用法?C++ LSM303::readAcc怎么用?C++ LSM303::readAcc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LSM303
的用法示例。
在下文中一共展示了LSM303::readAcc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loop
/**
* @brief provides imu readings in a 50 Hz rate.
*
*/
void loop() {
if((millis()-timer)>=20) { // Main loop runs at 50Hz
timer=millis();
//Read data from the hardware
gyro.read();
compass.readAcc();
compass.readMag();
//Assign read data to the ros messages
imu_msg.angular_velocity.x=gyro.g.x;
imu_msg.angular_velocity.y=gyro.g.y;
imu_msg.angular_velocity.z=gyro.g.z;
imu_msg.linear_acceleration.x=compass.a.x;
imu_msg.linear_acceleration.y=compass.a.y;
imu_msg.linear_acceleration.z=compass.a.z;
mag_msg.magnetic_field.x=compass.m.x;
mag_msg.magnetic_field.y=compass.m.y;
mag_msg.magnetic_field.z=compass.m.z;
//Publish the data to the ros message system
imu_pub.publish( &imu_msg );
mag_pub.publish( &mag_msg);
nh.spinOnce();
}
nh.spinOnce();
}
示例2: Read_Accel
// Reads x,y and z accelerometer registers
void Read_Accel()
{
compass.readAcc();
AN[3] = compass.a.x;
AN[4] = compass.a.y;
AN[5] = compass.a.z;
accel_x = SENSOR_SIGN[3] * (AN[3] - AN_OFFSET[3]);
accel_y = SENSOR_SIGN[4] * (AN[4] - AN_OFFSET[4]);
accel_z = SENSOR_SIGN[5] * (AN[5] - AN_OFFSET[5]);
}
示例3: Read_Accel
// Reads x,y and z accelerometer registers
void Read_Accel()
{
compass.readAcc();
AN[3] = compass.a.x >> 4; // shift left 4 bits to use 12-bit representation (1 g = 256)
AN[4] = compass.a.y >> 4;
AN[5] = compass.a.z >> 4;
accel_x = SENSOR_SIGN[3] * (AN[3] - AN_OFFSET[3]);
accel_y = SENSOR_SIGN[4] * (AN[4] - AN_OFFSET[4]);
accel_z = SENSOR_SIGN[5] * (AN[5] - AN_OFFSET[5]);
}