本文整理汇总了C++中ALValue类的典型用法代码示例。如果您正苦于以下问题:C++ ALValue类的具体用法?C++ ALValue怎么用?C++ ALValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ALValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Recovering_state_code
void Kick::Recovering_state_code(void)
{
//BUILDER COMMENT. DO NOT REMOVE. begin Recovering_state_code
ALValue path;
path.arraySetSize(6);
path[0] = 0.0;
path[2] = 0.0;
path[3] = 0.0;
path[4] = 0.0;
path[5] = 0.0;
if(foot == LEFT)
{
path[1] = 0.05;
pmotion->positionInterpolation("LLeg", 2, path, 63, 1.5, false);
path[1] = -0.05;
pmotion->positionInterpolation("RLeg", 2, path, 63, 1.5, false);
}else
{
path[1] = -0.05;
pmotion->positionInterpolation("RLeg", 2, path, 63, 1.5, false);
path[1] = 0.05;
pmotion->positionInterpolation("LLeg", 2, path, 63, 1.5, false);
}
path[0] = 0.0;
path[1] = 0.00;
path[2] = -0.03;
path[3] = 0.0;
path[4] = 0.0;
path[5] = 0.0;
pmotion->positionInterpolation("Torso", 2, path, 63, 1.0, false);
//BUILDER COMMENT. DO NOT REMOVE. end Recovering_state_code
}
示例2: move_joints
void APIDemonstration::move_joints(const ALValue& joints,
const ALValue& target_angles,
const ALValue& target_times,
const bool &restore_pos,
const std::string& phrase,
const float& phrase_lag) {
try{
bool useSensors = false;
std::vector<float> angles_before = motion_proxy.getAngles(joints, useSensors);
std::vector<float> stiffness_before = motion_proxy.getStiffnesses(joints);
int n = joints.isArray() ? joints.getSize() : 1;
motion_proxy.setStiffnesses(joints, std::vector<float>(n, 1.0));
bool isAbsolute = true;
int id = motion_proxy.post.angleInterpolation(joints, target_angles, target_times, isAbsolute);
qi::os::sleep(phrase_lag);
if (phrase != "") {
TTS_proxy.setLanguage("English");
TTS_proxy.post.say(phrase);
}
if (restore_pos)
motion_proxy.angleInterpolation(joints, angles_before, std::vector<float>(n, 1.0), true);
motion_proxy.setStiffnesses(joints, stiffness_before);
motion_proxy.wait(id, 0);
}
catch (const ALError& e) {
std::cerr << "Caught exception: " << e.what() << std::endl;
}
}
示例3: cvCreateImage
/**
* saveImageRemote : test remote image
* @param pName path of the file
*/
void vision::testRemote(){
//Now you can get the pointer to the video structure.
ALValue results;
results.arraySetSize(7);
try
{
results = ( camera->call<ALValue>( "getImageRemote", name ) );
}catch( ALError& e)
{
log->error( "vision", "could not call the getImageRemote method of the NaoCam module" );
}
if (results.getType()!= ALValue::TypeArray) return;
const char* dataPointerIn = static_cast<const char*>(results[6].GetBinary());
int size = results[6].getSize();
//You can get some informations of the image.
int width = (int) results[0];
int height = (int) results[1];
int nbLayers = (int) results[2];
int colorSpace = (int) results[3];
long long timeStamp = ((long long)(int)results[4])*1000000LL + ((long long)(int)results[5]);
// now you create an openCV image and you save it in a file.
IplImage* image = cvCreateImage( cvSize( width, height ), 8, nbLayers );
// image->imageData = ( char* ) imageIn->getFrame();
image->imageData = ( char* ) dataPointerIn;
std::string pName = "aaa";
//const char* imageName = ( pName + DecToString(results[4]) + ".jpg").c_str();
const char* imageName = ( pName + "test" + ".jpg").c_str();
printf("imageName %s\n", imageName);
cvSaveImage( imageName, image );
printf("image saved\n");
try
{
results = ( camera->call<ALValue>( "releaseImage", name ) );
}catch( ALError& e)
{
log->error( "vision", "could not call the releaseImage method of the NaoCam module" );
}
printf("image memory released\n");
// cvReleaseImage( &image );
cvReleaseImageHeader(&image);
printf("image released\n");
printf("testRemote finished\n");
}
示例4: qiLogInfo
void APIDemonstration::face_detected() {
qiLogInfo("module.example") << "Executing callback method on face_detected event" << std::endl;
ALCriticalSection section(fCallbackMutexFaceDetection);
ALValue data = memory_proxy.getData("FaceDetected");
if (data.getSize() > 0) {
TTS_proxy.say("Yep");
b_face_detected = true;
}
}
示例5: initPosition
/**
* @brief
*/
void oru_walk::initPosition()
{
/// @attention Hardcoded parameter!
unsigned int init_time = 1200;
ALValue initPositionCommands;
initPositionCommands.arraySetSize(6);
initPositionCommands[0] = string("jointActuator");
initPositionCommands[1] = string("ClearAll");
initPositionCommands[2] = string("time-separate");
initPositionCommands[3] = 0;
initPositionCommands[4].arraySetSize(1);
initPositionCommands[5].arraySetSize(JOINTS_NUM);
for (int i = 0; i < JOINTS_NUM; i++)
{
initPositionCommands[5][i].arraySetSize(1);
}
initJointAngles (initPositionCommands[5]);
for (int i = 0; i < LOWER_JOINTS_NUM; i++)
{
ref_joint_angles[i] = initPositionCommands[5][i][0];
}
// set time
try
{
initPositionCommands[4][0] = dcm_proxy->getTime(init_time);
}
catch (const ALError &e)
{
ORUW_THROW_ERROR("Error on DCM getTime : ", e);
}
// send commands
try
{
dcm_proxy->setAlias(initPositionCommands);
}
catch (const AL::ALError &e)
{
ORUW_THROW_ERROR("Error with DCM setAlias : ", e);
}
qi::os::msleep(init_time);
qiLogInfo ("module.oru_walk", "Execution of initPosition() is finished.");
}
示例6: Execute
int Sensors::Execute()
{
if(firstrun)
{
//Starting US Sensors
ALValue commands;
commands.arraySetSize(3);
commands[0] = string("Device/SubDeviceList/US/Actuator/Value");
commands[1] = string("Merge");
commands[2].arraySetSize(1);
commands[2][0].arraySetSize(2);
commands[2][0][0] = 68.0;
commands[2][0][1] = dcm->getTime(10);
dcm->set(commands);
rtm.start();
#ifndef KROBOT_IS_REMOTE
KAlBroker::Instance().GetBroker()->getProxy("DCM")->getModule()->atPostProcess(KALBIND(&Sensors::synchronisedDCMcallback , this));
#endif
firstrun = false;
}
#ifdef KROBOT_IS_REMOTE
//Fetch into vectors
jointaccess.GetValues(jointValues);
sensoraccess.GetValues(sensorValues);
fetchValues();
publishData(ASM, "sensors");
if(updateButtons())
{
publishSignal(BM, "buttonevents");
}
#endif
float oldvalue;
vector<float> RobotValues = motion->getRobotPosition(true);
//A vector containing the World Absolute Robot Position. (Absolute Position X, Absolute Position Y, Absolute Angle Z)
for (unsigned i = 0; i < RobotValues.size(); i++)
{
oldvalue = RPM.sensordata(i).sensorvalue();
RPM.mutable_sensordata(i)->set_sensorvalue(RobotValues[i]);
RPM.mutable_sensordata(i)->set_sensorvaluediff(RobotValues[i] - oldvalue);
}
RPM.set_timediff(timediff);
publishData(RPM, "sensors");
return 0;
}
示例7: Initial_state_code
void Kick::Initial_state_code(void)
{
//BUILDER COMMENT. DO NOT REMOVE. begin Initial_state_code
//Primero ir a PoseInit
pmotion->setWalkTargetVelocity(0.0, 0.0, 0.0, 0.7);
ALValue path;
path.arraySetSize(6);
path[0] = 0.0;
path[2] = 0.0;
path[3] = 0.0;
path[4] = 0.0;
path[5] = 0.0;
path[1] = 0.03;
pmotion->positionInterpolation("LLeg", 2, path, 63, 0.5, false);
path[1] = -0.03;
pmotion->positionInterpolation("RLeg", 2, path, 63, 0.5, false);
HPoint3D ball3D;
/*HPoint2D ball2D;
ball2D.x = _BallDetectorOld->getX()*160.0+80.0;
ball2D.y = _BallDetectorOld->getY()*120.0+60.0;
ball2D.h = 1.0;
_Kinematics->get3DPositionZ(ball3D, ball2D, 0.04);
path[0] = 0.0;
path[2] = -0.03;
path[3] = 0.0;
path[4] = 0.0;
path[5] = 0.0;
*/
ball3D.Y = 1.0;
if(ball3D.Y > 0.0)
path[1] = -0.07;
else
path[1] = 0.07;
pmotion->positionInterpolation("Torso", 2, path, 63, 1.0, false);
//BUILDER COMMENT. DO NOT REMOVE. end Initial_state_code
}
示例8: setJointData
void HWController::setJointData(const ALValue &values) {
if (values.getSize() < NUM_OF_JOINTS) return;
shared_ptr<vector<float> > local_actuator_values = make_shared<vector<float> >(NUM_OF_JOINTS);
for (int i = 0; i < NUM_OF_JOINTS; ++i) local_actuator_values->at(i) = (float) values[i];
lock_guard<mutex> guard(this->actuator_mutex);
this->work_actuator_values.swap(local_actuator_values);
}
示例9: setStiffness
/**
* @brief Set stiffness of joints.
*
* @param[in] stiffnessValue value of stiffness [0;1]
*/
void oru_walk::setStiffness(const float &stiffnessValue)
{
ALValue stiffnessCommands;
if ((stiffnessValue < 0) || (stiffnessValue > 1))
{
ORUW_THROW("Wrong parameters");
}
// Prepare one dcm command:
// it will linearly "Merge" all joint stiffness
// from last value to "stiffnessValue" in 1 seconde
stiffnessCommands.arraySetSize(3);
stiffnessCommands[0] = std::string("jointStiffness");
stiffnessCommands[1] = std::string("Merge");
stiffnessCommands[2].arraySetSize(1);
stiffnessCommands[2][0].arraySetSize(2);
stiffnessCommands[2][0][0] = stiffnessValue;
/// @attention Hardcoded parameter!
unsigned int stiffness_change_time = 1000;
try
{
stiffnessCommands[2][0][1] = dcm_proxy->getTime(stiffness_change_time);
}
catch (const ALError &e)
{
ORUW_THROW_ERROR("Error on DCM getTime : ", e);
}
try
{
dcm_proxy->set(stiffnessCommands);
}
catch (const ALError &e)
{
ORUW_THROW_ERROR("Error when sending stiffness to DCM : ", e);
}
qi::os::msleep(stiffness_change_time);
qiLogInfo ("module.oru_walk", "Execution of setStiffness() is finished.");
}
示例10: string
/**
* Creates the appropriate aliases with the DCM
*/
void NaoEnactor::initDCMAliases(){
ALValue positionCommandsAlias;
positionCommandsAlias.arraySetSize(3);
positionCommandsAlias[0] = string("AllActuatorPosition");
positionCommandsAlias[1].arraySetSize(Kinematics::NUM_JOINTS);
ALValue hardCommandsAlias;
hardCommandsAlias.arraySetSize(3);
hardCommandsAlias[0] = string("AllActuatorHardness");
hardCommandsAlias[1].arraySetSize(Kinematics::NUM_JOINTS);
for (unsigned int i = 0; i<Kinematics::NUM_JOINTS; i++){
positionCommandsAlias[1][i] = jointsP[i];
hardCommandsAlias[1][i] = jointsH[i];
}
dcmProxy->createAlias(positionCommandsAlias);
dcmProxy->createAlias(hardCommandsAlias);
}
示例11: Java_jp_ac_fit_asura_naoji_jal_JALMemory__1createQuery
JNIEXPORT jlong JNICALL Java_jp_ac_fit_asura_naoji_jal_JALMemory__1createQuery(
JNIEnv *env, jclass, jlong jmemoryPtr, jobjectArray jstrings) {
JALMemory *jmemory = reinterpret_cast<JALMemory*> (jmemoryPtr);
assert(jmemory != NULL);
Query *query = new Query(jmemory);
jsize size = env->GetArrayLength(jstrings);
ALValue names;
names.arraySetSize(size);
for (int i = 0; i < size; i++) {
jstring jstr = static_cast<jstring> (env->GetObjectArrayElement(
jstrings, i));
jassert(env, jstr != NULL);
names[i] = toString(env, jstr);
env->DeleteLocalRef(jstr);
}
query->names = names;
return reinterpret_cast<jlong> (query);
}
示例12: Java_jp_ac_fit_asura_naoji_jal_JALMemory__1updateStringQuery
JNIEXPORT
void JNICALL Java_jp_ac_fit_asura_naoji_jal_JALMemory__1updateStringQuery(
JNIEnv *env, jclass, jlong queryPtr) {
Query *query = reinterpret_cast<Query*> (queryPtr);
assert(query != NULL);
try {
ALValue data = query->jmemory->getProxy()->getListData(query->names);
int size = data.getSize();
assert(query->names.getSize() == size);
for (int i = 0; i < size; i++) {
env->SetObjectArrayElement(query->buffer.s, i, env->NewStringUTF(
((string)data[i]).c_str()));
}
} catch (AL::ALError err) {
std::cerr << err.toString() << std::endl;
assert(false);
}
}
示例13: Java_jp_ac_fit_asura_naoji_jal_JALMemory__1updateIntQuery
JNIEXPORT
void JNICALL Java_jp_ac_fit_asura_naoji_jal_JALMemory__1updateIntQuery(
JNIEnv *, jclass, jlong queryPtr) {
Query *query = reinterpret_cast<Query*> (queryPtr);
assert(query != NULL);
try {
ALValue data = query->jmemory->getProxy()->getListData(query->names);
int size = data.getSize();
assert(query->names.getSize() == size);
jint* buf = reinterpret_cast<jint*> (query->buffer.b);
for (int i = 0; i < size; i++) {
buf[i] = data[i];
}
} catch (AL::ALError err) {
std::cerr << err.toString() << std::endl;
assert(false);
}
}
示例14: initDCMAliases
void SimuNaoProvider::initDCMAliases()
{
ALValue positionCommandsAlias;
positionCommandsAlias.arraySetSize(2);
positionCommandsAlias[0] = std::string("AllActuatorPosition");
ALValue hardCommandsAlias;
hardCommandsAlias.arraySetSize(2);
hardCommandsAlias[0] = std::string("AllActuatorHardness");
positionCommandsAlias[1].arraySetSize(numOfJoints);
hardCommandsAlias[1].arraySetSize(numOfJoints);
for (int i=0;i<numOfJoints;i++)
{
positionCommandsAlias[1][i] = std::string(jointNames[i]) + "/Position/Actuator/Value";
hardCommandsAlias[1][i] = std::string(jointNames[i]) + "/Hardness/Actuator/Value";
}
dcmProxy->createAlias(positionCommandsAlias);
dcmProxy->createAlias(hardCommandsAlias);
}
示例15: fetchImage
struct timespec KImageExtractor::fetchImage(IplImage *img)
{
struct timespec rt;//Timestamp
cout<<"KImageExtractor::fetchimage():"<<endl;
if (doneSubscribe==false)
{
cout<<"KImageExtractor: Warning! fetchImage() called although GVM Subscription has failed!"<<endl;
rt.tv_sec=0;
rt.tv_nsec=0;
return rt;
}
#ifdef REMOTE_ON
// cout << "Remote method on" << endl;
// sleep(1);
ALValue results;
#ifdef RAW
results = (c->call<ALValue> ("getDirectRawImageRemote", GVM_name));
#else
results = (c->call<ALValue> ("getImageRemote", GVM_name));
#endif
if (results.getType() != ALValue::TypeArray && results.getSize() != 7)
{
throw ALError("KImageExtractor", "saveImageRemote", "Invalid image returned.");
}
//const int size = results[6].getSize();
// You can get some image information that you may find useful.
// const int width = (int) results[0];
// const int height = (int) results[1];
// const int nbLayers = (int) results[2];
// const int colorSpace = (int) results[3];
//const long long timeStamp = ((long long) (int) results[4]) * 1000000LL + ((long long) (int) results[5]);
// const int seconds = (int) (timeStamp / 1000000LL);
// Set the buffer we received to our IplImage header.
//fIplImageHeader->imageData = (char*) (results[6].GetBinary());
//cout << "Size" << size << endl;
int width = (int) results[0];
int height = (int) results[1];
int nChannels = (int) results[2];
int colorSpace = (int) results[3];
int size =width*height*nChannels;
//Fetch TimeStamp;
rt.tv_sec=(time_t)((int) results[4]);
rt.tv_nsec=(int) results[5]*1000L;
//Change of image data size
assert(img!=NULL);
//cout<<img->imageSize<<" "<<size<<endl;
if (img->imageSize!=size )
{
//cout<<img->width<<" "<<img->height<<endl;
cout<<"KImageExtractor::fetchImage():allocating new imagedata"<<endl;
//cout<<"Delete old"<<endl;
//delete img->imageData;
//img->imageData=NULL;
cout<<"cvInitImage"<<endl;
cvInitImageHeader(img, cvSize(width,height),IPL_DEPTH_8U, nChannels);
//img->imageData=NULL;
cout<<" Done"<<endl;
//img->imageData=(char*)malloc(img->imageSize);
}
if (img->imageData != NULL)
{
//free( fIplImageHeader->imageData)
memcpy(img->imageData, (char*) (results[6].GetBinary()), results[6].getSize() * sizeof(unsigned char));
}
else
{
img->imageData = new char[img->imageSize];
memcpy(img->imageData, (char*) (results[6].GetBinary()), results[6].getSize() * sizeof(char));
}
#else
//cout << "Remote method off" << endl;
//sleep(1);
ALImage* imageIn = NULL;
// Now you can get the pointer to the video structure.
#ifdef RAW
imageIn = (ALImage*) (c->call<int> ("getDirectRawImage", GVM_name));
#else
imageIn = (ALImage*) (c->call<int> ("getImageLocal", GVM_name));
#endif
if (!imageIn)
{
throw ALError("KImageExtractor", "saveImageLocal", "Invalid image returned.");
}
//fLogProxy->info(getName(), imageIn->toString());
// You can get some image information that you may find useful.
int width = imageIn->fWidth;
int height = imageIn->fHeight;
const int nChannels = imageIn->fNbLayers;
// const int colorSpace = imageIn->fColorSpace;
const long long timeStamp = imageIn->fTimeStamp;
//.........这里部分代码省略.........