[Rock-dev] Syskit::Composition child access within own methods
Christian Rauch
Christian.Rauch at dfki.de
Wed Nov 20 20:26:32 CET 2013
Hi,
in syskit I am inheriting from a composition, which relies on methods,
that are not yet implemented in the base class:
{{{
class TriggerIF < Syskit::Composition
attr_accessor :name
attr_accessor :sources
attr_accessor :block
def initialize(options)
super(options)
@trigger = nil
@name = get_name
@sources = get_sources
@block = get_block
end
# add trigger
on(:start) do |ev|
@trigger = @rl.trigger(@name, @sources, @block)
end
# remove trigger
on(:stop) do |ev|
@rl.remove_trigger(@trigger)
end
def get_name
puts "get_name: Implement me!"
nil
end
def get_sources
puts "get_sources: Implement me!"
nil
end
def get_block
puts "get_block: Implement me!"
nil
end
end
}}}
In a composition derived from TriggerIF, these methods are defined:
{{{
class GyroTrigger < Virgo::TriggerIF
add Virgo::VectorDoubleTimedSrv, :as => 'sync'
def get_name
"gyro_trigger"
end
def get_sources
sync_child.as(Virgo::VectorDoubleTimeSrv).vector_timed_port
end
end
}}}
The problem here is that 'sync_child' is not yet known when the
Composition GyroTrigger is created:
{{{
Roby::NoSuchChild: gyro_trigger{}[] has no child with the role 'sync'
}}}
As the on(:start) of the base class is called first, I cannot define
this in the on(:start) of the inheriting composition.
Is there a way to access own children within self define methods?
Or is there another way to tell the base class about the children and
ports of the deriving class?
Regards,
Christian
--
Christian Rauch
Space Robotics
Universität Bremen
FB 3 - Mathematik und Informatik
AG Robotik
Robert-Hooke-Straße 5
28359 Bremen, Germany
Tel: +49 (0)421 178 45-6619
Empfang: +49 (0)421 178 45-6611
Fax: +49 (0)421 178 45-4150
E-Mail: Christian.Rauch at dfki.de
Weitere Informationen: http://www.informatik.uni-bremen.de/robotik
More information about the Rock-dev
mailing list