Skip to content
Snippets Groups Projects
Commit 3fb2b37e authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Add command AddFeature in sot::Task

    * src/task/task-command.h: new,
    * src/task/task.cpp.
parent b74d1d57
Branches
Tags
No related merge requests found
/*
* Copyright 2010,
* Florent Lamiraux
*
* CNRS
*
* This file is part of sot-core.
* sot-core is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* sot-core is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with sot-core. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TASK_COMMAND_H
#define TASK_COMMAND_H
#include <boost/assign/list_of.hpp>
#include <dynamic-graph/command.h>
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/command-getter.h>
namespace sot {
namespace command {
namespace task {
using ::dynamicgraph::command::Command;
using ::dynamicgraph::command::Value;
// Command AddFeature
class AddFeature : public Command
{
public:
virtual ~AddFeature() {}
/// Create command and store it in Entity
/// \param entity instance of Entity owning this command
/// \param docstring documentation of the command
AddFeature(Task& entity, const std::string& docstring) :
Command(entity, boost::assign::list_of(Value::STRING), docstring)
{
}
virtual Value doExecute()
{
Task& task = static_cast<Task&>(owner());
std::vector<Value> values = getParameterValues();
std::string featureName = values[0].value();
FeatureAbstract& feature = sotPool.getFeature(featureName);
task.addFeature(feature);
// return void
return Value();
}
}; // class AddFeature
} // namespace task
} // namespace command
} //namespace sot
#endif //TASK_COMMAND_H
......@@ -25,11 +25,14 @@
/* SOT */
#include <sot-core/task.h>
#include <sot-core/debug.h>
#include <sot-core/pool.h>
#include "../src/task/task-command.h"
using namespace std;
using namespace sot;
using namespace dynamicgraph;
#include <sot-core/factory.h>
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Task,"Task");
......@@ -63,6 +66,21 @@ Task( const std::string& n )
signalRegistration( controlGainSIN<<dampingGainSINOUT
<<controlSelectionSIN<<errorSOUT );
//
// Commands
//
std::string docstring;
// AddFeature
docstring = " \n"
" \n"
" Add a feature to the task\n"
" \n"
" Input:\n"
" - name of the feature\n"
" \n";
addCommand("add",
new command::task::AddFeature(*this, docstring));
}
......@@ -307,7 +325,6 @@ display( std::ostream& os ) const
/* --- PARAMS --------------------------------------------------------------- */
/* --- PARAMS --------------------------------------------------------------- */
/* --- PARAMS --------------------------------------------------------------- */
#include <sot-core/pool.h>
static void readListIdx( std::istringstream& cmdArgs,
unsigned int & idx_beg,unsigned int &idx_end,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment