Hi everyone,
I have three files as attachments:
1. is the deployment file
2. is the fsm file
3. a component which is implementing the state machine
I have two states in my state machine, Ping and Pong. When ever I am in my
Ping state I call an entry function pingFunction() which actually prints
some piece of text. Similarly I have an entry function for the pong state
called as pongFunction() and prints a piece of text. The problem is that if
I use my lua deployer and change the states via sending events "e_pong" and
"e_ping" I cannot see the printed output. However if I load the state
machine using "rFSM-viz" and defining the pingFunction() and
pongFunction() inside the fsm file I get the desired behaviour.
Am I missing some reference syntax? In the end I want to map these entry
functions to some operations of some other component.
Br,
Shashank
Attachment | Size |
---|---|
StateMachineTest.zip | 3.18 KB |
Calling functions in state machines
Hi Shashank,
On Tue, Jan 17, 2012 at 03:07:14PM +0100, shashank sharma wrote:
> I have three files as attachments:
>
> 1. is the deployment file
> 2. is the fsm file
> 3. a component which is implementing the state machine
>
> I have two states in my state machine, Ping and Pong. When ever I am in my Ping
> state I call an entry function pingFunction() which actually prints some piece
> of text. Similarly I have an entry function for the pong state called as
> pongFunction() and prints a piece of text. The problem is that if I use my lua
> deployer and change the states via sending events "e_pong" and "e_ping" I
> cannot see the printed output. However if I load the state machine using
> "rFSM-viz" and defining the pingFunction() and pongFunction() inside the fsm
> file I get the desired behaviour.
>
>
> Am I missing some reference syntax? In the end I want to map these entry
> functions to some operations of some other component.
You have forgotten to start your supervisor. Try adding a line
sup:start()
right after
sup:configure()
in your deploy.lua
Does that fix it?
Best regards
Markus
Calling functions in state machines
Hi Shashank,
Please keep the list on CC:
On Tue, Jan 17, 2012 at 04:30:53PM +0100, shashank sharma wrote:
> On Tue, Jan 17, 2012 at 4:06 PM, Markus Klotzbuecher <
> markus [dot] klotzbuecher [..] ...> wrote:
>
> On Tue, Jan 17, 2012 at 03:48:05PM +0100, shashank sharma wrote:
>
> > Sorry to add earlier, I indeed do
> >
> > d:start()
>
> You don't need to start the deployer.
>
>
> I start the deployer because in my application I added an output port of the
> type "string" to deployer . This output port is connected to the supervisor's
> input port called events. I send the command for events on this output port
> with:
> output.write("e_pong)
I see, but you still don't need to start it to send data via a
port. For instance, the cmd port is connected to the events and is not
part of any TaskContext. Anyway, its not the problem here.
> > sup:start()
> > while I am at the lua prompt only then my state machine starts and goes
> to the
> > Ping state without printing any thing
>
> Strange, your example seems to works OK here. I only changed the paths
> to the files and uncommented the line
>
> cmd=rttlib.port_clone_conn(sup:getPort("events"))
>
> from your example.
>
>
> I uncommented the line
> cmd=rttlib.port_clone_conn(sup:getPort("events"))
> because I intentionally wanted to send the event via the deployer component.
> But I did change it back as per your description but still I can't see any
> thing printed on the screen !
Ok. But please send exactly the same files that are not working for
you next time, otherwise we might be missing something.
> > then I write
> > output:write("e_pong")
> > and my state machine changes to state Pong but without printing the
> text.
>
> What is 'output'? I can't see that in your file. How exactly are you
> sending in the events?
>
> Please refer to above statements.
>
>
> The following works here:
>
> $ rttlua-gnulinux -i deploy.lua
> 0.035 [ Warning][DeploymentComponent::import] The ROS package 'ocl' in
> '/home/mk/src/electric/orocos_toolchain/ocl' nor its dependencies contained
> a lib/orocos directory. I'll look in the RTT_COMPONENT_PATH
> next.
> OROCOS RTTLua 1.0-beta4 / Lua 5.1.4 (gnulinux)
> INFO: created undeclared connector root.initial
> > sup:start()
> > ******* In Ping Function *************
> > cmd:write("e_pong")
> > ****************In Pong Function ***********
> > cmd:write("e_ping")
> > ******* In Ping Function *************
>
> Best regards
> Markus
>
>
> My console looks like this:
> aviator@aviator-laptop:~/orocos_test/StateMachineTest$ rosrun ocl
> rttlua-gnulinux -i ./deploy.lua
> 0.050 [ Warning][DeploymentComponent::import] The ROS package 'ocl' in '/opt/
> ros/electric/stacks/orocos_toolchain/ocl' nor its dependencies contained a lib/
> orocos directory. I'll look in the RTT_COMPONENT_PATH next.
> OROCOS RTTLua 1.0-beta4 / Lua 5.1.4 (gnulinux)
> INFO: created undeclared connector root.initial
> > sup:start()
> > in ping entry
>
> > cmd:write("e_pong")
> > in pong entry
>
> > output:write("e_ping")
> > in ping entry
>
> > output:write("e_pong")
> > in pong entry
>?
> Note: That in your output we do not see the "in pong entry" and "in ping entry"
> statements. Why?
Because you are loading the wrong fsm. Your example does not contain
the string "in ping entry" anywhere. It seems you are loading the
original example fsm instead. Please make sure you are loading your
FSM.
> Secondly, in my output after display of "in Pong entry" there is an empty line
> and I have to press enter to get the prompt back?
That's normal, remember this is a multithreaded system. The '>' is
printed before the other thread prints your message. Just ignore it.
> Lastly, It still does not print !! :(
> I have no idea why is this happening. Any suggestions? I have used the same
> files that I sent you before just uncommented the line as per you suggestion.
Please check my suggestion above.
Markus
Calling functions in state machines
Hi Markus,
Yeah I was indeed loading the wrong FSM!
On Tue, Jan 17, 2012 at 4:50 PM, Markus Klotzbuecher <
markus [dot] klotzbuecher [..] ...> wrote:
> Hi Shashank,
>
> Please keep the list on CC:
>
> On Tue, Jan 17, 2012 at 04:30:53PM +0100, shashank sharma wrote:
>
> > On Tue, Jan 17, 2012 at 4:06 PM, Markus Klotzbuecher <
> > markus [dot] klotzbuecher [..] ...> wrote:
> >
> > On Tue, Jan 17, 2012 at 03:48:05PM +0100, shashank sharma wrote:
> >
> > > Sorry to add earlier, I indeed do
> > >
> > > d:start()
> >
> > You don't need to start the deployer.
> >
> >
> > I start the deployer because in my application I added an output port of
> the
> > type "string" to deployer . This output port is connected to the
> supervisor's
> > input port called events. I send the command for events on this output
> port
> > with:
> > output.write("e_pong)
>
> I see, but you still don't need to start it to send data via a
> port. For instance, the cmd port is connected to the events and is not
> part of any TaskContext. Anyway, its not the problem here.
>
> > > sup:start()
> > > while I am at the lua prompt only then my state machine starts and
> goes
> > to the
> > > Ping state without printing any thing
> >
> > Strange, your example seems to works OK here. I only changed the
> paths
> > to the files and uncommented the line
> >
> > cmd=rttlib.port_clone_conn(sup:getPort("events"))
> >
> > from your example.
> >
> >
> > I uncommented the line
> > cmd=rttlib.port_clone_conn(sup:getPort("events"))
> > because I intentionally wanted to send the event via the deployer
> component.
> > But I did change it back as per your description but still I can't see
> any
> > thing printed on the screen !
>
> Ok. But please send exactly the same files that are not working for
> you next time, otherwise we might be missing something.
>
> > > then I write
> > > output:write("e_pong")
> > > and my state machine changes to state Pong but without printing
> the
> > text.
> >
> > What is 'output'? I can't see that in your file. How exactly are you
> > sending in the events?
> >
> > Please refer to above statements.
> >
> >
> > The following works here:
> >
> > $ rttlua-gnulinux -i deploy.lua
> > 0.035 [ Warning][DeploymentComponent::import] The ROS package 'ocl'
> in
> > '/home/mk/src/electric/orocos_toolchain/ocl' nor its dependencies
> contained
> > a lib/orocos directory. I'll look in the RTT_COMPONENT_PATH
> > next.
> > OROCOS RTTLua 1.0-beta4 / Lua 5.1.4 (gnulinux)
> > INFO: created undeclared connector root.initial
> > > sup:start()
> > > ******* In Ping Function *************
> > > cmd:write("e_pong")
> > > ****************In Pong Function ***********
> > > cmd:write("e_ping")
> > > ******* In Ping Function *************
> >
> > Best regards
> > Markus
> >
> >
> > My console looks like this:
> > aviator@aviator-laptop:~/orocos_test/StateMachineTest$ rosrun ocl
> > rttlua-gnulinux -i ./deploy.lua
> > 0.050 [ Warning][DeploymentComponent::import] The ROS package 'ocl' in
> '/opt/
> > ros/electric/stacks/orocos_toolchain/ocl' nor its dependencies contained
> a lib/
> > orocos directory. I'll look in the RTT_COMPONENT_PATH next.
> > OROCOS RTTLua 1.0-beta4 / Lua 5.1.4 (gnulinux)
> > INFO: created undeclared connector root.initial
> > > sup:start()
> > > in ping entry
> >
> > > cmd:write("e_pong")
> > > in pong entry
> >
> > > output:write("e_ping")
> > > in ping entry
> >
> > > output:write("e_pong")
> > > in pong entry
> >?
> > Note: That in your output we do not see the "in pong entry" and "in ping
> entry"
> > statements. Why?
>
> Because you are loading the wrong fsm. Your example does not contain
> the string "in ping entry" anywhere. It seems you are loading the
> original example fsm instead. Please make sure you are loading your
> FSM.
>
> > Secondly, in my output after display of "in Pong entry" there is an
> empty line
> > and I have to press enter to get the prompt back?
>
> That's normal, remember this is a multithreaded system. The '>' is
> printed before the other thread prints your message. Just ignore it.
>
> > Lastly, It still does not print !! :(
>
> > I have no idea why is this happening. Any suggestions? I have used the
> same
> > files that I sent you before just uncommented the line as per you
> suggestion.
>
> Please check my suggestion above.
>
I was trying to play around and was copying files and forgot to change the
FSM location! Sorry for the confusion :(
Thanks
Br,
Shashank
>
> Markus
>
Calling functions in state machines
Hi Markus,
Sorry to add earlier, I indeed do
d:start()
and
sup:start()
while I am at the lua prompt only then my state machine starts and goes to
the Ping state without printing any thing
then I write
output:write("e_pong")
and my state machine changes to state Pong but without printing the text.
Br,
Shashank
On Tue, Jan 17, 2012 at 3:43 PM, Markus Klotzbuecher <
markus [dot] klotzbuecher [..] ...> wrote:
> Hi Shashank,
>
> On Tue, Jan 17, 2012 at 03:07:14PM +0100, shashank sharma wrote:
>
> > I have three files as attachments:
> >
> > 1. is the deployment file
> > 2. is the fsm file
> > 3. a component which is implementing the state machine
> >
> > I have two states in my state machine, Ping and Pong. When ever I am in
> my Ping
> > state I call an entry function pingFunction() which actually prints some
> piece
> > of text. Similarly I have an entry function for the pong state called as
> > pongFunction() and prints a piece of text. The problem is that if I use
> my lua
> > deployer and change the states via sending events "e_pong" and "e_ping" I
> > cannot see the printed output. However if I load the state machine using
> > "rFSM-viz" and defining the pingFunction() and pongFunction() inside
> the fsm
> > file I get the desired behaviour.
> >
> >
> > Am I missing some reference syntax? In the end I want to map these entry
> > functions to some operations of some other component.
>
> You have forgotten to start your supervisor. Try adding a line
>
> sup:start()
>
> right after
>
> sup:configure()
>
> in your deploy.lua
>
> Does that fix it?
>
> Best regards
> Markus
>
Calling functions in state machines
On Tue, Jan 17, 2012 at 03:48:05PM +0100, shashank sharma wrote:
> Sorry to add earlier, I indeed do
>
> d:start()
You don't need to start the deployer.
> sup:start()
> while I am at the lua prompt only then my state machine starts and goes to the
> Ping state without printing any thing
Strange, your example seems to works OK here. I only changed the paths
to the files and uncommented the line
cmd=rttlib.port_clone_conn(sup:getPort("events"))
from your example.
> then I write
> output:write("e_pong")
> and my state machine changes to state Pong but without printing the text.
What is 'output'? I can't see that in your file. How exactly are you
sending in the events?
The following works here:
$ rttlua-gnulinux -i deploy.lua
0.035 [ Warning][DeploymentComponent::import] The ROS package 'ocl' in
'/home/mk/src/electric/orocos_toolchain/ocl' nor its dependencies contained a lib/orocos directory. I'll look in the RTT_COMPONENT_PATH
next.
OROCOS RTTLua 1.0-beta4 / Lua 5.1.4 (gnulinux)
INFO: created undeclared connector root.initial
> sup:start()
> ******* In Ping Function *************
> cmd:write("e_pong")
> ****************In Pong Function ***********
> cmd:write("e_ping")
> ******* In Ping Function *************
Best regards
Markus