Armadillo and Typekit in c++

Dear all, I want to use OCL::ReportingComponent for capturing data of my "ControlLoop" component. I define my type called "robotTarget" for the outputport ( OutputPort<robotTarget> targetFromUser;) which is a struct defined as:
 struct robotTarget
{

    VECTOR targetPositionDH;
    VECTOR targetVelocityDH;
    VECTOR targetCurrent;
    int targetMode;
}; "VECTOR" is an alias for an Armadillo class
 #define VECTOR fcolvec::fixed1
According to http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-typekit-plugin.html I write

namespace boost {

      namespace serialization {
              template<class Archive>
          void serialize( Archive & a, VECTOR & cd, unsigned int) {
           using boost::serialization::make_nvp;
           using boost::serialization::make_array;
           float app[6];
           for(int i=0;i<20;i++)  app[i]=cd.at(i);
           a & make_nvp("VECTOR", make_array(app, 20));
           }

     }
}

namespace boost {

        namespace serialization {
             template<class Archive>
         void serialize( Archive & a, robotTarget & cd, unsigned int) {
              using boost::serialization::make_nvp;
              a & make_nvp("targetPositionDH", cd.targetPositionDH);
              a & make_nvp("targetVelocityDH", cd.targetVelocityDH);
              a & make_nvp("targetCurrent", cd.targetCurrent);
              a & make_nvp("targetMode", cd.targetMode);

           }

        }
    }

 struct VECTORTypeInfo
    : public RTT::types::StructTypeInfo2
  {
     VECTORTypeInfo()
        : RTT::types::StructTypeInfo3("VECTOR")
     {}
  };
  

  struct robotTargetTypeInfo
    : public RTT::types::StructTypeInfo4
  {
      robotTargetTypeInfo()
        : RTT::types::StructTypeInfo5("robotTarget")
     {}
  };
RTT::types::Types()->addType( new RTT::types::StructTypeInfo<VECTOR>("VECTOR") );

RTT::types::Types()->addType( new RTT::types::StructTypeInfo<robotTarget>("robotTarget") );

When I start the ReportingComponent I have a segmentation fault. Any idea? Thanks D.

Armadillo and Typekit in c++

2014-04-02 11:08 GMT+02:00 <dgerb [..] ...>:

> Dear all,
> I want to use OCL::ReportingComponent for capturing data of my
> "ControlLoop"
> component. I define my type called "robotTarget" for the outputport (
> OutputPort targetFromUser;) which is a struct defined as:
> struct robotTarget
> {
> VECTOR targetPositionDH;
> VECTOR targetVelocityDH;
> VECTOR targetCurrent;
> int targetMode;
> };
> "VECTOR" is an alias for an Armadillo class
> #define VECTOR fcolvec::fixed
>
>
> According to
>
> http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-typek...
> I write
>
> namespace boost {
> namespace serialization {
> template
> void serialize( Archive & a, VECTOR & cd, unsigned int) {
> using boost::serialization::make_nvp;
> using boost::serialization::make_array;
> float app[6];
> for(int i=0;iaddType( new
> RTT::types::StructTypeInfo("VECTOR") );
>
> RTT::types::Types()->addType( new RTT::types::StructTypeInfo("robotTarget")
> );
>
> When I start the ReportingComponent I have a segmentation fault. Any idea?
> Thanks
> D.
> --
>

I just have had the same problem yesterday on another case but I didn't
investigate further. Could you please provide the callstack when
segfaulting ?

There is maybe tools for generating typekits automatically to prevent user
code errors (orogren ? typegen ?)

> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

Armadillo and Typekit in c++

Thanks for you answer. This is the callstack: Reporting [S]> start

Program received signal SIGSEGV, Segmentation fault. 0xf8bff3c0 in ?? () (gdb) backtrace

  1. 0 0xf8bff3c0 in ?? ()
  2. 1 0xb7a240d8 in ~MutexLock (this=Cannot access memory at address 0x7

) at /usr/local/src/orocos/orocos-toolchain/rtt/rtt/os/MutexLock.hpp:71

  1. 2 RTT::types::TypeInfoRepository::getTypeById (this=Cannot access memory at address 0x7

) at /usr/local/src/orocos/orocos-toolchain/rtt/rtt/types/TypeInfoRepository.cpp:110 Cannot access memory at address 0x3

Armadillo and Typekit in c++

I added the line RTT::types::Types()->addType( new CArrayTypeInfo<types::carray< fcolvec > >("fcolvec[]") ); and now I have

Reporting [S]> start OrocosUnisa-lxrt: /usr/local/src/orocos/orocos-toolchain/install/include/rtt/types/type_discovery.hpp:195: bool RTT::types::type_discovery::referenceMember(RTT::internal::Reference*, T&, std::string) [with T = arma::Col<float>::fixed<20u>]: Assertion `ref' failed.

Program received signal SIGABRT, Aborted. 0xb7fe2424 in __kernel_vsyscall () (gdb) backtrace

  1. 0 0xb7fe2424 in __kernel_vsyscall ()
  2. 1 0xb6900681 in raise () from /lib/tls/i686/cmov/libc.so.6
  3. 2 0xb6903ab2 in abort () from /lib/tls/i686/cmov/libc.so.6
  4. 3 0xb68f9748 in __assert_fail () from /lib/tls/i686/cmov/libc.so.6
  5. 4 0x082c2b49 in RTT::types::StructTypeInfo<arma::Col<float>::fixed<20u>, false>::getMember(RTT::internal::Reference*, boost::intrusive_ptr<RTT::base::DataSourceBase>, std::string const&) const ()
  6. 5 0xb76e8cab in RTT::types::TypeInfo::getMember (dsb=..., targetbag=..., resized=...)

    at /usr/local/src/orocos/orocos-toolchain/install/include/rtt/internal/../types/TypeInfo.hpp:345
  1. 6 OCL::memberDecomposition (dsb=..., targetbag=..., resized=...)

    at /usr/local/src/orocos/orocos-toolchain/ocl/reporting/ReportingComponent.cpp:115
  1. 7 0xb76e8e02 in OCL::memberDecomposition (dsb=..., targetbag=..., resized=...)

    at /usr/local/src/orocos/orocos-toolchain/ocl/reporting/ReportingComponent.cpp:123
  1. 8 0xb76ea383 in OCL::ReportingComponent::makeReport2 (this=0x84402c0)

    at /usr/local/src/orocos/orocos-toolchain/ocl/reporting/ReportingComponent.cpp:617
  1. 9 0xb76ea9c9 in OCL::ReportingComponent::startHook (this=0x84402c0)

    at /usr/local/src/orocos/orocos-toolchain/ocl/reporting/ReportingComponent.cpp:552
  1. 10 0xb76e6996 in OCL::FileReporting::startHook (this=0x84402c0)

    at /usr/local/src/orocos/orocos-toolchain/ocl/reporting/FileReporting.cpp:39
  1. 11 0xb7a05af7 in RTT::base::TaskCore::start (this=0x84402c0)

    at /usr/local/src/orocos/orocos-toolchain/rtt/rtt/base/TaskCore.cpp:196
  1. 12 0xb79b2a32 in RTT::TaskContext::start (this=0x84402c0)

    at /usr/local/src/orocos/orocos-toolchain/rtt/rtt/TaskContext.cpp:405
  1. 13 0xb79b9090 in boost::_mfi::mf0<bool, RTT::TaskContext>::operator() (function_obj_ptr=...)

    at /usr/include/boost/bind/mem_fn_template.hpp:49
  1. 14 operator()<bool, boost::_mfi::mf0<bool, RTT::TaskContext>, boost::_bi::list0> (function_obj_ptr=...)

    at /usr/include/boost/bind/bind.hpp:236
  1. 15 boost::_bi::bind_t<boost::_bi::unspecified, boost::_mfi::mf0<bool, RTT::TaskContext>, boost::_bi::list1<boost::_bi::value<RTT::TaskContext*> > >::operator() (function_obj_ptr=...)

    at /usr/include/boost/bind/bind_template.hpp:20
  1. 16 boost::detail::function::function_obj_invoker0<boost::_bi::bind_t<boost::_bi::unspecified, boost::_mfi::mf0<bool, RTT::TaskContext>, boost::_bi::list1<boost::_bi::value<RTT::TaskContext*> > >, bool>::invoke (

    function_obj_ptr=...) at /usr/include/boost/function/function_template.hpp:132
  1. 17 0x082f56f4 in RTT::internal::InvokerImpl<0, bool ()(), RTT::internal::LocalOperationCallerImpl<bool ()()> >::call() ()
  2. 18 0x082d9b73 in RTT::internal::FusedMCallDataSource<bool ()()>::evaluate() const ()
  3. 19 0xb7ab83c2 in OCL::TaskBrowser::doPrint (this=0xbfffef74, ds=DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjuction with DW_OP_piece.

)

    at /usr/local/src/orocos/orocos-toolchain/ocl/taskbrowser/TaskBrowser.cpp:1501
  1. 20 0xb7ab82d3 in OCL::TaskBrowser::printResult (this=0xbfffef74, ds=0x8469a70, recurse=true)

    at /usr/local/src/orocos/orocos-toolchain/ocl/taskbrowser/TaskBrowser.cpp:1484
  1. 21 0xb7abe207 in OCL::TaskBrowser::evalCommand (this=0xbfffef74, comm=...)

what I miss?