PC based robot design -- musings



As I am working on the robot software. You make changes here and there, and
you start to think about how to make things easier/better etc.

My main PID loop has been rewritten to be more of a time slice mechanism for
various periodic systems. (I'll post new code on www.linuxpcrobot.org when
it is in a form I'm satisfied with)

Baically, it has been redesigned to accept task objects and a run priority.
The PID object runs every time, but things like the keyboard scanner runs
much less often, the report object runs MUCH less often.

I typically would have the OS do this sort of thing, but there are so many
periodic tasks, I would have so many small tasks calling usleep(). This
way, I can have a bit more control when certain functions are run in
relation to others. I'm not convinced that this is any more efficient, but
it does provide a flexable system I could move to threads or processes if I
want.

I know this is not rocket science, and there are probably many
implementations of it out there, but I started thinking...

The task objects have only a few virtul API entry points, these could easily
be wrapped in a UNIX shared library or Windows DLL. Outside a few control
API functions, there are three operational funtions:

Boolean Init()
Boolean Handler(int usec)
Boolean Shutdown()

Init is called to initialze the object "in system" but outside timing loop.
By returning FALSE, the object can indicate it could not be initialized and
should not run.

Handler is called periodically according to system load and priority. The
"usec" variable is a precision measurement of elapsed time since its last
run. If the funtion return FALSE, it is removed from the task list and its
Shutdown function is called.

Shutdown is called when the object is not longer being used and no longer
scheduled. If the object is shutdown successfully, the function should
return TRUE, otherwise FALSE. Currently the return value is ignored.

My thought is that functionality is added to the robot via this API and end
users (developer/users) simply make a shared library (or DLL or COM object
for Windos) that provides these entry points.

What do you think?
.



Relevant Pages

  • Re: WM_QUERYENDSESSION
    ... Add a handler for WM_ENDSESSION too. ... CTRL_SHUTDOWN_EVENT signal from system. ... you can play with SetProcessShutdownParameters API ... >> Try to call the API from your app and see if it works on your runtime. ...
    (microsoft.public.windowsxp.embedded)
  • Which Logoff/Shutdown API should I call?
    ... off or shutdown a computer. ... I need to write a script that would check for VMware's ... I've found four different API calls/messages and I really ... cancel or abort this call? ...
    (microsoft.public.windows.server.general)
  • Re: how to end a thread from the main thread
    ... Suppose for this example I have a boolean, ThreadRunning, on behalf of a view. ... >> See my essay on worker threads on my MVP Tips site. ... >The only place I ever truely wait on the handle is on shutdown events ... >User initiates shutdown ...
    (microsoft.public.vc.mfc)
  • Re: IOCTL access to the HIDCLASS
    ... attached/detached USB device. ... But when we shutdown the PC, our software sometimes freezes after ... HidD_GetPreparsedData API will generate IOCTL for HIDCLASS. ... the SetupDiGetDeviceRegistryProperty API, not calling the ...
    (microsoft.public.development.device.drivers)
  • RE: How do we know when Windows goes to Standby mode?
    ... there is an API SetSuspendState which enable you switch ... For how to shutdown/Logoff the system, you may use API ... ExitWindows/ExitWindowsEx, however On windows 2000 and later system, if you ... There is also a sample to show you how to shutdown the system, ...
    (microsoft.public.dotnet.framework)