33 #include <Rcs_typedef.h> 34 #include <Rcs_macros.h> 42 OMTask::OMTask(Task* task) : task(task), maxVelocity(task->getDim(), std::numeric_limits<double>::infinity()) {}
51 return task->getDim();
56 task->computeX(state);
57 task->computeXp(velocity);
63 minState[i] =
task->getParameter(i).minVal;
64 maxState[i] =
task->getParameter(i).maxVal;
65 maxVelocity[i] = this->maxVelocity[i];
73 std::vector<std::string> result;
76 std::string prefix =
task->getEffector()->name;
79 for (
auto param :
task->getParameters()) {
80 auto paramName = param.name;
81 auto spaceIdx = paramName.find(
' ');
83 if (spaceIdx != std::string::npos) {
84 paramName = paramName.substr(0, spaceIdx);
87 result.push_back(prefix + paramName);
95 task->getParameter(i).minVal = minState;
104 task->getParameter(i).minVal = minState[i];
112 task->getParameter(i).maxVal = maxState;
121 task->getParameter(i).maxVal = maxState[i];
128 std::fill(this->maxVelocity.begin(), this->maxVelocity.end(),
maxVelocity);
141 if (effectorName != NULL) {
142 RcsBody* effector = RcsGraph_getBodyByName(
task->getGraph(), effectorName);
143 RCHECK_MSG(effector,
"Effector body %s not found!", effectorName);
144 task->setEffector(effector);
146 if (refBodyName != NULL) {
147 RcsBody* refBody = RcsGraph_getBodyByName(
task->getGraph(), refBodyName);
148 RCHECK_MSG(refBody,
"Reference body %s not found!", refBodyName);
149 task->setRefBody(refBody);
152 if (refFrameName == NULL) {
153 task->setRefFrame(refBody);
156 if (refFrameName != NULL) {
157 RcsBody* refFrame = RcsGraph_getBodyByName(
task->getGraph(), refFrameName);
158 RCHECK_MSG(refFrame,
"Reference frame %s not found!", refFrameName);
159 task->setRefFrame(refFrame);
virtual void getLimits(double *minState, double *maxState, double *maxVelocity) const
void initTaskBodyNames(const char *effectorName, const char *refBodyName, const char *refFrameName)
virtual unsigned int getStateDim() const
std::vector< double > maxVelocity
Settable maximum velocity (min/max state is stored in task parameter)
virtual void computeObservation(double *state, double *velocity, const MatNd *currentAction, double dt) const
OMTask * setMinState(double minState)
OMTask * setMaxState(double maxState)
virtual std::vector< std::string > getStateNames() const
Task * task
Wrapped task object (owned!)
OMTask * setMaxVelocity(double maxVelocity)