### Install WSL Version 1 Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Installs and sets WSL version 1 for easier COM port access. Ensure to reboot after installation. ```bash wsl --install wsl --set-version Ubuntu 1 wsl --set-default-version 1 ``` -------------------------------- ### Install and Configure Minicom Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Installs minicom for serial communication testing on Linux. Configure and save the serial port setup as default. ```bash sudo apt install minicom minicom -s minicom ``` -------------------------------- ### Create Micro-ROS Workspace Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Sets up a new workspace for Micro-ROS and clones the necessary setup repository. ```bash mkdir microros_ws cd microros_ws git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup ``` -------------------------------- ### Install and Update Micro-ROS Dependencies Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Installs rosdep and updates dependencies for the Micro-ROS workspace. Ensure pip is also installed. ```bash sudo apt install python3-rosdep2 sudo apt update && rosdep update rosdep install --from-paths src --ignore-src -y sudo apt-get install python3-pip ``` -------------------------------- ### Start Pedometer Algorithm Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts the pedometer algorithm. The handler is called when a pedometer event is detected. Any interruptable pin can be used. Parameters are optional. ```C++ volatile uint8_t irq_received = 0; void irq_handler(void) { irq_received = 1; } // Accel ODR = 50 Hz and APEX Pedometer enabled IMU.startPedometer(2,irq_handler); ``` -------------------------------- ### Start Accelerometer Logging Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts logging accelerometer data with a specified output data rate and full-scale range. Defaults are 100 Hz ODR and 16 G FSR. ```C++ IMU.startAccel(100,16); ``` -------------------------------- ### Build Micro-ROS Tools and Source Environment Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Builds the Micro-ROS tools using colcon and sources the local setup script to make commands available. ```bash sudo apt install python3-colcon-common-extensions colcon build source install/local_setup.bash ``` -------------------------------- ### Initialize IMU Driver Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/src/imu/README.md Example of initializing the IMU device and serial interface. Ensure the `read_reg`, `write_reg`, `max_read`, `max_write`, and `serif_type` fields of the `inv_imu_serif_t` structure are correctly configured before calling `inv_imu_init`. ```C inv_imu_device_t imu_dev; inv_imu_serif_t imu_serif; /* Initialize serial interface */ imu_serif.read_reg = si_io_imu_read_reg; imu_serif.write_reg = si_io_imu_write_reg; imu_serif.max_read = 32768; imu_serif.max_write = 32768; imu_serif.serif_type = SERIF_TYPE; imu_serif.context = 0; /* Init device */ rc |= inv_imu_init(&imu_dev, &imu_serif, sensor_event_cb); ``` -------------------------------- ### Start Wake on Motion Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts the Wake on Motion algorithm. The handler is called when movement is detected. Any interruptable pin can be used. ```C++ volatile bool wake_up = false; void irq_handler(void) { wake_up = true; } // APEX WoM enabled, irq on pin 2 IMU.startWakeOnMotion(2,irq_handler); ``` -------------------------------- ### Start Tilt Detection Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts the tilt detection algorithm. The handler is called when a tilt event is detected. Any interruptable pin can be used. Parameters are optional. ```C++ void irq_handler(void) { Serial.println("TILT"); } // Accel ODR = 50 Hz and APEX Tilt enabled IMU.startTiltDetection(2,irq_handler); ``` -------------------------------- ### Start Gyroscope Logging Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts logging gyroscope data with a specified output data rate and full-scale range. Defaults are 100 Hz ODR and 2000 dps FSR. ```C++ IMU.startGyro(100,2000); ``` -------------------------------- ### startWakeOnMotion Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts the Wake on Motion algorithm. The provided handler is called when a movement is detected. Any interruptable pin can be used for intpin. ```APIDOC ## startWakeOnMotion ### Description Starts the Wake on Motion algorithm. The provided *handler* is called when a movement is detected. Any interuptable pin of the Arduino can be used for *intpin*. ### Parameters - **intpin** (uint8_t) - The interrupt pin to use. - **handler** (ICM42670P_irq_handler) - The function to call when a movement is detected. ### Request Example ```c++ volatile bool wake_up = false; void irq_handler(void) { wake_up = true; } // APEX WoM enabled, irq on pin 2 IMU.startWakeOnMotion(2,irq_handler); ``` ``` -------------------------------- ### startTiltDetection Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts the tilt detection algorithm. The provided handler is called when a tilt event is detected. Any interruptable pin can be used for intpin. Parameters are optional. ```APIDOC ## startTiltDetection ### Description Starts the tilt detection algorithm. The provided handler is called when a tilt event is detected. Any interruptable pin of the Arduino can be used for *intpin*. Parameters are optionals: if *handler* and *intpin* are omitted, no handler will be registered. ### Parameters - **intpin** (uint8_t) - Optional - The interrupt pin to use. - **handler** (ICM42670P_irq_handler) - Optional - The function to call when a tilt event is detected. ### Request Example ```c++ void irq_handler(void) { Serial.println("TILT"); } // Accel ODR = 50 Hz and APEX Tilt enabled IMU.startTiltDetection(2,irq_handler); ``` ``` -------------------------------- ### startPedometer Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts the pedometer algorithm. The provided handler is called when a pedometer event is detected. Any interruptable pin can be used for intpin. Parameters are optional. ```APIDOC ## startPedometer ### Description Starts the pedometer algorithm. The provided *handler* is called when a pedometer event is detected. Any interuptable pin of the Arduino can be used for *intpin*. Parameters are optionals: if *handler* and *intpin* are omitted, no handler will be registered. ### Parameters - **intpin** (uint8_t) - Optional - The interrupt pin to use. - **handler** (ICM42670P_irq_handler) - Optional - The function to call when a pedometer event is detected. ### Request Example ```c++ volatile uint8_t irq_received = 0; void irq_handler(void) { irq_received = 1; } // Accel ODR = 50 Hz and APEX Pedometer enabled IMU.startPedometer(2,irq_handler); ``` ``` -------------------------------- ### startAccel Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts logging with the accelerometer, using the specified full scale range and output data rate. Supported ODRs are: 12, 25, 50, 100, 200, 400, 800, 1600 Hz (any other value defaults to 100 Hz). Supported full scale ranges are: 2, 4, 8, 16 G (any other value defaults to 16 G). ```APIDOC ## startAccel ### Description Starts logging with the accelerometer, using the specified full scale range and output data rate. ### Method Signature `int startAccel(uint16_t odr, uint16_t fsr)` ### Parameters #### Path Parameters - **odr** (uint16_t) - Required - Output Data Rate in Hz. Defaults to 100 Hz if unsupported. - **fsr** (uint16_t) - Required - Full Scale Range in G. Defaults to 16 G if unsupported. ### Request Example ```c++ IMU.startAccel(100,16); ``` ``` -------------------------------- ### getPedometer Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Gets the pedometer algorithm output, including step count, step cadence, and activity. ```APIDOC ## getPedometer ### Description Gets the pedometer algorithm output. The pedometer algorithm returns the number of steps as *step count*, the number of steps per seconds as the *step cadence* and the walk/run *activity*. ### Parameters - **step_count** (uint16_t&) - Output - The number of steps detected. - **step_cadence** (float&) - Output - The number of steps per second. - **activity** (const char*&) - Output - The detected activity (walk/run). ### Request Example ```c++ uint16_t step_count=0; float step_cadence=0; const char* activity; IMU.getPedometer(step_count,step_cadence,activity); Serial.print("Step count:"); Serial.println(step_count); Serial.print("Step cadence:"); Serial.println(step_cadence); Serial.print("activity:"); Serial.println(activity); ``` ``` -------------------------------- ### Get Pedometer Data Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Retrieves the pedometer algorithm output, including step count, step cadence, and activity (walk/run). ```C++ uint16_t step_count=0; float step_cadence=0; const char* activity; IMU.getPedometer(step_count,step_cadence,activity); Serial.print("Step count:"); Serial.println(step_count); Serial.print("Step cadence:"); Serial.println(step_cadence); Serial.print("activity:"); Serial.println(activity); ``` -------------------------------- ### getTilt Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Gets the Tilt detection algorithm status. Returns true if a Tilt was detected since the last call to this function. ```APIDOC ## getTilt ### Description Gets the Tilt detection algorithm status. It returns true if a Tilt was detected since last call to this function. ### Parameters None ### Response - **bool** - true if a tilt was detected, false otherwise. ### Request Example ```c++ if(IMU.getTilt()) { Serial.println("Tilt"); } ``` ``` -------------------------------- ### startGyro Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Starts logging with the gyroscope, using the specified full scale range and output data rate. Supported ODRs are: 12, 25, 50, 100, 200, 400, 800, 1600 Hz (any other value defaults to 100 Hz). Supported full scale ranges are: 250, 500, 1000, 2000 dps (any other value defaults to 2000 dps). ```APIDOC ## startGyro ### Description Starts logging with the gyroscope, using the specified full scale range and output data rate. ### Method Signature `int startGyro(uint16_t odr, uint16_t fsr)` ### Parameters #### Path Parameters - **odr** (uint16_t) - Required - Output Data Rate in Hz. Defaults to 100 Hz if unsupported. - **fsr** (uint16_t) - Required - Full Scale Range in dps. Defaults to 2000 dps if unsupported. ### Request Example ```c++ IMU.startGyro(100,2000); ``` ``` -------------------------------- ### Increase Sensor ODR and Serial Baudrate Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Configure the sensor's output data rate (ODR) and the serial baudrate for monitoring. This example sets the serial baudrate to 2Mbauds and the IMU ODR for accelerometer and gyroscope to 800Hz. ```C++ // Serial at 2Mbauds Serial.begin(2000000); // IMU at 800Hz IMU.startAccel(800,16); IMU.startGyro(800,16); ``` -------------------------------- ### Get Tilt Detection Status Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Retrieves the status of the tilt detection algorithm. Returns true if a tilt was detected since the last call. ```C++ if(IMU.getTilt()) { Serial.println("Tilt"); } ``` -------------------------------- ### Enable IMU Interrupt Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Registers an interrupt for the IMU. The handler is called when an interrupt occurs. Any interruptable pin can be used. This example also shows enabling Pedometer and Tilt detection before enabling the interrupt. ```C++ // Pedometer enabled IMU.startPedometer(); // Tilt enabled IMU.startTiltDetection(); // Enable interrupt IMU.enableInterrupt(2, irq_handler); ``` -------------------------------- ### Get Sensor Data from FIFO Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Reads sensor data samples from the FIFO buffer and passes each sample to a provided callback function. Raw data can be converted using the configured FSR. Temperature conversion: (TEMP_DATA / 2) + 25. ```C++ void event_cb(inv_imu_sensor_event_t* evt) { Serial.print("AccelX:"); Serial.println(evt->accel[0]); Serial.print("AccelY:"); Serial.println(evt->accel[1]); Serial.print("AccelZ:"); Serial.println(evt->accel[2]); Serial.print("GyroX:"); Serial.println(evt->gyro[0]); Serial.print("GyroY:"); Serial.println(evt->gyro[1]); Serial.print("GyroZ:"); Serial.println(evt->gyro[2]); Serial.print("Temperature:"); Serial.println(evt->temperature); } void loop() { // Wait for interrupt to read data from fifo if(irq_received) { irq_received = 0; IMU.getDataFromFifo(event_cb); } } ``` -------------------------------- ### Get Sensor Data from Registers Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Reads raw sensor data (accelerometer, gyroscope, temperature) from registers into an event structure. Temperature can be converted using the formula (TEMP_DATA / 128) + 25. ```C++ inv_imu_sensor_event_t imu_event; IMU.getDataFromRegisters(imu_event); Serial.print("AccelX:"); Serial.println(imu_event.accel[0]); Serial.print("AccelY:"); Serial.println(imu_event.accel[1]); Serial.print("AccelZ:"); Serial.println(imu_event.accel[2]); Serial.print("GyroX:"); Serial.println(imu_event.gyro[0]); Serial.print("GyroY:"); Serial.println(imu_event.gyro[1]); Serial.print("GyroZ:"); Serial.println(imu_event.gyro[2]); Serial.print("Temperature:"); Serial.println(imu_event.temperature); ``` -------------------------------- ### begin() Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Initializes the ICM42670P sensor. This method must be called after creating an instance to ensure proper communication and usage. ```APIDOC ## int begin() ### Description Initializes all the required parameters in order to communicate and use the ICM42670P. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```C++ IMU.begin(); ``` ### Response #### Success Response (200) - **int** - Indicates the success of the initialization. (Specific return values not detailed in source) #### Response Example None ``` -------------------------------- ### Initialize ICM42670P Sensor Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Call the begin() method to execute the ICM42670P initialization routine. This method initializes all parameters required for communication and sensor usage. ```C++ IMU.begin(); ``` -------------------------------- ### Run Micro-ROS Agent Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Launches the Micro-ROS agent in a Linux window, connecting to the specified serial device with a given baudrate. Use -v6 for verbose output. ```bash source /opt/ros/iron/setup.bash source ~/microros_ws/install/local_setup.bash ros2 run micro_ros_agent micro_ros_agent serial -b 1000000 --dev /dev/tty ``` -------------------------------- ### Create and Build Micro-ROS Agent Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Generates the Micro-ROS agent workspace and builds the agent packages. ```bash ros2 run micro_ros_setup create_agent_ws.sh ros2 run micro_ros_setup build_agent.sh ``` -------------------------------- ### Monitor Micro-ROS Topics Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md In a separate Linux window, lists available ROS topics and subscribes to the '/IMU_publisher' topic to view published messages. ```bash source /opt/ros/iron/setup.bash source ~/microros_ws/install/local_setup.bash ros2 topic list ros2 topic echo /IMU_publisher ``` -------------------------------- ### ICM42670P Constructor (I2C) Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Creates an instance of the ICM42670P sensor using the I2C interface. The LSB of the I2C address can be set, and the I2C clock frequency can be specified. ```APIDOC ## ICM42670P(TwoWire &i2c, bool lsb) ### Description Creates an instance of the ICM42670P that will be accessed using the specified I2C. The LSB of the I2C address can be set to 0 or 1. I2C default clock is 400kHz. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```C++ ICM42670P IMU(Wire,0); ``` ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## ICM42670P(TwoWire &i2c, bool lsb, uint32_t freq) ### Description Same as above, specifying the I2C clock frequency (must be between 100kHz and 1MHz). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```C++ ICM42670P IMU(Wire,0,1000000); ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Enable FIFO Interrupt Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Initializes the FIFO buffer and sets up an interrupt that triggers when a specified number of samples are available. A custom handler function is called upon interrupt. ```C++ uint8_t irq_received = 0; void irq_handler(void) { irq_received = 1; } ... // Enable interrupt on pin 2 IMU.enableFifoInterrupt(2,irq_handler); ``` -------------------------------- ### ICM42670P Constructor (SPI) Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Creates an instance of the ICM42670P sensor using the SPI interface. The chip select IO number can be specified, and the SPI clock frequency can be set. ```APIDOC ## ICM42670P(SPIClass &spi, uint8_t cs_id) ### Description Creates an instance of the ICM42670P that will be accessed using the specified SPI. The IO number to be used as chip select must be specified. SPI default clock is 6MHz. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```C++ ICM42670P IMU(SPI,8); ``` ### Response #### Success Response (200) None #### Response Example None ``` ```APIDOC ## ICM42670P(SPIClass &spi, uint8_t cs_id, uint32_t freq) ### Description Same as above, specifying the SPI clock frequency (must be between 100kHz and 24MHz). ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```C++ ICM42670P IMU(SPI,8,12000000); ``` ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Create ICM42670P Instance (I2C, Custom Frequency) Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Instantiate the ICM42670P sensor for I2C communication with a specified clock frequency. The frequency must be between 100kHz and 1MHz. ```C++ ICM42670P IMU(Wire,0,1000000); ``` -------------------------------- ### Create ICM42670P Instance (I2C, Default Frequency) Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Instantiate the ICM42670P sensor for I2C communication with the LSB of the I2C address set to 0. The default I2C clock is 400kHz. ```C++ ICM42670P IMU(Wire,0); ``` -------------------------------- ### Create ICM42670P Instance (SPI, Custom Frequency) Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Instantiate the ICM42670P sensor for SPI communication with a specified clock frequency. The frequency must be between 100kHz and 24MHz. ```C++ ICM42670P IMU(SPI,8,12000000); ``` -------------------------------- ### Create ICM42670P Instance (SPI, Default Frequency) Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Instantiate the ICM42670P sensor for SPI communication, specifying the chip select pin. The default SPI clock is 6MHz. ```C++ ICM42670P IMU(SPI,8); ``` -------------------------------- ### Add Authorship Information Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/CONTRIBUTING.md Include these lines in source files to preserve authorship and copyright information for your contributions. ```c++ // Contributors: // Copyright: (c) , (c) ``` -------------------------------- ### enableFifoInterrupt Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Initializes the FIFO and the interrupt of the ICM42670P. The interrupt is triggered each time there are enough samples in the FIFO (as specified by fifo_watermark), and the provided handler is called. Any interruptable pin of the Arduino can be used for intpin. ```APIDOC ## enableFifoInterrupt ### Description Initializes the FIFO and the interrupt of the ICM42670P. The interrupt is triggered each time there are enough samples in the FIFO, and the provided handler is called. ### Method Signature `int enableFifoInterrupt(uint8_t intpin, ICM42670P_irq_handler handler, uint8_t fifo_watermark)` ### Parameters #### Path Parameters - **intpin** (uint8_t) - Required - The interrupt pin to use on the Arduino. - **handler** (ICM42670P_irq_handler) - Required - A callback function to be executed when the interrupt is triggered. - **fifo_watermark** (uint8_t) - Optional - The number of samples in the FIFO that triggers the interrupt. Defaults to a system-defined value if not provided. ### Request Example ```c++ uint8_t irq_received = 0; void irq_handler(void) { irq_received = 1; } ... // Enable interrupt on pin 2 IMU.enableFifoInterrupt(2,irq_handler); ``` ``` -------------------------------- ### getDataFromFifo Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Reads the ICM42670P sensor data samples stored in the FIFO and calls the provided event handler with the sample event as a parameter. Raw data can be translated to International System using the configured FSR for each sensor. Temperature in Degrees Centigrade = (TEMP_DATA / 2) + 25. ```APIDOC ## getDataFromFifo ### Description Reads the ICM42670P sensor data samples stored in the FIFO and calls the provided event handler with the sample event as parameter. ### Method Signature `int getDataFromFifo(ICM42670P_sensor_event_cb event_cb)` ### Parameters #### Path Parameters - **event_cb** (ICM42670P_sensor_event_cb) - Required - A callback function that will be called with the sensor event data. ### Response Example ```c++ void event_cb(inv_imu_sensor_event_t* evt) { Serial.print("AccelX:"); Serial.println(evt->accel[0]); Serial.print("AccelY:"); Serial.println(evt->accel[1]); Serial.print("AccelZ:"); Serial.println(evt->accel[2]); Serial.print("GyroX:"); Serial.println(evt->gyro[0]); Serial.print("GyroY:"); Serial.println(evt->gyro[1]); Serial.print("GyroZ:"); Serial.println(evt->gyro[2]); Serial.print("Temperature:"); Serial.println(evt->temperature); } void loop() { // Wait for interrupt to read data from fifo if(irq_received) { irq_received = 0; IMU.getDataFromFifo(event_cb); } } ``` ``` -------------------------------- ### getDataFromRegisters Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Reads the ICM42670P sensor data from registers and fills the provided event structure with sensor raw data. Raw data can be translated to International System using the configured FSR for each sensor. Temperature in Degrees Centigrade = (TEMP_DATA / 128) + 25. ```APIDOC ## getDataFromRegisters ### Description Reads the ICM42670P sensor data from registers and fills the provided event structure with sensor raw data. ### Method Signature `int getDataFromRegisters(inv_imu_sensor_event_t& evt)` ### Parameters #### Path Parameters - **evt** (inv_imu_sensor_event_t&) - Required - A reference to an `inv_imu_sensor_event_t` structure to be filled with sensor data. ### Response Example ```c++ inv_imu_sensor_event_t imu_event; IMU.getDataFromRegisters(imu_event); Serial.print("AccelX:"); Serial.println(imu_event.accel[0]); Serial.print("AccelY:"); Serial.println(imu_event.accel[1]); Serial.print("AccelZ:"); Serial.println(imu_event.accel[2]); Serial.print("GyroX:"); Serial.println(imu_event.gyro[0]); Serial.print("GyroY:"); Serial.println(imu_event.gyro[1]); Serial.print("GyroZ:"); Serial.println(imu_event.gyro[2]); Serial.print("Temperature:"); Serial.println(imu_event.temperature); ``` ``` -------------------------------- ### Set ROS Domain ID Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Exports the ROS_DOMAIN_ID environment variable and adds it to the bashrc for persistence. ```bash export ROS_DOMAIN_ID=0 echo "export ROS_DOMAIN_ID=0" >> ~/.bashrc ``` -------------------------------- ### enableInterrupt Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Registers an interrupt for the IMU. The provided handler is called when an interrupt occurs. Any interruptable pin can be used for intpin. ```APIDOC ## enableInterrupt ### Description Registers an interrupt for the IMU. The provided *handler* is called when an interrupt occurs. Any interuptable pin of the Arduino can be used for *intpin*. ### Parameters - **intpin** (uint8_t) - The interrupt pin to use. - **handler** (ICM42670P_irq_handler) - The function to call when an interrupt occurs. ### Request Example ```c++ // Pedometer enabled IMU.startPedometer(); // Tilt enabled IMU.startTiltDetection(); // Enable interrupt IMU.enableInterrupt(2, irq_handler); ``` ``` -------------------------------- ### Check Accelerometer Data Validity Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Validates if the accelerometer data within a given FIFO sample is considered valid. ```C++ void event_cb(inv_imu_sensor_event_t* evt) { if(IMU.isAccelDataValid(evt)) { ... } } ``` -------------------------------- ### Check Gyroscope Data Validity Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Validates if the gyroscope data within a given FIFO sample is considered valid. ```C++ void event_cb(inv_imu_sensor_event_t* evt) { if(IMU.isGyroDataValid(evt)) { ... } } ``` -------------------------------- ### Update Serial Interface Speed Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/examples/MicroROS_Publisher/MicroROS_README.md Modifies the default serial interface baudrate in the micro-ros-arduino library to a higher speed, such as 1Mbaud/s. ```c++ bool arduino_transport_open(struct uxrCustomTransport * transport) { Serial.begin(1000000); return true; } ``` -------------------------------- ### isAccelDataValid Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Checks if the accelerometer data in the FIFO sample is valid. ```APIDOC ## isAccelDataValid ### Description Checks if the accelerometer data in the FIFO sample is valid. ### Method Signature `bool isAccelDataValid(inv_imu_sensor_event_t* evt)` ### Parameters #### Path Parameters - **evt** (inv_imu_sensor_event_t*) - Required - A pointer to the sensor event structure containing the data to validate. ### Response Example ```c++ void event_cb(inv_imu_sensor_event_t* evt) { if(IMU.isAccelDataValid(evt)) { ... } } ``` ``` -------------------------------- ### isGyroDataValid Source: https://github.com/tdk-invn-oss/motion.arduino.icm42670p/blob/main/README.md Checks if the gyroscope data in the FIFO sample is valid. ```APIDOC ## isGyroDataValid ### Description Checks if the gyroscope data in the FIFO sample is valid. ### Method Signature `bool isGyroDataValid(inv_imu_sensor_event_t* evt)` ### Parameters #### Path Parameters - **evt** (inv_imu_sensor_event_t*) - Required - A pointer to the sensor event structure containing the data to validate. ### Response Example ```c++ void event_cb(inv_imu_sensor_event_t* evt) { if(IMU.isGyroDataValid(evt)) { ... } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.