The problem about exercise 4 methods of RTT exercise

I follow the guide and define a new method:


<span style="background-color: rgb(255, 204, 255);">Method< void(const std::string&) > method_2;<span>
<span style="background-color: rgb(255, 204, 255);">void sayIt(const std::string& word)<span>

<span style="background-color: rgb(255, 204, 255);">{<span>
<span style="background-color: rgb(255, 204, 255);">      log(Info)<<word<<endlog();<span>

<span style="background-color: rgb(255, 204, 255);">}<span>
<span style="background-color: rgb(255, 204, 255);">method_2("the_method_2",&Hello::sayIt, this);<span>



<span style="background-color: rgb(204, 204, 204);"><span>But when I add it using:
<span style="background-color: rgb(255, 204, 255);">this->methods()->addMethod(&method_2, "'the_method_2' Description");<span>


The Boost gives me errors like:
<span style="background-color: rgb(255, 204, 255);">"g++ -g -o helloworld HelloWorld.cpp -I/usr/local/include -DOROCOS_TARGET=gnulinux -Wall -L/usr/local/lib -Wl,-rpath /usr/local/lib -lorocos-taskbrowser-gnulinux -lorocos-rtt-gnulinux<span>

<span style="background-color: rgb(255, 204, 255);">/usr/local/include/rtt/MethodRepository.hpp: In member function 'bool RTT::MethodRepository::addMethod(MethodT, const char*) [with MethodT = RTT::Method<void ()(const std::string&)>*]':<span>

<span style="background-color: rgb(255, 204, 255);">HelloWorld.cpp:93:   instantiated from here<span>
<span style="background-color: rgb(255, 204, 255);">/usr/local/include/rtt/MethodRepository.hpp:175: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' <span>

<span style="background-color: rgb(255, 204, 255);">make: *** [helloworld] Error 1<span>
<span style="background-color: rgb(255, 204, 255);">"<span>


I think it's about the data type that addMethod can not support.

Anyone has ideas to solve it??


Thanks,
GL

The problem about exercise 4 methods of RTT exercise

On Tuesday 27 January 2009 19:49:57 guoliang liu wrote:
> I follow the guide and define a new method:
>
>
> Method< void(const std::string&) > method_2;
> void sayIt(const std::string& word)
> {
> log(Info)<<word< > }
> method_2("the_method_2",&Hello::sayIt, this);
>
>
> But when I add it using:
> this->methods()->addMethod(&method_2, "'the_method_2' Description");
>
> The Boost gives me errors like:
> "g++ -g -o helloworld HelloWorld.cpp -I/usr/local/include
> -DOROCOS_TARGET=gnulinux -Wall -L/usr/local/lib -Wl,-rpath /usr/local/lib
> -lorocos-taskbrowser-gnulinux -lorocos-rtt-gnulinux
> /usr/local/include/rtt/MethodRepository.hpp: In member function 'bool
> RTT::MethodRepository::addMethod(MethodT, const char*) [with MethodT =
> RTT::Method<void ()(const std::string&)>*]':
> HelloWorld.cpp:93: instantiated from here
> /usr/local/include/rtt/MethodRepository.hpp:175: error: invalid application
> of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>'
> make: *** [helloworld] Error 1
> "
>
>
> I think it's about the data type that addMethod can not support.
> Anyone has ideas to solve it??

This is explained in the manual and the API documentation of addMethod. For
each argument of your method, you need to supply the name and a description.
So it should be:

 this->methods()->addMethod(&method_2, "'the_method_2' Description", 
"sentence", "The sentence to say (a string).");

The same holds for commands and events.

Peter

The problem about exercise 4 methods of RTT exercise

Thanks very much, it's solved.


2009/1/27 Peter Soetens <span dir="ltr"><peter [dot] soetens [..] ...><span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

On Tuesday 27 January 2009 19:49:57 guoliang liu wrote:

> I follow the guide and define a new method:

>

>

> Method< void(const std::string&) > method_2;

> void sayIt(const std::string& word)

> {

>       log(Info)<<word<<endlog();

> }

> method_2("the_method_2",&Hello::sayIt, this);

>

>

> But when I add it using:

> this->methods()->addMethod(&method_2, "'the_method_2' Description");

>

> The Boost gives me errors like:

> "g++ -g -o helloworld HelloWorld.cpp -I/usr/local/include

> -DOROCOS_TARGET=gnulinux -Wall -L/usr/local/lib -Wl,-rpath /usr/local/lib

> -lorocos-taskbrowser-gnulinux -lorocos-rtt-gnulinux

> /usr/local/include/rtt/MethodRepository.hpp: In member function 'bool

> RTT::MethodRepository::addMethod(MethodT, const char*) [with MethodT =

> RTT::Method<void ()(const std::string&)>*]':

> HelloWorld.cpp:93:   instantiated from here

> /usr/local/include/rtt/MethodRepository.hpp:175: error: invalid application

> of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>'

> make: *** [helloworld] Error 1

> "

>

>

> I think it's about the data type that addMethod can not support.

> Anyone has ideas to solve it??


This is explained in the manual and the API documentation of addMethod. For

each argument of your method, you need to supply the name and a description.

So it should be:



<code>

 this->methods()->addMethod(&method_2, "'the_method_2' Description",

"sentence", "The sentence to say (a string).");

</code>



The same holds for commands and events.



Peter

<font color="#888888">--

Peter Soetens -- FMTC -- <http://www.fmtc.be>



<font><blockquote>