Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

polar_h10

This ROS 2 Python package provides support for Polar H10 sensor.

Upon launch the driver will configure and connect to the sensor, once connected the driver will handle incoming heart rate, ECG and accelerometer packets, publish corresponding ROS 2 messages on the topics:

  • /polarH10_AABBCCDD/heart_rate
  • /polarH10_AABBCCDD/heart_rate_contact
  • /polarH10_AABBCCDD/acceleration
  • /polarH10_AABBCCDD/ecg

where AABBCCDD is the unique sensor address.

Requirements

This package has been developed for ROS 2 Foxy.

In addition to the base ROS 2 installation, the following Python packages are required: bleak, bleakheart.

pip install bleak
pip install bleakheart

Note
To compile and run this package, you need also the polar_h10_msgs package.

Getting Started

To build the driver using ROS 2 you need to clone this package and the Polar H10 messages package into the src folder of a catkin workspace as shown below:

mkdir -p ros2_ws/src && cd ros2_ws/src
git clone https://github.com/ROSETEA-lab/polar_h10.git
git clone https://github.com/ROSETEA-lab/polar_h10_msgs.git

Next to compile the driver you need to source the ROS 2 environment into the active terminal:

source /opt/ros/jazzy/setup.bash

Finally, invoke colcon build command from within the catkin workspace as shown below:

cd ros2_ws
colcon build

Usage

Configure

The package is provided with a configuration file polar_h10/config/config.yaml where the parameters are stored.

To connect to a specific Polar H10 device, set the corresponding sensor_address parameter in the configuration file.

Note
When the driver starts, it performs a scan and lists the addresses of all the available Polar H10 sensors.

To change the time the node waits after a reconnection attempt before trying another one, set the parameter wait_for_reconnection. The default value is 5 seconds.

Note
The first time you use a sensor, you may need to pair it (for some sensors, this is done automatically). If you open the Ubuntu Settings app before starting the node, the operating system will automatically prompt you to pair the sensor if necessary. Alternatively, you can check the sensor’s status via the Bluetooth tab in the Ubuntu Settings app. If the sensor’s status is Not set up, you must initiate a connection request from the app; only once the sensor’s status has changed to Connected will you be able to start the node.

Running with a single sensor

The package provides a launch file that runs the driver for a single sensor (using the address provided by the configuration file):

ros2 launch polar_h10 polar_sensor_launch.py

In order to store the published data in a bag file you should run the bag recording in a separate terminal:

ros2 bag record

Running with multiple sensors

The package provides also a launch file that allows to run the driver for a multi sensor environment.

In this case, the sensor address defined in the configuration file is superseded by the value passed as a launch command parameter:

ros2 launch polar_h10 polar_multisensor_launch.py sensor_address:=AABBCCDD

where AABBCCDD must be substituted by the specific sensor address.

Postprocess sensor data

The package provides also two Python scripts, in the polar_h10/script folder, that allow to plot the sensor data recorded in a bag, or to convert the bag file in a Matlab file.

The script PlotData.py takes as input the name of a bag file and the address of a sensor, and plots heart rate, ECG, and acceleration data of that specific sensor. Run the script as follows

python PlotData.py bag_name AABBCCDD

substituting bag_name with the name of your bag file, and AABBCCDD with the address of your sensor.

The script bag2mat.py takes as input the name of a bag file and converts it into a mat file. The generated mat file has the same name and is placed in the same folder of the bag file.

python bag2mat.py bag_name       # substitute bag_name with the name of your bag file

In case of data from multiple sensors, the mat file contains one struct for each sensor, whose name is sensor_<sensor_address>.

About

ROS2 device driver for Polar H10 sensor device

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages