The customized code for the 3DM GX4-25 can be found in GitHub.
For the telemetry data in a quadruped project, we are using a MicroStrain 3DM GX4-25. To get this device to work, you have to understand a few concepts built into the provided examples. The given example provides one large main function. I broke the functionality up for the sake of modulation in my code which can be found in github in the data_test.c file. Getting the device to work in a c/c++ Linux environment is not very straightforward from the documents on the MicroStrain site. For example, if you want to capture scaled gyroscope or accelerometer values, you need to first define them in the ahrs_packet_callback() function. There are constants that represent each type of value and these constants are used in the switch statement in this funciton. Here is an example of a declaration for the scaled accelerometer values:
There are a couple of important things to note in this code block. First, the MIP_AHRS_DATA_ACCEL_SCALED is the constant defined in the mip_sdk_ahrs.h file. This is important only for identification, but it is also helpful to browse this file for the other definitions like delta velocity, delta acceleration, and internal timestamp data. Second, notice that the memcopy function is populating the shared variable, curr_ahrs_accel, and pulling the data from “field_data” with a specific size set by the mip_ahrs_scaled_accel. All these things are important because it tells you where your data is coming from. Looking at this code you can assume that there’s a variable (more specifically a struct with an array member) now called curr_ahrs_accel that you can access. The final byteswap, as it says in the comment, is for architectures that may prefer least significant endianness. [pullquote align=”center”]So the big take-away here is that you can define a case in the switch statement that fits your needs and “memcopies” over the data that you want to use.[/pullquote] With this knowledge you can even group measurements together in your own data structure. For example, I may define my own structure called _mip_ahrs_telemetry like so:
Then I can poll the data according to the given api and documentation:
and then move the data into my own variable inside of my structure:
Now you have a nice stucture that you can call to print out relevant data:
Credit: to the MicroStrain team for providing great base code to work with. Note: The original source code can be downloaded from http://www.microstrain.com/inertial/3dm-gx4-25 under the MIP™ C Code Sample for Windows and Linux Version 1.1 link. The code to run is found under the MIP%20SDK/C/Examples/Linux/GX4-25/ path.
Comments