{"action":"created","issue":{"url":"https://api.github.com/repos/robotology/QA/issues/131","repository_url":"https://api.github.com/repos/robotology/QA","labels_url":"https://api.github.com/repos/robotology/QA/issues/131/labels{/name}","comments_url":"https://api.github.com/repos/robotology/QA/issues/131/comments","events_url":"https://api.github.com/repos/robotology/QA/issues/131/events","html_url":"https://github.com/robotology/QA/issues/131","id":170455774,"number":131,"title":"Handling of compliance while using goToPose","user":{"login":"misaki43","id":9462576,"avatar_url":"https://avatars.githubusercontent.com/u/9462576?v=3","gravatar_id":"","url":"https://api.github.com/users/misaki43","html_url":"https://github.com/misaki43","followers_url":"https://api.github.com/users/misaki43/followers","following_url":"https://api.github.com/users/misaki43/following{/other_user}","gists_url":"https://api.github.com/users/misaki43/gists{/gist_id}","starred_url":"https://api.github.com/users/misaki43/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/misaki43/subscriptions","organizations_url":"https://api.github.com/users/misaki43/orgs","repos_url":"https://api.github.com/users/misaki43/repos","events_url":"https://api.github.com/users/misaki43/events{/privacy}","received_events_url":"https://api.github.com/users/misaki43/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/robotology/QA/labels/control","name":"control","color":"fbca04"},{"url":"https://api.github.com/repos/robotology/QA/labels/software","name":"software","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-10T16:06:46Z","updated_at":"2016-08-10T18:14:05Z","closed_at":null,"body":"Hello! \r\n\r\nIn my program I need the robot to be compliant, except for one given moment. At this special time instant, the robot has to go back to a specified initial position.\r\n\r\nTo put the robot in compliant mode, I use the following code for each joints:\r\n```cpp\r\niimp->setImpedance(j,leftArmJointsStiffness[j],leftArmJointsDamping[j]);\r\nictrl->setTorqueMode(j); \r\nitrq->setRefTorque(j, 0.0); // should be totally compliant ? How is \"setImpedance\" taking into account after that ?\r\nimode->setInteractionMode(j,VOCAB_IM_COMPLIANT);\r\n```\r\n\r\nThen, to drive the robot back to the \"home position\", I use the code:\r\n```cpp\r\nclient.goToPose(xinit,od);  // that is a iCartesianControl method\r\n```\r\n\r\nAfter that, I use again the following code to put the robot in compliant mode:\r\n```cpp\r\nictrl->setTorqueMode(j); \r\nitrq->setRefTorque(j, 0.0); // should it be totally compliant? How is the \"setImpedance\" taking into account?   \r\nimode->setInteractionMode(j,VOCAB_IM_COMPLIANT);\r\n```\r\n\r\nThe issue is that the second time I ask it to be compliant in torque mode, it stays in `position-direct` mode, and I don't know why.\r\n\r\nWhile trying to understand, I have seen that if I use the instructions:\r\n```cpp\r\nictrl->getControlMode(j, &control_mode);\r\nimode->getInteractionMode(j, &interaction_mode);\r\n```\r\nIt turns out that after the `goToPose` command, the robot is still in `position-direct` mode. Therefore, the control mode seems to be not updated.\r\n\r\nCan you explain why and what I am supposed to do?\r\n\r\nMoreover, I tried to understand better the control mode of the robot. I wanted to look at the `goToPose()` function, but I didn't find it (I only find the CartesianControl.h file but not the cpp function linked). Could you help me please? \r\n\r\nFinally, I would like to verify something. I am only interested in the position control of the robot (goToPose and getPose) and by the possibility to change the compliance of the robot. Do I have a cleaner way to put the robot in the compliance mode, without passing from torque control to position control?\r\n\r\nThanks! \r\n"},"comment":{"url":"https://api.github.com/repos/robotology/QA/issues/comments/238954480","html_url":"https://github.com/robotology/QA/issues/131#issuecomment-238954480","issue_url":"https://api.github.com/repos/robotology/QA/issues/131","id":238954480,"user":{"login":"pattacini","id":3738070,"avatar_url":"https://avatars.githubusercontent.com/u/3738070?v=3","gravatar_id":"","url":"https://api.github.com/users/pattacini","html_url":"https://github.com/pattacini","followers_url":"https://api.github.com/users/pattacini/followers","following_url":"https://api.github.com/users/pattacini/following{/other_user}","gists_url":"https://api.github.com/users/pattacini/gists{/gist_id}","starred_url":"https://api.github.com/users/pattacini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattacini/subscriptions","organizations_url":"https://api.github.com/users/pattacini/orgs","repos_url":"https://api.github.com/users/pattacini/repos","events_url":"https://api.github.com/users/pattacini/events{/privacy}","received_events_url":"https://api.github.com/users/pattacini/received_events","type":"User","site_admin":false},"created_at":"2016-08-10T18:14:05Z","updated_at":"2016-08-10T18:14:05Z","body":"Hi @misaki43 \r\n\r\nI'm afraid there's a bit of confusion between `torque` and `compliant-mode`: the former is one of the available **control mode**, whereas the latter is one of the two allowed **interaction mode**.\r\n\r\nWhile `position-direct` and `torque` take a mutually exclusive control of the joints realizing two utterly different tasks, `position-direct` can be used either in `stiff` or `compliant` mode, which are in turn the two interaction modes we provide. On the other hand, `torque` does not go along with any specific interaction mode, given that it takes over the low level control outright.\r\n\r\nTo summarize:\r\n\r\n**CM**=Control Mode; **IM**=Interaction Mode\r\n\r\n| Joint in CM | IM = Stiff | IM = Compliant |\r\n| ------------- | ------------- | ------------- |\r\n| **Position-Direct**  | **Rigidly** controlled toward the target | **Spring effect** while controlled toward the target |\r\n| **Torque**  | The torque reference is directly assigned and tracked (e.g. zero-g) | The torque reference is directly assigned and tracked (e.g. zero-g) |\r\n\r\nIt comes out that when the joint is in `torque`, the control is not affected by **IM**.\r\n\r\nI don't know exactly where I can point you at for finding out more on this topic. Perhaps @randaz81 and/or @traversaro can give better hints on what I've reported above and - more importantly - on where the documentation is.\r\n\r\nComing to your specific problem, the correct instructions to put a joint in compliant mode is (let's assume you're already in `position-direct`):\r\n```cpp\r\nIInteractionMode  *imode;\r\nIImpedanceControl *iimp;\r\n\r\ndriver->view(imode);\r\ndriver->view(iimp);\r\n\r\niimp->setImpedance(j,stiffness_value,damping_value);\r\nimode->setInteractionMode(j,VOCAB_IM_COMPLIANT);\r\n```\r\n\r\nAt this point, it's not necessary to disable compliance when you want to drive the robot back to its home position, unless you want to do so for a specific reason (maybe for precision? but it's a mere home position in the end). However, to do that:\r\n\r\n```cpp\r\nimode->setInteractionMode(j,VOCAB_IM_STIFF);\r\n```\r\n\r\nThe Cartesian control is agnostic with respect to how its reference commands will be actually implemented by the firmware depending on the current **IM**. Therefore you can enable and disable the compliant mode at will with no particular care.\r\n\r\nOn the contrary, `torque` is a control mode, and as such it does interfere with `position-direct`. As a result, you have to be careful with the switching. If the movement yielded by a call to the `goToPose` service is still ongoing, then you cannot safely switch to `torque`. Well, you can try it out, but the Cartesian controller will take over again and switch it back to `position-direct`. This check is being performed continuously until the robot has come to a complete stop (i.e. has reached its final target or is asked to stop straightaway).\r\n\r\nThereby, you might consider calling the following methods before changing the control mode when you're steering the robot in the operational space: `checkMotionDone`, `waitMotionDone`, `stopControl`.\r\n\r\nHope this better clarifies the matter."}}
{"actor":{"display_login":"pattacini"}}