Send data to a NAO

It is possible to send 3 kind of data:

  • A 8 bits unsigned integer (0-255)
  • A 32 bits unsigned integer (0-4294967295)
  • An IP address (eg "192.168.0.56")

To do that use respectively the 3 following bound methods:

/** * Function sendIpAddress is called to send an IP address * @param pIP: string containing an IP address (eg "127.0.15.129") */ void sendIpAddress(const std::string& pIP); /** * Function send8 is called to send 1 octet * @param pOctet : Integer containing an octet */ void send8(const int& pOctet); /** * Function send32 is called to send 4 octets * @param pData_IR: string containing a 4 octet value (be careful it's a string) */ void send32(const std::string& pData_IR); // OR /** * Function send32 is called to send 4 octets * @param pOctet1 : 1st octet of the 32 bits value * @param pOctet2 : 2nd octet of the 32 bits value * @param pOctet3 : 3rd octet of the 32 bits value * @param pOctet4 : 4th octet of the 32 bits value */ void send32(const int& pOctet1, const int& pOctet2, const int& pOctet3, const int& pOctet4);

Python example to send successively the 3 kinds of data:

import naoqi from naoqi import ALProxy import time lirc=ALProxy("ALInfrared","127.0.0.1",9559) # change IP with NAO IP lirc.sendIpAddress("127.0.0.1") # Send IP address time.sleep(0.5) # Delay necessary for a reliable transfer lirc.send8(42) # Send the number 42 time.sleep(0.5) lirc.send32(0x42, 0x2A, 0x13, 0x0D) # Send four 8 bits numbers time.sleep(0.5) lirc.send32("36757575") # Send one 32 bits number

Warning:

It takes around 0.5 seconds to send an octet and around 2 seconds to send 4 octets or an IP address.

Warning:

A delay (~0.5'') between every sending is necessary for a reliable transfer.

After sending a data, the corresponding data will be saved in ALMemory:

Event / Data Type ALMemory Description
Data int "Device/SubDeviceList/IR/LIRC/Data/IP/Actuator/Value/" IP address
Data int "Device/SubDeviceList/IR/LIRC/Data/uInt8/Byte/Actuator/Value/" Unsigned 8 bits integer
Data int "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte1/Actuator/Value/" 1st octet of the 32 bits unsigned integer
Data int "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte2/Actuator/Value/" 2nd octet of the 32 bits unsigned integer
Data int "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte3/Actuator/Value/" 3rd octet of the 32 bits unsigned integer
Data int "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte4/Actuator/Value/" 4th octet of the 32 bits unsigned integer





Copyright © 2010 Aldebaran-Robotics - All rights reserved