NAOqi Sensors - Overview | API
See also
Namespace : AL
#include <alproxies/alledsproxy.h>
As any module, this module inherits methods from ALModule API. It also has the following specific methods:
Makes a group name for ease of setting multiple LEDs.
Parameters: |
|
---|
# 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")
boost::shared_ptr<ALLedsProxy> leds = boost::shared_ptr<ALLedsProxy>(new ALLedsProxy(getParentBroker()));
// Create a new group
std::vector<std::string> 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");
An animation to show a direction with the ears.
Parameters: |
|
---|
Sets the intensity of a LED or Group of LEDs within a given time.
Parameters: |
|
---|
#include <iostream>
#include <alproxies/alledsproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: leds_ledsfade pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Create a proxy to ALLeds.
AL::ALLedsProxy leds(pIp);
// Example showing how to fade the left eye group to mid-intensity
std::string name = "EarLeds";
float intensity = 0.5f;
float duration = 1.0f;
leds.fade(name, intensity, duration);
std::cout << "Faded " << name << " to " << intensity << " in " << duration
<< std::endl;
return 0;
}
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python leds_fade.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
proxy = ALProxy("ALLeds", IP, PORT)
except Exception,e:
print "Could not create proxy to ALLeds"
print "Error was: ",e
sys.exit(1)
# Example showing how to fade the ears group to mid-intensity
name = 'EarLeds'
intensity = 0.5
duration = 1.0
proxy.fade(name, intensity, duration)
Chain a list of color for a device, as the motion.doMove command.
Parameters: |
|
---|
Sets the intensity of a led. If the name matches an RGB led, all channels are set to the same value.
Parameters: |
|
---|
Gets the intensity of a LED.
Parameters: |
|
---|---|
Returns: | The intensity of the LED. |
Lists the devices in the group.
Parameters: |
|
---|---|
Returns: | A vector of string device names. |
# 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"))
boost::shared_ptr<ALLedsProxy> leds = boost::shared_ptr<ALLedsProxy>(new ALLedsProxy(getParentBroker()));
// Print the names of all the devices in the group
std::vector<std::string> deviceNames = leds.listGroup("FaceLedsLeftExternal");
for(unsigned int i=0; i < deviceNames.size(); i++) {
std::cout << deviceNames.at(i) << std::endl;
}
Lists available group names.
Returns: | A vector of group names. |
---|
Lists the devices aliased by a short LED name.
Parameters: |
|
---|---|
Returns: | A vector of device names. |
Lists the short LED names.
Returns: | A vector of LED names. |
---|
Switch to a minimum intensity a LED or Group of LEDs.
Parameters: |
|
---|
samples/cpp/alleds/alleds_off.cpp
#include <iostream>
#include <alproxies/alledsproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: leds_off pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Create a proxy to ALLeds.
AL::ALLedsProxy leds(pIp);
// Example showing how to switch off a group
std::string name = "FaceLeds";
leds.off(name);
std::cout << "LEDs from " << name << " group are now off" << std::endl;
return 0;
}
samples/python/alleds/alleds_off.py
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python leds_off.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
proxy = ALProxy("ALLeds", IP, PORT)
except Exception,e:
print "Could not create proxy to ALLeds"
print "Error was: ",e
sys.exit(1)
# Example showing how to switch off a group
name = 'FaceLeds'
proxy.off(name)
Switch to a maximum intensity a LED or Group of LEDs.
Parameters: |
|
---|
#include <iostream>
#include <alproxies/alledsproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage: leds_on pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Create a proxy to ALLeds.
AL::ALLedsProxy leds(pIp);
// Example showing how to switch on a group
std::string name = "FaceLeds";
leds.on(name);
std::cout << "LEDs from " << name << " group are now on." << std::endl;
return 0;
}
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python leds_on.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
proxy = ALProxy("ALLeds", IP, PORT)
except Exception,e:
print "Could not create proxy to ALLeds"
print "Error was: ",e
sys.exit(1)
# Example showing how to switch on a group
name = 'FaceLeds'
proxy.on(name)
sys.exit(0)
Launch a random animation in eyes
Parameters: |
|
---|
Launch a green/yellow/red rasta animation on all body.
Parameters: |
|
---|
samples/cpp/alleds/alleds_rasta.cpp
#include <iostream>
#include <alproxies/alledsproxy.h>
int main(int argc, char **argv)
{
if (argc < 2) {
std::cerr << "Usage 'leds_on pIp" << std::endl;
return 1;
}
const std::string pIp = argv[1];
// Create a proxy to ALLeds.
AL::ALLedsProxy leds(pIp);
// Example showing a two seconds rasta animation
float duration = 2.0f;
leds.rasta(duration);
std::cout << "LED animation complete." << std::endl;
return 0;
}
samples/python/alleds/alleds_rasta.py
# -*- encoding: UTF-8 -*-
import sys
from naoqi import ALProxy
if (len(sys.argv) < 2):
print "Usage: 'python leds_rasta.py IP [PORT]'"
sys.exit(1)
IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
PORT = sys.argv[2]
try:
proxy = ALProxy("ALLeds", IP, PORT)
except Exception,e:
print "Could not create proxy to ALLeds"
print "Error was: ",e
sys.exit(1)
# Example showing a one second rasta animation
duration = 1.0
proxy.rasta(duration)
Launch a rotation using the leds of the eyes.
Parameters: |
|
---|
Sets the intensity of a LED or Group of LEDs.
Parameters: |
|
---|
# 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)
boost::shared_ptr<ALLedsProxy> leds = boost::shared_ptr<ALLedsProxy>(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);