Getting Started with ROS on Embedded Systems - Examples - Turn detector node

From RidgeRun Developer Connection
Jump to: navigation, search




Previous: Examples/V4L2 capture node Index Next: Examples/Proximity detector node




This page describes the ROS turn detector node developed by RidgeRun on C++ language.

ROS versions

Distribution: Melodic Morenia [1]

Build system: catkin [2]

Introduction

When working on robotic applications, one may need to analyze what is happening to the device or robot, and act based on that. This node uses information from a gyroscope ROS topic to detect turns on a device with a configurable sensitivity, and publishes in which of the device axes a turn occurred.

Getting the code

Contact support@ridgerun.com for getting the code or any question you have.

RR Contact Us.png


ROS node description

Getting velocity data

The turn detector node uses a ROS subscriber to get sensor_msgs::Imu messages[3] from the selected ROS topic. These sensor_msgs::Imu messages provide angular velocity values that are processed whenever a message is published into the subscribed topic.

Processing the data

To reduce the noise from the physical device velocity measurements, the turn detector node uses a Moving average filter. This filter order is customizable, which provides a custom tradeoff between noise reduction and response time.

The resulting velocity values are then compared with positive and negative threshold values. These thresholds allow to detect positive and negative turns every time an angular velocity value exceeds them.

The velocity data processing can be configured to be performed in the positive and negative direction of the measurement axes (X, Y, Z) or just on some of them.

Sending turn notifications

When a turn (or multiple turns) are detected, a ROS publisher is used to publish a custom message on a ROS topic for other nodes to subscribe to this topic. Each message indicates in which axes a turn occurred and the direction of these turns.

Using the ROS node

Compilation of ROS node

To compile the turn detector node, install ROS on your system (Getting Started) and follow the next steps:

1. Export the main directory of the turn detector node to ease all the building process for the guide

export DEVDIR=`pwd`

2. Move to the ROS workspace and build the node with catkin

cd $DEVDIR/ros_ws
catkin_make

3. Source the package

source $DEVDIR/ros_ws/devel/setup.bash

4. Install the package so that it may be used by other ROS nodes (optional)

cd $DEVDIR/ros_ws
catkin_make install

Launch parameters

The following parameters are available for configuration:

  • namespace: ROS namespace for the node.
  • output: This may be set to "screen" to let the node print to console or to "log" to hide the node output.
  • publish_to: Name of the ROS topic to publish turn notification messages to.
  • subscribe_to: Name of the ROS topic that publishes the sensor_msgs::Imu messages.
  • publisher_buffer: Number of messages to buffer by the ROS publisher.
  • subscriber_buffer: Number of messages to buffer by the ROS subscriber.
  • enable_pos_x: Set to "true" to enable positive X axis detection, set to "false" to disable it.
  • enable_pos_y: Set to "true" to enable positive Y axis detection, set to "false" to disable it.
  • enable_pos_z: Set to "true" to enable positive Z axis detection, set to "false" to disable it.
  • enable_neg_x: Set to "true" to enable negative X axis detection, set to "false" to disable it.
  • enable_neg_y: Set to "true" to enable negative Y axis detection, set to "false" to disable it.
  • enable_neg_z: Set to "true" to enable negative Z axis detection, set to "false" to disable it.
  • pos_threshold_x: Positive X axis threshold velocity value to detect a turn.
  • pos_threshold_y: Positive Y axis threshold velocity value to detect a turn.
  • pos_threshold_z: Positive Z axis threshold velocity value to detect a turn.
  • neg_threshold_x: Negative X axis threshold velocity value to detect a turn.
  • neg_threshold_y: Negative Y axis threshold velocity value to detect a turn.
  • neg_threshold_z: Negative Z axis threshold velocity value to detect a turn.
  • filter_order_x: Order of moving average filter for X axis velocity values.
  • filter_order_y: Order of moving average filter for Y axis velocity values.
  • filter_order_z: Order of moving average filter for Z axis velocity values.
  • message_step: Step to skip processing messages from the subscribed topic. This allows to reduce the data processing frequency.

Testing ROS turn detector node

To launch the node:

roslaunch turn_detector turn_detector.launch <param>:=<value>

Replace <param> with any of the previous parameters that you may want to change, and <value> with the value you want to set to that parameter.

References


Previous: Examples/V4L2 capture node Index Next: Examples/Proximity detector node