robotology / icub-tutorials

Tutorials on iCub code
19 stars 9 forks source link

vel->velocityMove(setpoints.data()) seems that it does not work. #17

Closed YANGGANG1971 closed 4 years ago

YANGGANG1971 commented 4 years ago

Following the link below, I try to control the head movement.
(http://www.icub.org/software_documentation/icub_basic_image_processing.html )

But some errors occurred. It may be due to velocityMove() function.
Screenshot from 2020-01-06 16-57-56

The codes are as follows.

IVelocityControl *vel;  
/* prepare command */ 
for (int i=0; i<jnts; i++) { 
setpoints[i] = 0; 
} 
if (conf>0.5) { 
setpoints[3] = vy; 
setpoints[4] = vx; 
}  
else { 
setpoints[3] = 0; 
setpoints[4] = 0; 
} 
vel->velocityMove(setpoints.data()); 
pattacini commented 4 years ago

Thanks for reporting the bug @YANGGANG1971

This is a quite outdated tutorial that needs some upgrade regarding the setting up of the correct control mode prior to sending commands.

Hence, I'll be dealing with the upgrade and I'll get back to you once done.

PS: as a general remark, please open up issues within the repository containing the code that raised the bug/question... I've moved this issue here from YARP.

pattacini commented 4 years ago

En passant, a quite complete tutorial on the use of different control modes can be found at https://github.com/vvv-school/tutorial_joint-interface.

pattacini commented 4 years ago

@YANGGANG1971 it should be fixed now 👍

YANGGANG1971 commented 4 years ago

Sorry, I am still confusing. It seems that there is no change in the link below. http://www.icub.org/software_documentation/icub_basic_image_processing.html

Also, you said that needs some upgrade regarding the setting up of the correct control mode before sending commands. How to set up the correct control mode? The link below does not explain the detail. https://github.com/vvv-school/tutorial_joint-interface.

pattacini commented 4 years ago

Sorry, I fixed only the code; https://github.com/robotology/icub-tutorials/commit/d6f4d4d0392e37c1765cde4487f0ca140ab05cc0 fixed the documentation too.

Anyway, you have to wait that our server will be triggered to update the documentation page.

YANGGANG1971 commented 4 years ago

I noted that only the snippet of codes below was added. but it seems that the syntax errors occurred.

   vector<int> modes(jnts,VOCAB_CM_VELOCITY);
   mod->setControlModes(modes.data());

Maybe, the correct syntax is as follows,

    Vector modes(jnts,VOCAB_CM_VELOCITY);
    mod->setControlModes((int*)modes.data());

Although I added the contents, it seems that the joints still cannot move.

pattacini commented 4 years ago

@YANGGANG1971

For the code, you have to download it from the repository where the fix was already correct. Peruse lookAtLocation.cpp, then.

The documentation cannot be compiled 😉 hence I missed to include the following:

#include <vector>

Instead, the modifications you have suggested, that is

Vector modes(jnts,VOCAB_CM_VELOCITY);
mod->setControlModes((int*)modes.data());

doesn't turn right here as setControlModes() does expect a vector of int and not double.

This might explain why the tutorial wasn't working yet, I think.