Reading an outputport in a stateMachine

Hi,

I have a component (lwr) with an outputport (fromKRL). I can read the data on this port in the taskbrowser by 'leaving' the component. How can I access this data in a state machine function()?

doo =function(fsm)
while true do
??? 'READ intData[1] from lwr.fromKRL' ???
...
end
end

Thanks!

Bert

Reading an outputport in a stateMachine

On Mon, 15 Oct 2012, Bert Willaert wrote:

> Hi,
>
> I have a component (lwr) with an outputport (fromKRL). I can read the data on this port in the
> taskbrowser by 'leaving' the component. How can I access this data in a state machine
> function()?

Why would you want to do that...? To me it violates the "hiding" that
component provide; in other words, it is the job of the (configuration of
the) component that creates the data to generate an event (under some
configured conditions) to inform the state machine. It is not the state
machine's job to go and read ports and interpret them: too much coupling
between the components...

> doo =function(fsm)   
>     while true do
>        ??? 'READ intData[1] from lwr.fromKRL'   ???
>     ...
>     end
> end
>
> Thanks!
>
> Bert

Herman

Reading an outputport in a stateMachine

On Mon, Oct 15, 2012 at 10:24:46AM +0000, Bert Willaert wrote:
> Hi,
>
> I have a component (lwr) with an outputport (fromKRL). I can read the data on
> this port in the taskbrowser by 'leaving' the component. How can I access this
> data in a state machine function()?
>
> doo =function(fsm)
> while true do
> ??? 'READ intData[1] from lwr.fromKRL' ???
> ...
> end
> end

Are you using rFSM or traditional RTT FSM ? What exactly are you
trying to do?

Markus

Reading an outputport in a stateMachine

to Charles: the datatype of the outputport is a custom structure (tFriKrlData). A typekit is generated for this type but still the functionality in the taskbrowser is apparently limited, i.e. last() cannot be used for this datatype. As far as I know, the way to read this data in the taskbrowser is:

cd lwr
leave lwr
var tFriKrlData sample
fromKRL.read(sampe)

to Markus: I would like to know for both types of fsm :) I guess the above is clarifying what I want to do?

________________________________________
Van: Markus Klotzbuecher [markus [dot] klotzbuecher [..] ...]
Verzonden: maandag 15 oktober 2012 13:14
To: Bert Willaert
Cc: orocos-users [..] ...
Onderwerp: Re: [Orocos-users] Reading an outputport in a stateMachine

On Mon, Oct 15, 2012 at 10:24:46AM +0000, Bert Willaert wrote:
> Hi,
>
> I have a component (lwr) with an outputport (fromKRL). I can read the data on
> this port in the taskbrowser by 'leaving' the component. How can I access this
> data in a state machine function()?
>
> doo =function(fsm)
> while true do
> ??? 'READ intData[1] from lwr.fromKRL' ???
> ...
> end
> end

Are you using rFSM or traditional RTT FSM ? What exactly are you
trying to do?

Markus

Reading an outputport in a stateMachine

2012/10/15 Bert Willaert <Bert [dot] Willaert [..] ...>

> to Charles: the datatype of the outputport is a custom structure
> (tFriKrlData). A typekit is generated for this type but still the
> functionality in the taskbrowser is apparently limited, i.e. last() cannot
> be used for this datatype. As far as I know, the way to read this data in
> the taskbrowser is:
>
> cd lwr
> leave lwr
> var tFriKrlData sample
> fromKRL.read(sampe)
>

What you actually do here (under the scene) is that you create an InputPort
outside the component, connect it to the fromKRL OutputPort, and read what
is sent.

I don't understand what your 'last' would not work because of your
typekit... if the read returns an understood type, should be the same for
last!

>
> to Markus: I would like to know for both types of fsm :) I guess the above
> is clarifying what I want to do?
>
>
> ________________________________________
> Van: Markus Klotzbuecher [markus [dot] klotzbuecher [..] ...]
> Verzonden: maandag 15 oktober 2012 13:14
> To: Bert Willaert
> Cc: orocos-users [..] ...
> Onderwerp: Re: [Orocos-users] Reading an outputport in a stateMachine
>
> On Mon, Oct 15, 2012 at 10:24:46AM +0000, Bert Willaert wrote:
> > Hi,
> >
> > I have a component (lwr) with an outputport (fromKRL). I can read the
> data on
> > this port in the taskbrowser by 'leaving' the component. How can I
> access this
> > data in a state machine function()?
> >
> > doo =function(fsm)
> > while true do
> > ??? 'READ intData[1] from lwr.fromKRL' ???
> > ...
> > end
> > end
>
> Are you using rFSM or traditional RTT FSM ? What exactly are you
> trying to do?
>
> Markus
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

Ruben Smits's picture

Reading an outputport in a stateMachine

On Mon, Oct 15, 2012 at 2:38 PM, Charles Lesire-Cabaniols
<charles [dot] lesire [..] ...> wrote:
>
>
> 2012/10/15 Bert Willaert <Bert [dot] Willaert [..] ...>
>>
>> to Charles: the datatype of the outputport is a custom structure
>> (tFriKrlData). A typekit is generated for this type but still the
>> functionality in the taskbrowser is apparently limited, i.e. last() cannot
>> be used for this datatype. As far as I know, the way to read this data in
>> the taskbrowser is:
>>
>> cd lwr
>> leave lwr
>> var tFriKrlData sample
>> fromKRL.read(sampe)
>
>
> What you actually do here (under the scene) is that you create an InputPort
> outside the component, connect it to the fromKRL OutputPort, and read what
> is sent.
>
> I don't understand what your 'last' would not work because of your
> typekit... if the read returns an understood type, should be the same for
> last!
>
>>
>>
>> to Markus: I would like to know for both types of fsm :) I guess the above
>> is clarifying what I want to do?
>>

If it's in rFSM just create a local anticloned port:

fromkrl = rttlib.port_clone_conn(lwr:getPort("fromKRL"))

And read it whenever you like:

krldata = rtt.Variable("tFriKrlData")
krldata = fromkrl:read(krldata)

If it's in the oldstyle use the last function:

fromkrldata = lwr.fromKRL.last()

Ruben

>>
>> ________________________________________
>> Van: Markus Klotzbuecher [markus [dot] klotzbuecher [..] ...]
>> Verzonden: maandag 15 oktober 2012 13:14
>> To: Bert Willaert
>> Cc: orocos-users [..] ...
>> Onderwerp: Re: [Orocos-users] Reading an outputport in a stateMachine
>>
>> On Mon, Oct 15, 2012 at 10:24:46AM +0000, Bert Willaert wrote:
>> > Hi,
>> >
>> > I have a component (lwr) with an outputport (fromKRL). I can read the
>> > data on
>> > this port in the taskbrowser by 'leaving' the component. How can I
>> > access this
>> > data in a state machine function()?
>> >
>> > doo =function(fsm)
>> > while true do
>> > ??? 'READ intData[1] from lwr.fromKRL' ???
>> > ...
>> > end
>> > end
>>
>> Are you using rFSM or traditional RTT FSM ? What exactly are you
>> trying to do?
>>
>> Markus
>> --
>> Orocos-Users mailing list
>> Orocos-Users [..] ...
>> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

Ruben Smits's picture

Reading an outputport in a stateMachine

On Mon, Oct 15, 2012 at 3:11 PM, Ruben Smits
<ruben [dot] smits [..] ...> wrote:
> On Mon, Oct 15, 2012 at 2:38 PM, Charles Lesire-Cabaniols
> <charles [dot] lesire [..] ...> wrote:
>>
>>
>> 2012/10/15 Bert Willaert <Bert [dot] Willaert [..] ...>
>>>
>>> to Charles: the datatype of the outputport is a custom structure
>>> (tFriKrlData). A typekit is generated for this type but still the
>>> functionality in the taskbrowser is apparently limited, i.e. last() cannot
>>> be used for this datatype. As far as I know, the way to read this data in
>>> the taskbrowser is:
>>>
>>> cd lwr
>>> leave lwr
>>> var tFriKrlData sample
>>> fromKRL.read(sampe)
>>
>>
>> What you actually do here (under the scene) is that you create an InputPort
>> outside the component, connect it to the fromKRL OutputPort, and read what
>> is sent.
>>
>> I don't understand what your 'last' would not work because of your
>> typekit... if the read returns an understood type, should be the same for
>> last!
>>
>>>
>>>
>>> to Markus: I would like to know for both types of fsm :) I guess the above
>>> is clarifying what I want to do?
>>>
>
> If it's in rFSM just create a local anticloned port:
>
> fromkrl = rttlib.port_clone_conn(lwr:getPort("fromKRL"))
>
> And read it whenever you like:
>
> krldata = rtt.Variable("tFriKrlData")
> krldata = fromkrl:read(krldata)

As a matter of fact you could also use the last function in rFSM:

krldata = lwr:provides("fromKRL"):last()

But I would propose to use the anticloned port.

Ruben

>
> If it's in the oldstyle use the last function:
>
> fromkrldata = lwr.fromKRL.last()
>
> Ruben
>
>
>>>
>>> ________________________________________
>>> Van: Markus Klotzbuecher [markus [dot] klotzbuecher [..] ...]
>>> Verzonden: maandag 15 oktober 2012 13:14
>>> To: Bert Willaert
>>> Cc: orocos-users [..] ...
>>> Onderwerp: Re: [Orocos-users] Reading an outputport in a stateMachine
>>>
>>> On Mon, Oct 15, 2012 at 10:24:46AM +0000, Bert Willaert wrote:
>>> > Hi,
>>> >
>>> > I have a component (lwr) with an outputport (fromKRL). I can read the
>>> > data on
>>> > this port in the taskbrowser by 'leaving' the component. How can I
>>> > access this
>>> > data in a state machine function()?
>>> >
>>> > doo =function(fsm)
>>> > while true do
>>> > ??? 'READ intData[1] from lwr.fromKRL' ???
>>> > ...
>>> > end
>>> > end
>>>
>>> Are you using rFSM or traditional RTT FSM ? What exactly are you
>>> trying to do?
>>>
>>> Markus
>>> --
>>> Orocos-Users mailing list
>>> Orocos-Users [..] ...
>>> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>>
>>
>>
>> --
>> Orocos-Users mailing list
>> Orocos-Users [..] ...
>> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>>
>
>
>
> --
> Ruben Smits, Phd
> Chief Technology Officer
> Intermodalics BVBA
> +32479511786
> www.intermodalics.eu

Reading an outputport in a stateMachine

2012/10/15 Bert Willaert <Bert [dot] Willaert [..] ...>

> Hi,
>
> I have a component (lwr) with an outputport (fromKRL). I can read the data
> on this port in the taskbrowser by 'leaving' the component. How can I
> access this data in a state machine function()?
>
> doo =function(fsm)
> while true do
> ??? 'READ intData[1] from lwr.fromKRL' ???
> ...
> end
> end
>

I guess your state machine is executed by the lwr component... in that
case, you can use fromKRL.last() to get the last value that has been
published on this port.

Charles.

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