00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef BRICK_IMU_H
00012 #define BRICK_IMU_H
00013
00014 #include "ip_connection.h"
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00029 typedef Device IMU;
00030
00034 #define IMU_FUNCTION_GET_ACCELERATION 1
00035
00039 #define IMU_FUNCTION_GET_MAGNETIC_FIELD 2
00040
00044 #define IMU_FUNCTION_GET_ANGULAR_VELOCITY 3
00045
00049 #define IMU_FUNCTION_GET_ALL_DATA 4
00050
00054 #define IMU_FUNCTION_GET_ORIENTATION 5
00055
00059 #define IMU_FUNCTION_GET_QUATERNION 6
00060
00064 #define IMU_FUNCTION_GET_IMU_TEMPERATURE 7
00065
00069 #define IMU_FUNCTION_LEDS_ON 8
00070
00074 #define IMU_FUNCTION_LEDS_OFF 9
00075
00079 #define IMU_FUNCTION_ARE_LEDS_ON 10
00080
00084 #define IMU_FUNCTION_SET_ACCELERATION_RANGE 11
00085
00089 #define IMU_FUNCTION_GET_ACCELERATION_RANGE 12
00090
00094 #define IMU_FUNCTION_SET_MAGNETOMETER_RANGE 13
00095
00099 #define IMU_FUNCTION_GET_MAGNETOMETER_RANGE 14
00100
00104 #define IMU_FUNCTION_SET_CONVERGENCE_SPEED 15
00105
00109 #define IMU_FUNCTION_GET_CONVERGENCE_SPEED 16
00110
00114 #define IMU_FUNCTION_SET_CALIBRATION 17
00115
00119 #define IMU_FUNCTION_GET_CALIBRATION 18
00120
00124 #define IMU_FUNCTION_SET_ACCELERATION_PERIOD 19
00125
00129 #define IMU_FUNCTION_GET_ACCELERATION_PERIOD 20
00130
00134 #define IMU_FUNCTION_SET_MAGNETIC_FIELD_PERIOD 21
00135
00139 #define IMU_FUNCTION_GET_MAGNETIC_FIELD_PERIOD 22
00140
00144 #define IMU_FUNCTION_SET_ANGULAR_VELOCITY_PERIOD 23
00145
00149 #define IMU_FUNCTION_GET_ANGULAR_VELOCITY_PERIOD 24
00150
00154 #define IMU_FUNCTION_SET_ALL_DATA_PERIOD 25
00155
00159 #define IMU_FUNCTION_GET_ALL_DATA_PERIOD 26
00160
00164 #define IMU_FUNCTION_SET_ORIENTATION_PERIOD 27
00165
00169 #define IMU_FUNCTION_GET_ORIENTATION_PERIOD 28
00170
00174 #define IMU_FUNCTION_SET_QUATERNION_PERIOD 29
00175
00179 #define IMU_FUNCTION_GET_QUATERNION_PERIOD 30
00180
00184 #define IMU_FUNCTION_ORIENTATION_CALCULATION_ON 37
00185
00189 #define IMU_FUNCTION_ORIENTATION_CALCULATION_OFF 38
00190
00194 #define IMU_FUNCTION_IS_ORIENTATION_CALCULATION_ON 39
00195
00199 #define IMU_FUNCTION_GET_PROTOCOL1_BRICKLET_NAME 241
00200
00204 #define IMU_FUNCTION_GET_CHIP_TEMPERATURE 242
00205
00209 #define IMU_FUNCTION_RESET 243
00210
00214 #define IMU_FUNCTION_GET_IDENTITY 255
00215
00225 #define IMU_CALLBACK_ACCELERATION 31
00226
00236 #define IMU_CALLBACK_MAGNETIC_FIELD 32
00237
00247 #define IMU_CALLBACK_ANGULAR_VELOCITY 33
00248
00259 #define IMU_CALLBACK_ALL_DATA 34
00260
00271 #define IMU_CALLBACK_ORIENTATION 35
00272
00283 #define IMU_CALLBACK_QUATERNION 36
00284
00285
00289 #define IMU_CALIBRATION_TYPE_ACCELEROMETER_GAIN 0
00290
00294 #define IMU_CALIBRATION_TYPE_ACCELEROMETER_BIAS 1
00295
00299 #define IMU_CALIBRATION_TYPE_MAGNETOMETER_GAIN 2
00300
00304 #define IMU_CALIBRATION_TYPE_MAGNETOMETER_BIAS 3
00305
00309 #define IMU_CALIBRATION_TYPE_GYROSCOPE_GAIN 4
00310
00314 #define IMU_CALIBRATION_TYPE_GYROSCOPE_BIAS 5
00315
00325 #define IMU_DEVICE_IDENTIFIER 16
00326
00333 void imu_create(IMU *imu, const char *uid, IPConnection *ipcon);
00334
00341 void imu_destroy(IMU *imu);
00342
00362 int imu_get_response_expected(IMU *imu, uint8_t function_id, bool *ret_response_expected);
00363
00379 int imu_set_response_expected(IMU *imu, uint8_t function_id, bool response_expected);
00380
00387 int imu_set_response_expected_all(IMU *imu, bool response_expected);
00388
00395 void imu_register_callback(IMU *imu, uint8_t id, void *callback, void *user_data);
00396
00403 int imu_get_api_version(IMU *imu, uint8_t ret_api_version[3]);
00404
00415 int imu_get_acceleration(IMU *imu, int16_t *ret_x, int16_t *ret_y, int16_t *ret_z);
00416
00427 int imu_get_magnetic_field(IMU *imu, int16_t *ret_x, int16_t *ret_y, int16_t *ret_z);
00428
00440 int imu_get_angular_velocity(IMU *imu, int16_t *ret_x, int16_t *ret_y, int16_t *ret_z);
00441
00454 int imu_get_all_data(IMU *imu, int16_t *ret_acc_x, int16_t *ret_acc_y, int16_t *ret_acc_z, int16_t *ret_mag_x, int16_t *ret_mag_y, int16_t *ret_mag_z, int16_t *ret_ang_x, int16_t *ret_ang_y, int16_t *ret_ang_z, int16_t *ret_temperature);
00455
00472 int imu_get_orientation(IMU *imu, int16_t *ret_roll, int16_t *ret_pitch, int16_t *ret_yaw);
00473
00509 int imu_get_quaternion(IMU *imu, float *ret_x, float *ret_y, float *ret_z, float *ret_w);
00510
00517 int imu_get_imu_temperature(IMU *imu, int16_t *ret_temperature);
00518
00524 int imu_leds_on(IMU *imu);
00525
00531 int imu_leds_off(IMU *imu);
00532
00539 int imu_are_leds_on(IMU *imu, bool *ret_leds);
00540
00546 int imu_set_acceleration_range(IMU *imu, uint8_t range);
00547
00553 int imu_get_acceleration_range(IMU *imu, uint8_t *ret_range);
00554
00560 int imu_set_magnetometer_range(IMU *imu, uint8_t range);
00561
00567 int imu_get_magnetometer_range(IMU *imu, uint8_t *ret_range);
00568
00600 int imu_set_convergence_speed(IMU *imu, uint16_t speed);
00601
00607 int imu_get_convergence_speed(IMU *imu, uint16_t *ret_speed);
00608
00647 int imu_set_calibration(IMU *imu, uint8_t typ, int16_t data[10]);
00648
00654 int imu_get_calibration(IMU *imu, uint8_t typ, int16_t ret_data[10]);
00655
00664 int imu_set_acceleration_period(IMU *imu, uint32_t period);
00665
00671 int imu_get_acceleration_period(IMU *imu, uint32_t *ret_period);
00672
00679 int imu_set_magnetic_field_period(IMU *imu, uint32_t period);
00680
00686 int imu_get_magnetic_field_period(IMU *imu, uint32_t *ret_period);
00687
00694 int imu_set_angular_velocity_period(IMU *imu, uint32_t period);
00695
00701 int imu_get_angular_velocity_period(IMU *imu, uint32_t *ret_period);
00702
00709 int imu_set_all_data_period(IMU *imu, uint32_t period);
00710
00716 int imu_get_all_data_period(IMU *imu, uint32_t *ret_period);
00717
00724 int imu_set_orientation_period(IMU *imu, uint32_t period);
00725
00731 int imu_get_orientation_period(IMU *imu, uint32_t *ret_period);
00732
00739 int imu_set_quaternion_period(IMU *imu, uint32_t period);
00740
00746 int imu_get_quaternion_period(IMU *imu, uint32_t *ret_period);
00747
00757 int imu_orientation_calculation_on(IMU *imu);
00758
00776 int imu_orientation_calculation_off(IMU *imu);
00777
00786 int imu_is_orientation_calculation_on(IMU *imu, bool *ret_orientation_calculation_on);
00787
00797 int imu_get_protocol1_bricklet_name(IMU *imu, char port, uint8_t *ret_protocol_version, uint8_t ret_firmware_version[3], char ret_name[40]);
00798
00809 int imu_get_chip_temperature(IMU *imu, int16_t *ret_temperature);
00810
00821 int imu_reset(IMU *imu);
00822
00835 int imu_get_identity(IMU *imu, char ret_uid[8], char ret_connected_uid[8], char *ret_position, uint8_t ret_hardware_version[3], uint8_t ret_firmware_version[3], uint16_t *ret_device_identifier);
00836
00837 #ifdef __cplusplus
00838 }
00839 #endif
00840
00841 #endif