Epson IMU ROS2 Driver Node

ess_sensors/g552.jpg ess_sensors/g370.jpg ess_sensors/g365.jpg


  • The Epson IMU ROS software is ROS2 C++ wrapper of a Linux C driver for communicating on a ROS2 system

  • The original Linux C driver can be found below:
  • This version of the driver software supports either UART or SPI interface connection to the Epson device
  • This code assumes that the user is familiar with building ROS2 packages using the colcon build process

  • This is NOT detailed step by step instructions describing how to build and install this ROS2 driver

  • Refer to the inside the ROS package for more detailed up-to-date info on usage or Github repository

Interface Connections

UART Connection & Configuration

  • Direct connection to UART port must be compatible with CMOS 3.3V I/O
  • Connection is also possible through a USB-UART 3.3V converter IC such as on the M-G32EV041 evaluation board

  • GPIO output for asserting RESET# pin on the IMU is optional, but recommended where possible (i.e. embedded platforms)
  • Below is an example IMU UART connection when using a Raspberry Pi based system:
    • Epson IMU

      Raspberry Pi

      EPSON_SIN Input

      RPI_GPIO_P1_8 (GPIO14/UART_TXD) Output

      EPSON_SOUT Output

      RPI_GPIO_P1_10 (GPIO15/UART_RXD) Input

      EPSON_RESET Input

      RPI_GPIO_P1_15 (GPIO22) Output *Optional, but recommended*

  • When connecting the Epson G552PRx to a ROS2 system using a RS422 UART interface, direct connection to RS422 UART port must be compatible with RS422 I/O signal levels
  • Below is an example IMU RS422 connection to a RS422 Host:
    • Epson IMU

      RS422 Host

      EPSON_TD+ Output

      HOST_RD+ Input

      EPSON_TD- Output

      HOST_RD- Input

      EPSON_RD+ Input

      HOST_TD+ Output

      EPSON_RD- Input

      HOST_TD- Output

SPI Connection & Configuration

  • Since SPI interfaces are not standard on PCs, interfacing using SPI to ROS2 is typically applicable only to embedded Linux platforms
  • Direct connection to SPI port must be compatible with CMOS 3.3V I/O
  • Connection between the host & Epson device is possible using the M-G32EV031 evaluation breakout board

  • This ROS2 driver uses the external library Unofficial wiringPi library to generate low level SPI communication & accurate time delays

    • Other libraries can be used to generate timer delays and SPI messages but requires minor changes to redirect the low-level function calls (i.e. similar to bcm2835 C library, etc)
  • Accurate timing delays are necessary to optimize throughput for high dout_rate when using the SPI interface (refer to IMU datasheets for timing specifications)

  • Below is an example IMU SPI connection when using a Raspberry Pi:
    • Epson IMU

      Raspberry Pi

      EPSON_RESET Input

      RPI_GPIO_P1_15 (GPIO22) Output

      EPSON_DRDY Output

      RPI_GPIO_P1_18 (GPIO24) Input

      EPSON_CS Input

      RPI_GPIO_P1_16 (GPIO23) Output

      EPSON_SCLK Input

      RPI_GPIO_P1_23 (GPIO11) Output

      EPSON_DOUT Output

      RPI_GPIO_P1_19 (GPIO10) Input

      EPSON_DIN Input

      RPI_GPIO_P1_21 (GPIO9) Output

SPI Configuration for Timer Delays

  • This software contains wrapper functions for time delays in millisecond and microseconds using seDelayMS() and seDelayMicroSecs(), respectively.
  • On embedded Linux platforms, these function calls may need to be redirected to platform-specific HW delay routines if not using a RaspberryPi

  • For example on RaspberryPi, the time delay functions for millisecond and microseconds is redirected to WiringPi library delay() and delayMicroseconds() function calls, respectively.

  • If a hardware delay is not available from a library, then a custom written software delay loop is possible, but not preferred

SPI Configuration for GPIO Control

  • This software uses the following 3 GPIO pins designated on the host for connection to the Epson device
    • GPIO output for asserting CS# on the Epson device (NOTE: Alternatively, pin SPI0_CE0 on the RaspberryPi can be used)

    • GPIO input for reading the logic status on the Epson device DRDY (GPIO1) pin
    • GPIO output for asserting RESET# on the Epson device
  • Connecting CS# and DRDY to the Epson device is mandatory
  • RESET# is recommended to force Hardware Reset during every IMU initialization for better robustness

ROS2 Node

Orientation Data

  • For IMU models that support quaternion output function the orientation field in Imu Message can update with valid data and publish on imu/data

  • For IMU models that do not support quaternion output function the orientation field will not update with valid data and publish on imu/data_raw

Launch File

  • The python launch files in the launch folder of this package is used to pass the init parameters to configure the Epson device at runtime using ros2 launch

  • Changes to init parameters by editing the launch file does not require rebuilding with colcon

  • Typically, the user only needs to modify imu_dout_rate & imu_filter_sel as needed based on system requirements

  • NOTE: Only use the specific IMU model launch file which matches the IMU model that the driver was built for by colcon build process

Timestamping With EXT Signal (Time Correction)

  • The Epson G3xx series IMU has a 3.3V I/O EXT (GPIO2) pin which can be connected to a cyclic external sync signal such as a GNSS 1PPS signal
  • When the init parameter time_correction_en is enabled (set to true), the driver attempts to correct the time stamp field in Imu Message using the devices internal reset counter value (measured delay since latest GNSS 1PPS)

                    description="Enables using IMU external trigger function for sending IMU samples with external trigger signal connected to IMU input pin for GPIO2/EXT",
  • The use of time_correction_en feature is expected to give a more accurate timestamp of the inertial data by minimizing the effects of link delays and host processing delays

Building & Installing ROS2 Node

  1. Place this package (including folders) into a new folder within your colcon workspace src/ folder.

  2. Modify the CMakeLists.txt to select the desired Epson IMU model that is being used in the ROS2 system.

    • NOTE: You *MUST* re-build using colcon when changing IMU models or making any changes in the CMakeLists.txt

  3. From the colcon workspace folder run colcon build to build all changed ROS2 packages located in the <colcon_workspace>/src/ folder

  4. Reload the current ROS2 environment variables that may have changed after the colcon build process.
    From the <colcon_workspace>/source install/setup.bash
  5. Modify the appropriate launch file in the launch folder to set your desired IMU init parameters for the specific IMU model that you built using colcon build

    • Typically, only the imu_dout_rate & imu_filter_sel needs to be edited

Running the ROS2 Node

  • To start the Epson IMU ROS2 driver use the appropriate launch file located in launch/ with ros2 launch

  • For example:
    <colcon_workspace>/ros2 launch ess_imu_driver2

USB-UART Latency

  • When using USB-UART bridge ICs to connect between the Linux host & Epson device, it is possible to experience higher than expected latencies or slower than expected IMU data rates

  • If your connection between the Epson IMU UART and the Linux host is by FTDI, the latency_timer setting in the FTDI driver may be large i.e. typically 16 (msec)

  • For example, the M-G32EV041 evaluation board uses an FTDI IC and driver

  • There are 3 methods listed below to reduce the impact of this latency by setting the latency_timer to 1msec

Modifying *latency_timer* by *udev* mechanism

  • udev is a device manager for Linux that can dynamically create and remove devices in *userspace* and run commands when new devices appear or for other device events

  • Create a udev rule to automatically set the latency_timer to 1 when an FTDI USB-UART device is plugged in

  • For example, below is a text file named *99-ftdi_sio.rules* that can be put in the */etc/udev/rules.d* directory
    SUBSYSTEM=="usb-serial", DRIVER=="ftdi_sio", ATTR{latency_timer}="1"

    NOTE: Requires root (sudo) access to create or copy file in */etc/udev/rules.d* NOTE: This is a more robust method because it automatically sets when device is plugged in, but affects ALL FTDI USB-UART devices on the system

Modifying *latency_timer* by *sysfs* mechanism

  • The example below reads the *latency_timer* setting for */dev/ttyUSB0* which returns 16msec.
  • Then, it sets the *latency_timer* to 1msec, and confirms it by readback.

    NOTE: May require root (sudo su) access on your system to modify

    cat /sys/bus/usb-serial/devices/ttyUSB0/latency_timer
    echo 1 > /sys/bus/usb-serial/devices/ttyUSB0/latency_timer
    cat /sys/bus/usb-serial/devices/ttyUSB0/latency_timer

Modifying *low_latency* flag using *setserial* utility

  • The example below sets the low_latency flag for /dev/ttyUSB0

  • This will have the same effect as setting the latency_timer to 1msec.

  • This can be confirmed by running the setserial command again.

  • NOTE: You may need to install setserial with sudo apt install setserial

    user@user:~$ setserial /dev/ttyUSB0
    /dev/ttyUSB0, UART: unknown, Port: 0x0000, IRQ: 0
    user@user:~$ setserial /dev/ttyUSB0 low_latency
    user@user:~$ setserial /dev/ttyUSB0
    /dev/ttyUSB0, UART: unknown, Port: 0x0000, IRQ: 0, Flags: low_latency

Technical Support

Wiki: ess_imu_driver2 (last edited 2023-12-05 00:12:48 by RChow)