GUI from within a Stage CTRL plugin?

View: New views
6 Messages — Rating Filter:   Alert me  

GUI from within a Stage CTRL plugin?

by Tyler Gunn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm coding up a control plugin for Stage and would like to provide my  
own UI from within.  I've tried using FLTK within my plugin to create  
a simple window.

Under Linux, it works fine.
However, under OS X, I need to run Fl::run in my plugin or the window  
doesn't display.  When it does display, the window from my plugin is  
VERY unstable; crashing at random when I select menu items.  I suspect  
the two Fl:run calls present in the same address space is messing  
things up.

SO, I've managed to get a GTK+ window up and running from within my  
plug.  But I'm curious, has anyone done something like this before?    
Any reason why this won't work?


My other thought was to have a standalone gui app that my plugin  
communicates with over sockets, but since one of my goals is to  
display the maps that a robot builds, I figure sockets would introduce  
an unnecessary speed penalty.

Thanks,
Tyler

--
Tyler Gunn
University of Manitoba
tyler@...




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users

Re: GUI from within a Stage CTRL plugin?

by Geoff Biggs :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A standalone GUI would probably be more stable, more responsive, and
easier to maintain. If you're only interested in POSIX systems (this
includes Linux and OSX), you can use a FIFO instead of a socket. They
are programmatically simpler to use, but the speed difference is likely
to be negligible when running both on the same system (at least in
Linux, anyway, where it skips the networking stack for loopback
addresses), and it also isn't likely to be less responsive than having
it in Stage's update loop.

Using a socket would give you the ability to run your GUI non-locally,
though, which a FIFO can't do. This could be useful if you want to run
your simulation on a faster remote computer.

Geoff

Tyler Gunn wrote:
> My other thought was to have a standalone gui app that my plugin  
> communicates with over sockets, but since one of my goals is to  
> display the maps that a robot builds, I figure sockets would introduce  
> an unnecessary speed penalty.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users

Re: GUI from within a Stage CTRL plugin?

by Tyler Gunn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 2009-11-09, at 9:21 PM, gbiggs wrote:

> A standalone GUI would probably be more stable, more responsive, and
> easier to maintain. If you're only interested in POSIX systems (this
> includes Linux and OSX), you can use a FIFO instead of a socket. They
> are programmatically simpler to use, but the speed difference is  
> likely
> to be negligible when running both on the same system (at least in
> Linux, anyway, where it skips the networking stack for loopback
> addresses), and it also isn't likely to be less responsive than having
> it in Stage's update loop.
>
> Using a socket would give you the ability to run your GUI non-locally,
> though, which a FIFO can't do. This could be useful if you want to run
> your simulation on a faster remote computer.


Thanks for the response Geoff,
I put the GTK+ main event loop in a thread my controller spawns.   It  
seems to work, but it just doesn't feel right to me.
I'm definitely only worried about linux and Mac as this is the primary  
development target for my project.  I'm going to look into FIFOs for  
IPC, and see if they'd suit my needs.  I'm not too concerned about  
running my GUI on a different machine that the simulation as  
everything will be on one machine (my Mac Pro).

I'll rethink this and probably use a FIFO, or some other form of IPC.

Thanks,
Tyler


--
Tyler Gunn
tyler@...
http://www.egunn.com/




------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users

Re: GUI from within a Stage CTRL plugin?

by Geoff Biggs :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You should consider also making your GUI a separate application. This
will isolate your simulation from crashes in the GUI (i.e. if the GUI
thread crashes, you have to restart the whole application, but if a
separate app crashes, you just restart the GUI).

Geoff

Tyler Gunn wrote:

> Thanks for the response Geoff,
> I put the GTK+ main event loop in a thread my controller spawns.   It  
> seems to work, but it just doesn't feel right to me.
> I'm definitely only worried about linux and Mac as this is the primary  
> development target for my project.  I'm going to look into FIFOs for  
> IPC, and see if they'd suit my needs.  I'm not too concerned about  
> running my GUI on a different machine that the simulation as  
> everything will be on one machine (my Mac Pro).
>
> I'll rethink this and probably use a FIFO, or some other form of IPC.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users

Re: GUI from within a Stage CTRL plugin?

by Richard Vaughan-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 9, 2009 at 7:14 PM, Tyler Gunn <tyler@...> wrote:

> I'm coding up a control plugin for Stage and would like to provide my
> own UI from within.  I've tried using FLTK within my plugin to create
> a simple window.
>
> Under Linux, it works fine.
> However, under OS X, I need to run Fl::run in my plugin or the window
> doesn't display.  When it does display, the window from my plugin is
> VERY unstable; crashing at random when I select menu items.  I suspect
> the two Fl:run calls present in the same address space is messing
> things up.


I think Fl::Run never returns, so you may be calling it recursively,
which would explain the bad behaviour.

Do you know why there's a difference between Linux and OSX? Is Stage
doing something wrong that I can fix?

- rtv



> SO, I've managed to get a GTK+ window up and running from within my
> plug.  But I'm curious, has anyone done something like this before?
> Any reason why this won't work?
>
>
> My other thought was to have a standalone gui app that my plugin
> communicates with over sockets, but since one of my goals is to
> display the maps that a robot builds, I figure sockets would introduce
> an unnecessary speed penalty.
>
> Thanks,
> Tyler
>
> --
> Tyler Gunn
> University of Manitoba
> tyler@...
>
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Playerstage-users mailing list
> Playerstage-users@...
> https://lists.sourceforge.net/lists/listinfo/playerstage-users
>



--
Richard Vaughan
Autonomy Lab / Computing Science / Simon Fraser University

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users

Re: GUI from within a Stage CTRL plugin?

by Tyler Gunn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I think Fl::Run never returns, so you may be calling it recursively,
> which would explain the bad behaviour.

I had set it up so that my controller just calls "Fl:run" in a
new thread it creates; that way it would only get called one.

> Do you know why there's a difference between Linux and OSX? Is Stage
> doing something wrong that I can fix?

I'm not 100% sure what the difference is.  My working hypothesis is that
it has something to do with how libtool loads in the plugins on each
platform.

FLTK keeps a global static object with all kinds of state information in
it.  I suspect on linux, when my plugin loads in that its able to access
the global static state object and thus works fine.

In OS X it appears that the global state is not available, requiring the
creation of one local to the plugin.

I need to dig into it in more depth to determine for sure what is going
on; it could also be how I'm linking FLTK into my plugin and into stage
(static linking).

Thanks,
Tyler

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-users mailing list
Playerstage-users@...
https://lists.sourceforge.net/lists/listinfo/playerstage-users