[Rock-dev] Types in Ruby, Constructor, initial values

Alexander Duda Alexander.Duda at dfki.de
Mon May 6 14:22:46 CEST 2013


On 05/06/2013 01:53 PM, Felix Rehrmann wrote:
> Hi,
>
> when instantiating Rock Types in Ruby like
>
> a = Type::TypeToVector::PortConfig (defined like below)
>
> the constructor is not called, so values are uninitialized.
>
> Is there any way, to set initial values for a Rock type instantiated in
> ruby?
Typelib does not support any struct/class methods. You have to manually 
initialize it from ruby. You can have a look at Typelib.specialize_model 
to add functions to typelib types like for example it is done for 
RigidBodyState.

# returns a RigidBodyState with all values initialized to NaN
pp t = Types::Base::RigidBodyState.invalid

#you can also use zero! to initialize everything to zero which is 
defined for all types
pp t.zero!

Alex

>
> Felix
>
>
> namespace type_to_vector {
>
> struct PortConfig {
>
>       std::string portname; //!< Name the port should have.
>       std::string type; //!< Name of the type the port should handle.
>       std::string slice; //!< Gives the part of a type that should be
> used in a vector.
>       int vectorIdx; //!< The vector to add the port's data to.
>       double period; //!< Sample rate in seconds. (0 if unknown or not
> periodic).
>       bool useTimeNow; //!< Use time now to stamp unstamped data.
>
>       PortConfig() :
>           portname(""),
>           type(""),
>           slice(""),
>           vectorIdx(0),
>           period(0.0),
>           useTimeNow(true) {}
>
> };
> }
> _______________________________________________
> Rock-dev mailing list
> Rock-dev at dfki.de
> http://www.dfki.de/mailman/cgi-bin/listinfo/rock-dev


-- 
Dipl.-Ing. Alexander Duda
Unterwasserrobotik

DFKI Bremen
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany

Phone: +49 (0)421 178-456620
Fax:   +49 (0)421 178-454150
E-Mail: alexander.duda at dfki.de

Weitere Informationen: http://www.dfki.de/robotik
-----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.:    DE 148646973
Steuernummer:  19/673/0060/3



More information about the Rock-dev mailing list