Skip to content

adityakamath/sensehat_ros

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sensehat_ros

GitHub License X (formerly Twitter) Follow

ROS 2 package for the Raspberry Pi Sense HAT which includes an accelerometer, a gyroscope, a magnetometer, a barometric pressure sensor, a humidity sensor, a 5-button joystick and a 8x8 LED matrix. The Sensor HAT v2 also includes a color and brightness sensor. This package provides support for both versions.

Note: This implementation is a bit over-engineered, as I have been experimenting with ROS 2 managed/lifecycle nodes using Python.

Implementation details

  • sensehat_publisher: This executable uses the python-sense-hat library to access data from the Sense HAT over multiple I2C channels. This node publishes messages from the IMU sensors (accelerometer, gyroscope, magnetometer), the magnetometer only, the pressure sensor, the humidity sensor, and the 5-button joystick respectively. Additionally, it uses the pressure sensor and humidity sensor to calculate the ambient temperature and publishes them as topics. Finally, if the Sense HAT v2 is used, the color sensor measurements are also published. Each sensor/publisher can be enabled or disabled using boolean parameters. When everything is enabled, the following topics are published:

  • sensehat_display_handler: This executable provides a handler for displaying different images/animations based on different subscribed topics on the 8x8 LED matrix. This is still a work in progress.

  • sensehat_launch.py: This is the launch file that launches sensehat_publisher as a lifecycle node, loads its parameters, and then configures and activates it. The lifecycle node is first initialized, and then set to 'configure' from the launch file. When the 'inactive' state is reached, the registered event handler activates the node. This launch file has the following arguments:

    • ns: Namespace of the system (default: '')
    • frame_id: Frame ID of the Sense HAT (default: sensehat_frame)
    • config_path: Path to the config file, if called from another package/launch file (default: config/sensehat_config.yaml)

Parameters

  • en_imu: Enable IMU publisher - Gyroscope, Accelerometer, Magnetometer (Default: True)
  • en_mag: Enable Magnetometer publisher (Default: True)
  • en_pressure: Enable Pressure publisher (Default: True)
  • en_humidity: Enable Humidity publisher (Default: True)
  • en_joy: Enable Joystick publisher (Default: False)
  • en_color: Enable Color publisher, if v2 (Default: False)
  • frame_id: Sense HAT Frame ID (Default: sensehat_frame)
  • timer_period: Time period of the Timer in seconds (Default: 0.02)
  • imu_transform: Transform IMU coordinate system from NED to ENU (Default: True)
  • joy_once: If True, sets Joy output once when pressed. If False, sets Joy output continuously as the button is pressed. (Default: True)
  • color_gain: Sets the sensitivity of the Color sensor [1, 4, 16, 60] (Default: 60)
  • color_int_cycles: Sets the time that the the sensor takes between measuring the light times 2.4 milliseconds [1, 256] (Default: 64)

How to use

  • Stack the Sense HAT onto the RPi GPIO
  • Follow the Raspberry Pi Setup and the Sense HAT Setup, forked from the EnvTrackerNode repository (I made a copy just in case the documentation in this repo is updated)
  • Clone this repository in a ROS 2 workspace. Check the sensor_params.yaml file in the config directory and sensehat_launch.py, and make any necessary changes.
  • Calibrate the IMU using the RTIMULibCal tool (RTIMULib must already be cloned to your device from the Sense HAT Setup steps from earlier). Follow the Hardware Calibration steps and generate a RTIMULib.ini calibration file. OR you can use my calibration file, which is located in the config folder.
  • Copy this calibration file to ~/.config/sense_hat/RTIMULib.ini. If this path does not exist, simply create it or run the launch file which will generate a default calibration file in this location.
  • Build the package and run the launch file: ros2 launch sensehat_ros sensehat_launch.py
  • Launch arguments can be added like this: ros2 launch sensehat_ros sensehat_launch.py frame_id:='sensehat'

About

ROS 2 package for RPi/AstroPi Sense HAT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages