Set

Overview

This is the basic command to send one or more order (timed command) to an actuator.

It could also be an alias name instead of an actuator name (see below). In this case, every actuator in the alias will be updated with the same commands.

/** * Call this function to send a timed-command list to an actuator * Command send from an other module * * @param pCommands ALValue with all data * pCommands[0] has the actuator name (with or without the base name) * pCommands[1] Is the kind of update: * "Merge": Just add new timed command. * "ClearAll": Delete all timed command before adding this one. * "ClearAfter": Delete all commands that are after the time of the 1st one on the list (the soonest) * "ClearBefore": Delete all commands that are before the time of the last one on the list (the oldest) * pCommands[2][x] is a list of x timed-command * pCommands[2][x][0] is the float command (offset and gain are then used) * pCommands[2][x][1] is the DCM Time for the command to be applied * pCommands[2][x][2] is the optional importance level. Minimum if not specified * */ void DCM::set(ALValue& pCommands)

Kind of update

As you can see, there are 4 possible kinds of updates: "ClearAll", "Merge", "ClearAfter" and "ClearBefore".

These are used to specify to the DCM how new commands will be added when timed commands are already in its internal buffer for the same actuator (sent by an other module or by the same module).

  • "ClearAll" is the simple one. Formers commands (for this actuator) are simply deleted and changed by the new ones. Use clearAll with no new commands to delete everything. The last sent value will be kept.

    ClearAll

  • "Merge" is also simple: new commands are just mixed with formers ones (Be careful if there is two commands at exactly the same time):

    Merge

  • "ClearAfter" means that every former command that is after the first new command will be deleted:

    ClearAfter

  • "ClearBefore" means that every former command that is before the last new command will be deleted:

    ClearBefore

Importance level

The importance level is not implemented right now. Please set it to "0" if you use it.

Example of use

Python:

import naoqi from naoqi import ALProxy dcm = ALProxy("DCM","127.0.0.1",9559) dcm.set(["ChestBoard/Led/Red/Actuator/Value", "Merge", [[1.0,dcm.getTime(10000)]] ])

C++

// Program running in a module. Do not forget the #include "dcmproxy.h" try { DCMProxy* dcm = new DCMProxy(pBroker); ALValue commands; commands.arraySetSize(3); commands[0] = string("ChestBoard/Led/Red/Actuator/Value"); commands[1] = string("Merge"); commands[2].arraySetSize(1); commands[2][0].arraySetSize(2); commands[2][0][0] = 1.0; commands[2][0][1] = dcm->getTime(10000); dcm->set(commands); } AL_CATCH_ERR(return false;);

The new value for the red LED in the chest will be 1.0 in 10s. The DCM will interpolate with the currently sent value.

Python:

import naoqi from naoqi import ALProxy dcm = ALProxy("DCM","127.0.0.1",9559) dcm.set([ "ChestBoard/Led/Red/Actuator/Value", "ClearAll", [ [1.0, dcm.getTime(2000) ], [0.0, dcm.getTime(4000) ], [1.0, dcm.getTime(6000) ], [0.0, dcm.getTime(8000) ] ] ])

C++

// Program running in a module. Do not forget the #include "dcmproxy.h" try { DCMProxy* dcm = new DCMProxy(pBroker); ALValue commands; commands.arraySetSize(3); commands[0] = string("ChestBoard/Led/Red/Actuator/Value"); commands[1] = string("ClearAll"); commands[2].arraySetSize(4); commands[2][0].arraySetSize(2); commands[2][0][0] = 1.0; commands[2][0][1] = dcm->getTime(2000); commands[2][1].arraySetSize(2); commands[2][1][0] = 0.0; commands[2][1][1] = dcm->getTime(4000); commands[2][2].arraySetSize(2); commands[2][2][0] = 1.0; commands[2][2][1] = dcm->getTime(6000); commands[2][3].arraySetSize(2); commands[2][3][0] = 0.0; commands[2][3][1] = dcm->getTime(8000); dcm->set(commands); } AL_CATCH_ERR(return false;);

This is a list of 4 commands sent to the green chest LED.

In 2sec, the LED value will be at 1.0. In 4sec, it will be at 0. In 6sec at 1.0 again, and back to 0 in 8sec.

So you will see a soft increase/decrease of LED twice in 80s.

Note:

All examples here use dcm.getTime() to get all time for timed-command request. This is just an example, and there are better ways to use it. For example, you can just do one dcm.getTime() at startup and after increment the integer value for each ms. Or you can use the CPU clock if you have a module running on the robot.

Python:

import naoqi from naoqi import ALProxy dcm = ALProxy("DCM","127.0.0.1",9559) dcm.set([ "US/Actuator/Value", "ClearAll", [ [64.0+4.0, dcm.getTime(0) ], [32.0 , dcm.getTime(3000) ] ] ])

C++

// Program running in a module. Do not forget the #include "dcmproxy.h" try { DCMProxy* dcm = new DCMProxy(pBroker); ALValue commands; commands.arraySetSize(3); commands[0] = string("US/Actuator/Value"); commands[1] = string("ClearAll"); commands[2].arraySetSize(2); commands[2][0].arraySetSize(2); commands[2][0][0] = 68.0; commands[2][0][1] = dcm->getTime(0); commands[2][1].arraySetSize(2); commands[2][1][0] = 32.0; commands[2][1][1] = dcm->getTime(3000); dcm->set(commands); } AL_CATCH_ERR(return false;);

This will make measurement every 100 ms on both side (Left and Right) for 3 seconds.

For each measure 10 echoes are placed in ALmemory for both side in:

Device/SubDeviceList/US/Left/Sensor/Value, Device/SubDeviceList/US/Right/Sensor/Value,

Device/SubDeviceList/US/Left/Sensor/Value1, Device/SubDeviceList/US/Right1/Sensor/Value1,

Device/SubDeviceList/US/Left/Sensor/Value2, Device/SubDeviceList/US/Right1/Sensor/Value2,...





Copyright © 2010 Aldebaran-Robotics - All rights reserved