401 response.accepted =
false;
402 response.emitted =
false;
404 if (request.newAction.action_name.empty()) {
406 response.error_msg =
"action_name can not be empty";
407 ROS_ERROR_STREAM (
"[RosServiceHandler " << __func__ <<
" ] " << response.error_msg);
411 if (request.newAction.action_motor_position.name.size() == 0 ||
412 request.newAction.action_motor_position.position.size() == 0 ||
413 request.newAction.action_motor_position.position.size() != request.newAction.action_motor_position.name.size()) {
415 response.error_msg =
"action_motor_position is empty or badly formed";
416 ROS_ERROR_STREAM (
"[RosServiceHandler " << __func__ <<
" ] " << response.error_msg);
421 if (request.newAction.action_motor_count.name.size() != request.newAction.action_motor_count.count.size()) {
423 response.error_msg =
"action_motor_count is badly formed, name and count have different sizes";
424 ROS_ERROR_STREAM (
"[RosServiceHandler " << __func__ <<
" ] " << response.error_msg);
432 if (
_mapActionHandler->getGeneric(request.newAction.action_name,
false) !=
nullptr) {
434 response.error_msg =
"A generic action with name '" + request.newAction.action_name +
"' already exists";
435 ROS_ERROR_STREAM (
"[RosServiceHandler " << __func__ <<
" ] " << response.error_msg);
444 std::set<std::string> elementInvolved;
446 for (
int i = 0; i < request.newAction.action_motor_position.name.size(); i++){
448 std::vector<double> one_dof{request.newAction.action_motor_position.position.at(i)};
449 jp.insert(std::make_pair(request.newAction.action_motor_position.name.at(i),
453 for (
int i = 0; i < request.newAction.action_motor_count.name.size(); i++){
455 jic.insert(std::make_pair(request.newAction.action_motor_count.name.at(i),
456 request.newAction.action_motor_count.count.at(i)));
459 for (
int i = 0; i< request.newAction.elements_involved.size(); i++) {
461 elementInvolved.insert(request.newAction.elements_involved.at(i));
465 try { newAction = std::make_shared<ROSEE::ActionGeneric>(request.newAction.action_name,
472 response.error_msg =
"action_motor_position and action_motor_count have different names element. They must be the same because they refer to actuator of the end-effector";
473 ROS_ERROR_STREAM (
"[RosServiceHandler " << __func__ <<
" ] " << response.error_msg);
482 response.error_msg =
"error by mapActionHandler when inserting the new generic action";
483 ROS_ERROR_STREAM (
"[RosServiceHandler " << __func__ <<
" ] " << response.error_msg);
488 ROS_INFO_STREAM (
"[RosServiceHandler " << __func__ <<
" ] The new action '"<< newAction->getName() <<
"' is inserted in the system");
491 if (request.emitYaml) {
495 ROS_INFO_STREAM (
"[RosServiceHandler " << __func__ <<
" ] The received new action '"<< newAction->getName() <<
"' has been stored in " << path);
496 response.emitted =
true;
499 response.accepted =
true;
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints.
std::map< std::string, unsigned int > JointsInvolvedCount
The map to describe, how many times a joint is set by the action.
MapActionHandler::Ptr _mapActionHandler
std::shared_ptr< ActionGeneric > Ptr
std::string _path2saveYamlGeneric
std::string createYamlFile(const std::map< std::set< std::string >, ActionPrimitive * > mapOfActions, const std::string actionName, std::string pathFolder)
Create/overwrite yaml file and emit info on it about each ActionPrimitive inside the given mapOfActio...