Difference between revisions of "Getting Started with ROS on Embedded Systems/Examples/Turn detector node"

From RidgeRun Developer Connection
Jump to: navigation, search
(Create base structure for the wiki page)
 
m
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Getting Started with ROS on Embedded Systems/Head|previous=V4L2 capture node|next=Performance|keywords=detector, ROS, turn}}
+
{{Getting Started with ROS on Embedded Systems/Head|previous=Examples/V4L2 capture node|next=Examples/Proximity detector node|metakeywords=detector, ROS, turn}}
  
This page describes in detail the ROS turn detector node developed by RidgeRun on C++ language.  
+
This page describes the ROS turn detector node developed by RidgeRun on C++ language.  
  
 
__TOC__
 
__TOC__
Line 12: Line 12:
  
 
== Introduction ==
 
== 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 ==
 
== Getting the code ==
Line 22: Line 22:
  
  
== ROS turn detector node ==
+
== ROS node description ==
  
 +
=== Getting velocity data ===
  
 +
The turn detector node uses a ROS subscriber to get sensor_msgs::Imu messages<ref>http://docs.ros.org/en/noetic/api/sensor_msgs/html/msg/Imu.html</ref> 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 ===
 
=== Compilation of ROS node ===
  
 +
To compile the turn detector node, install ROS on your system ([[Getting_Started_with_ROS_on_Embedded_Systems/Getting_Started|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
 +
 +
<syntaxhighlight lang="bash">
 +
export DEVDIR=`pwd`
 +
</syntaxhighlight>
  
=== Configuration of ROS node ===
+
2. Move to the ROS workspace and build the node with catkin
  
 +
<syntaxhighlight lang="bash">
 +
cd $DEVDIR/ros_ws
 +
catkin_make
 +
</syntaxhighlight>
  
 +
3. Source the package
 +
 +
<syntaxhighlight lang="bash">
 +
source $DEVDIR/ros_ws/devel/setup.bash
 +
</syntaxhighlight>
 +
 +
4. Install the package so that it may be used by other ROS nodes (optional)
 +
 +
<syntaxhighlight lang="bash">
 +
cd $DEVDIR/ros_ws
 +
catkin_make install
 +
</syntaxhighlight>
 +
 +
=== 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 ===
 
=== Testing ROS turn detector node ===
  
 +
To launch the node:
 +
 +
<syntaxhighlight lang="bash">
 +
roslaunch turn_detector turn_detector.launch <param>:=<value>
 +
</syntaxhighlight>
  
 +
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 ==
 
== References ==
  
 
<references />
 
<references />
 
+
<br>
{{Getting Started with ROS on Embedded Systems/Foot|V4L2 capture node|Performance}}
+
{{Getting Started with ROS on Embedded Systems/Foot|Examples/V4L2 capture node|Examples/Proximity detector node}}

Latest revision as of 13:17, 8 March 2023




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