Skip to content

Commit

Permalink
add more info on eye led indexes and add some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ijnek committed Jun 13, 2021
1 parent fdceb7d commit 67618a4
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 38 deletions.
56 changes: 56 additions & 0 deletions eye-led-indexes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. _eye_led_indexes:

Eye Led Indexes
###############

.. image:: images/eye_leds.png

The following list is from ``EyeLeds.msg``:

.. code-block:: cpp
int32 L0=0
int32 L1=1
int32 L2=2
int32 L3=3
int32 L4=4
int32 L5=5
int32 L6=6
int32 L7=7
int32 R0=8
int32 R1=9
int32 R2=10
int32 R3=11
int32 R4=12
int32 R5=13
int32 R6=14
int32 R7=15
int32 NUM_EYE_LEDS=16
Setting color for one led
**************************

.. code-block:: cpp
// Set led L0 to red
nao_interfaces::msg::EyeLeds eye_leds;
eye_leds.leds[nao_interfaces::msg::EyeLeds::L0].r = 1.0;
Setting color for all leds
**************************

To populate all LEDs to be a certain color, you can iterate over ``nao_interfaces::msg::EyeLeds::NUM_EYE_LEDS``.

.. code-block:: cpp
// Set all leds to yellow
nao_interfaces::msg::EyeLeds eye_leds;
std_msgs/ColorRGBA yellow;
yellow.r = 1.0;
yellow.g = 1.0;
for (unsigned i = 0; i < nao_interfaces::msg::EyeLeds::NUM_EYE_LEDS; ++i)
{
eye_leds.leds[i] = yellow;
}
1 change: 1 addition & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The :ref:`joint_indexes` page explains how to handle NAO joints in detail.

msgs
joint-indexes
eye-led-indexes
related-ros2-packages

.. _ROS2 interface package: https://docs.ros.org/en/foxy/Tutorials/Custom-ROS2-Interfaces.html
40 changes: 23 additions & 17 deletions joint-indexes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,7 @@
Joint Indexes
#############

The list at the bottom shows the joint indexes copied from `Joints.msg`.

An example of accessing an angle for a specific joint:

.. code-block:: cpp
joints.angles[nao_interfaces::msg::Joints::HEADYAW]
``nao_interfaces::msg::Joints::NUM_JOINTS`` can be for iterating over all joints, as following:

.. code-block:: cpp
for (unsigned i = 0; i < nao_interfaces::msg::Joints::NUMJOINTS; ++i)
{
// do something for each joint
}
The following list are the joint indexes copied from ``Joints.msg``:

.. code-block:: cpp
Expand Down Expand Up @@ -47,4 +32,25 @@ An example of accessing an angle for a specific joint:
int32 RWRISTYAW=22
int32 LHAND=23
int32 RHAND=24
int32 NUMJOINTS=25
int32 NUMJOINTS=25
Accessing a joint angle
***********************

An example of accessing an angle for a specific joint:

.. code-block:: cpp
joints.angles[nao_interfaces::msg::Joints::HEADYAW]
Iterating over all joints
*************************

``nao_interfaces::msg::Joints::NUM_JOINTS`` can be used for iterating over all joints, as following:

.. code-block:: cpp
for (unsigned i = 0; i < nao_interfaces::msg::Joints::NUMJOINTS; ++i)
{
// do something for each joint
}
25 changes: 4 additions & 21 deletions msgs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,12 @@ Touch
EyeLeds
*******

Message identifying colors for each RGB LED in the NAO's eyes.
.. image:: images/eye_leds.png

**Expect ranges for R, G and B are 0.0 - 1.0. The alpha value (A) is ignored.**
Message identifying colors for each of the 16 RGB Leds in the NAO's eyes. **Expected range for R, G and B are 0.0 - 1.0. The alpha (A) is not used.**

.. image:: images/eye_leds.png
See :ref:`eye_led_indexes` to see which indexes correspond to which led in the eyes.

.. code-block:: cpp
int32 L0=0
int32 L1=1
int32 L2=2
int32 L3=3
int32 L4=4
int32 L5=5
int32 L6=6
int32 L7=7
int32 R0=8
int32 R1=9
int32 R2=10
int32 R3=11
int32 R4=12
int32 R5=13
int32 R6=14
int32 R7=15
std_msgs/ColorRGBA[16] leds
std_msgs/ColorRGBA[16] leds // r, g, b should be 0.0 - 1.0. a is ignored

0 comments on commit 67618a4

Please sign in to comment.