The attached test case demonstrates what I think is non-obvious behaviour. Wondering if you agree?
-
- First addMethod() call succeeds but the methodi is not available in the TaskBrowser.
- Second addMethod() fails to compile due to "arity==0" test in indicated function.
- Third addMethod() succeeds and the method is available in the TaskBrowser.
It appears that the various addMethod() functions either take no description and then the method doesn't appear in the TaskBrowser, OR, the addMethod() functions force you to describe each parameter to the method. I don't see this indicated anywhere, though I did notice that the Component Builder's Manual does document each parameter to a method (and hence is case 3 above).
YMMV
Stephen
#include <rtt/RTT.hpp>
#include <rtt/PeriodicActivity.hpp>
#include <rtt/TaskContexti.hpp>
#include <rtt/os/main.h>
#include <rtt/Method.hpp>
#include <ocl/TaskBrowser.hpp>
#include <string>
using namespace Orocos;
class MyTask : public RTT::TaskContext
{
private:
RTT::Method<void(const std::string&)> d_logState;
public:
MyTask(std::string name):
RTT::TaskContext(name),
d_logState("logState", &MyTask::logState, this)
{
// suceeds but not available in TaskBrowser
// methods()->addMethod(&d_logState);
// fails with STATIC ASSERT in RTT::MethodRepository::addMethod()
// methods()->addMethod(&d_logState, "log");
// suceeds and available in TaskBrowser
methods()->addMethod(&d_logState, "log", "v", "name");
}
void logState(const std::string& name)
{
log(Info) << "state = " << name << endlog();
}
};
int ORO_main(int arc, char* argv[])
{
log().setLogLevel( Logger::Debug );
MyTask myTask("myTask");
PeriodicActivity myTask_activity(
ORO_SCHED_RT, RTT::OS::HighestPriority, 1.0 / 1, myTask.engine());
myTask_activity.start();
TaskBrowser browser( &myTask );
browser.setColorTheme( TaskBrowser::whitebg );
browser.loop();
myTask_activity.stop();
return 0;
}