Skip to content

Commit 4fe6933

Browse files
author
Francois Keith
committed
Update GripperControl: add the python interface, remove the old one.
1 parent d81f902 commit 4fe6933

File tree

2 files changed

+17
-28
lines changed

2 files changed

+17
-28
lines changed

include/sot/core/gripper-control.hh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ class SOTGRIPPERCONTROL_EXPORT GripperControl
9393
static ml::Vector& selector( const ml::Vector& fullsize,
9494
const Flags& selec,
9595
ml::Vector& desPos );
96-
9796
};
9897

9998
/* --------------------------------------------------------------------- */
@@ -144,10 +143,9 @@ class SOTGRIPPERCONTROL_EXPORT GripperControlPlugin
144143

145144
public: /* --- COMMANDLINE --- */
146145

147-
virtual void commandLine( const std::string& cmdLine,
148-
std::istringstream& cmdArgs,
149-
std::ostream& os );
146+
void initCommands();
150147

148+
void setOffset(const double & value);
151149
};
152150

153151

src/tools/gripper-control.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <sot/core/factory.hh>
2424
#include <sot/core/macros-signal.hh>
2525

26+
#include <dynamic-graph/all-commands.h>
27+
2628
using namespace dynamicgraph::sot;
2729
using namespace dynamicgraph;
2830

@@ -98,6 +100,8 @@ GripperControlPlugin( const std::string & name )
98100
<< torqueFullSizeSIN << torqueReduceSOUT
99101
<< torqueLimitFullSizeSIN << torqueLimitReduceSOUT );
100102
sotDEBUGOUT(5);
103+
104+
initCommands();
101105
}
102106

103107

@@ -232,32 +236,19 @@ selector( const ml::Vector& fullsize,
232236
/* --- COMMANDLINE ---------------------------------------------------------- */
233237
/* --- COMMANDLINE ---------------------------------------------------------- */
234238
/* --- COMMANDLINE ---------------------------------------------------------- */
235-
236-
void GripperControlPlugin::
237-
commandLine( const std::string& cmdLine,
238-
std::istringstream& cmdArgs,
239-
std::ostream& os )
239+
void GripperControlPlugin::initCommands()
240240
{
241-
if( "help"==cmdLine )
242-
{
243-
os << "GripperControl: " << std::endl
244-
<< " - offset [<value>]: set/get the offset value." <<std::endl;
245-
}
246-
else if( "offset"==cmdLine )
247-
{
248-
cmdArgs>>std::ws; if( cmdArgs.good() )
249-
{
250-
double val; cmdArgs>>val; if( (val>0)&&(val<1) ) offset=val;
251-
} else {
252-
os << "offset = " << offset << std:: endl;
253-
}
254-
}
255-
else if( "factor"==cmdLine )
256-
{
257-
os << "factor = " << factor << std:: endl;
258-
}
259-
else{ Entity::commandLine( cmdLine,cmdArgs,os ); }
241+
namespace dc = ::dynamicgraph::command;
242+
addCommand("offset",
243+
dc::makeCommandVoid1(*this,&GripperControlPlugin::setOffset,
244+
"set the offset (should be in )0, 1(."));
245+
}
260246

261247

248+
void GripperControlPlugin::setOffset(const double & value)
249+
{
250+
if( (value>0)&&(value<1) ) offset = value;
251+
else std::cerr << "The offset should be in )0, 1(." << std::endl;
262252
}
263253

254+

0 commit comments

Comments
 (0)