.. _alleds-api: ALLeds API ========== :ref:`Overview ` | API .. seealso:: - :ref:`naoqi-sensors` - :ref:`LEDs Hardware ` - :ref:`nao-manual-meaning-of-lights` Namespace : **AL** .. code-block:: cpp #include Method list ----------- .. cpp:class:: ALLedsProxy * Methods: * :cpp:func:`ALLeds::createGroup` * :cpp:func:`ALLeds::earLedsSetAngle` * :cpp:func:`ALLeds::fade` * :cpp:func:`ALLeds::fadeListRGB` * :cpp:func:`ALLeds::fadeRGB` * :cpp:func:`ALLeds::getIntensity` * :cpp:func:`ALLeds::listGroup` * :cpp:func:`ALLeds::listGroups` * :cpp:func:`ALLeds::listLED` * :cpp:func:`ALLeds::listLEDs` * :cpp:func:`ALLeds::off` * :cpp:func:`ALLeds::on` * :cpp:func:`ALLeds::randomEyes` * :cpp:func:`ALLeds::rasta` * :cpp:func:`ALLeds::rotateEyes` * :cpp:func:`ALLeds::setIntensity` .. seealso:: * :ref:`Methods inherited from ALModule ` Methods ------- .. cpp:function:: void ALLeds::createGroup( const std::string& groupName, const std::vector& ledNames ) Makes a group name for ease of setting multiple LEDs. :param groupName: The name of the group. :param ledNames: A vector of the names of the LEDs in the group. Python: ^^^^^^^ .. code-block:: guess # Replace "127.0.0.1" with the IP of your NAO leds = ALProxy("ALLeds","127.0.0.1",9559) # Create a new group names = [ "Face/Led/Red/Left/0Deg/Actuator/Value", "Face/Led/Red/Left/90Deg/Actuator/Value", "Face/Led/Red/Left/180Deg/Actuator/Value", "Face/Led/Red/Left/270Deg/Actuator/Value"] leds.createGroup("MyGroup",names) # Switch the new group on leds.on("MyGroup") C++: ^^^^ .. code-block:: guess boost::shared_ptr leds = boost::shared_ptr(new ALLedsProxy(getParentBroker())); // Create a new group std::vector names; names.push_back("Face/Led/Red/Left/0Deg/Actuator/Value"); names.push_back("Face/Led/Red/Left/90Deg/Actuator/Value"); names.push_back("Face/Led/Red/Left/180Deg/Actuator/Value"); names.push_back("Face/Led/Red/Left/270Deg/Actuator/Value"); leds.createGroup("MyGroup",names); // Switch the new group on leds.on("MyGroup"); .. cpp:function:: void ALLeds::earLedsSetAngle( const int& degrees, const float& duration, const bool& leaveOnAtEnd ) An animation to show a direction with the ears. :param degrees: The angle you want to show in degrees (int). 0 is up, 90 is forwards, 180 is down and 270 is back. :param duration: The duration in seconds of the animation. :param leaveOnAtEnd: If true the last led is left on at the end of the animation. .. cpp:function:: void ALLeds::fade( const std::string& name, const float& intensity, const float& duration ) Sets the intensity of a LED or Group of LEDs within a given time. :param name: The name of the LED or Group. :param intensity: The intensity of the LED or Group (a value between 0 and 1). :param duration: The duration of the fade in seconds :download:`alleds_fade.cpp ` .. literalinclude:: /samples/cpp/alleds/alleds_fade.cpp :language: cpp :download:`alleds_fade.py ` .. literalinclude:: /samples/python/alleds/alleds_fade.py :language: py .. cpp:function:: void ALLeds::fadeListRGB( const std::string& name, const AL::ALValue& rgbList, const AL::ALValue& timeList ) Chain a list of color for a device, as the motion.doMove command. :param name: The name of the LED or Group. :param rgbList: List of RGB led value, RGB as seen in hexa-decimal: 0x00RRGGBB. :param timeList: List of time to go to given intensity. .. cpp:function:: void ALLeds::fadeRGB( const std::string& name, const int& rgb, const float& duration ) Sets the intensity of a led. If the name matches an RGB led, all channels are set to the same value. :param name: The name of the LED or Group. :param rgb: The RGB value led, RGB as seen in hexa-decimal: 0x00RRGGBB. :param duration: Time used to fade in seconds. .. cpp:function:: AL::ALValue ALLeds::getIntensity(const std::string& name) Gets the intensity of a LED or device :param name: The name of the LED or Group. :return: The intensity of the LED or Group. .. cpp:function:: std::vector ALLeds::listGroup(const std::string& groupName) Lists the devices in the group. :param groupName: The name of the Group. :return: A vector of string device names. Python: ^^^^^^^ .. code-block:: guess # Replace "127.0.0.1" with the IP of your NAO leds = ALProxy("ALLeds","127.0.0.1",9559) # Print the names of all the groups print(leds.listGroup("FaceLedsLeftExternal")) C++: ^^^^ .. code-block:: guess boost::shared_ptr leds = boost::shared_ptr(new ALLedsProxy(getParentBroker())); // Print the names of all the devices in the group std::vector deviceNames = leds.listGroup("FaceLedsLeftExternal"); for(unsigned int i=0; i < deviceNames.size(); i++) { std::cout << deviceNames.at(i) << std::endl; } .. cpp:function:: std::vector ALLeds::listGroups() Lists available group names. :return: A vector of group names. .. cpp:function:: std::vector ALLeds::listLED(const std::string& arg1) Lists the devices aliased by a short LED name. :param arg1: arg :return: A vector of device names. .. cpp:function:: std::vector ALLeds::listLEDs() Lists the short LED names. :return: A vector of LED names. .. cpp:function:: void ALLeds::off(const std::string& name) Switch to a minimum intensity a LED or Group of LEDs. :param name: The name of the LED or Group. samples/cpp/alleds/alleds_off.cpp .. literalinclude:: /samples/cpp/alleds/alleds_off.cpp :language: cpp samples/python/alleds/alleds_off.py .. literalinclude:: /samples/python/alleds/alleds_off.py :language: py .. cpp:function:: void ALLeds::on(const std::string& name) Switch to a maximum intensity a LED or Group of LEDs. :param name: The name of the LED or Group. :download:`alleds_on.cpp ` .. literalinclude:: /samples/cpp/alleds/alleds_on.cpp :language: cpp :download:`alleds_on.py ` .. literalinclude:: /samples/python/alleds/alleds_on.py :language: py .. cpp:function:: void ALLeds::randomEyes(const float& duration) Launch a random animation in eyes :param duration: Approximate duration of the animation in seconds. .. cpp:function:: void ALLeds::rasta(const float& duration) Launch a green/yellow/red rasta animation on all body. :param duration: Approximate duration of the animation in seconds. samples/cpp/alleds/alleds_rasta.cpp .. literalinclude:: /samples/cpp/alleds/alleds_rasta.cpp :language: cpp samples/python/alleds/alleds_rasta.py .. literalinclude:: /samples/python/alleds/alleds_rasta.py :language: py .. cpp:function:: void ALLeds::rotateEyes( const int& rgb, const float& timeForRotation, const float& totalDuration ) Launch a rotation using the leds of the eyes. :param rgb: the RGB value led, RGB as seen in hexa-decimal: 0x00RRGGBB. :param timeForRotation: Approximate time to make one turn. :param totalDuration: Approximate duration of the animation in seconds. .. cpp:function:: void ALLeds::setIntensity( const std::string& name, const float& intensity ) Sets the intensity of a LED or Group of LEDs. :param name: The name of the LED or Group. :param intensity: The intensity of the LED or Group (a value between 0 and 1). Python: ^^^^^^^ .. code-block:: guess # Replace "127.0.0.1" with the IP of your NAO leds = ALProxy("ALLeds","127.0.0.1",9559) # Turn the red LED of the left foot half on leds.setIntensity("LFoot/Led/Red/Actuator/Value", 0.5) # Turn the green face LEDs half on leds.setIntensity("LeftFaceLedsGreen", 0.5) C++: ^^^^ .. code-block:: guess boost::shared_ptr leds = boost::shared_ptr(new ALLedsProxy(getParentBroker())); // Turn the red LED of the left foot half on leds->setIntensity("LFoot/Led/Red/Actuator/Value", 0.5f); // Turn the green face LEDs half on leds->setIntensity("LeftFaceLedsGreen", 0.5f);