5 int ControllerClient::CONTROLLER_CLIENT_COUNT = 0;
8 : yarp::os::RateThread(DEFAULT_LOOP_PERIOD)
10 , expectedPeriod(DEFAULT_LOOP_PERIOD)
16 : yarp::os::RateThread(loopPeriod)
17 ,
model(derivedModelPtr)
18 , expectedPeriod(loopPeriod)
20 clientNumber = ++ControllerClient::CONTROLLER_CLIENT_COUNT;
22 clientComs = std::make_shared<ClientCommunications>();
25 std::string statesPort_Name =
"/ControllerClient/"+ std::to_string(clientNumber) +
"/states:i";
27 statesPort.open(statesPort_Name.c_str());
31 statesPort.setReader(stateCallback);
33 yarp.connect(
"/ControllerServer/states:o", statesPort_Name.c_str());
45 clientThreadHasBeenReleased =
false;
60 clientThreadHasBeenReleased =
true;
65 yarp::os::Bottle request;
67 request.addString(taskName);
83 std::vector<ocra::TaskBuilderOptions> addTaskOptsVec;
84 std::vector<ocra::TaskBuilderOptions> overwriteTaskOptsVec;
85 for (
auto taskOpts : taskOptsVec) {
87 addTaskOptsVec.push_back(taskOpts);
90 overwriteTaskOptsVec.push_back(taskOpts);
95 yarp::os::Bottle request;
97 request.addInt(addTaskOptsVec.size());
98 for (
auto taskOpts : addTaskOptsVec) {
99 taskOpts.putIntoBottle(request);
103 std::cout <<
"Didn't work." << std::endl;
111 for (
auto name : tmNames) {
118 yLog.warning() <<
"You are trying to add a task with the same name as another task. I am gonna rename it for you big dummy.";
119 tmOpts.
taskName +=
"_" + std::to_string(clientNumber);
140 yarp::os::Bottle request;
141 if (!newFixedLink.compare(
"r_sole") || !newFixedLink.compare(
"right")) {
143 OCRA_INFO(
"Changed fixed link to right sole");
145 if (!newFixedLink.compare(
"l_sole") || !newFixedLink.compare(
"left")) {
147 OCRA_INFO(
"Changed fixed link to left sole");
149 OCRA_ERROR(
"The new fixed link you specify is not supported yet. Please try r_sole, right, l_sole or left.");
153 OCRA_INFO(
"sending contact state (" << isInLeftSupport <<
", " <<isInRightSupport <<
")");
154 request.addInt(isInLeftSupport);
155 request.addInt(isInRightSupport);
160 OCRA_ERROR(
"Communication with ocra-icub-server didn't work. Requested change to right foot link");
std::string getTaskTypeAsString()
virtual ~ControllerClient()
void addTasks(const std::string &pathToXmlFile, bool overwrite)
ClientCommunications::Ptr clientComs
std::vector< std::string > getTaskNames()
virtual bool threadInit()
virtual bool initialize()
std::vector< TaskBuilderOptions > parseTaskOptionsFromXml(const std::string &optionsXmlFilePath)
A callback for a port listing to robot states.
bool checkIfTaskExists(ocra::TaskBuilderOptions &tmOpts)
bool removeTasks(const std::vector< std::string > &taskNameVector)
std::vector< std::string > getTaskTypes()
bool changeFixedLink(std::string newFixedLink, int isInLeftSupport, int isInRightSupport)
virtual void threadRelease()
bool removeTask(const std::string &taskName)