Applications

specEditor.py - Specification Editor

A development environment for specifications written in structured English, allowing for editing, compilation, and execution/simulation

class specEditor.AnalysisResultsDialog(parent, *args, **kwds)
appendLog(text, color='BLACK')
markFragments(agent, section, jx=None)
onButtonClose(event)
onClickRefineAnalysis(event)
populateTree(gentree)
class specEditor.MapDialog(parent, *args, **kwds)

A simple little dialog that displays the regions on top of the map so that you can select a region visually instead of just choosing the name.

drawMap(event)
onMapClick(event)
class specEditor.RedirectText(parent, aWxTextCtrl)

A class that lets the output of a stream be directed into a text box.

http://mail.python.org/pipermail/python-list/2007-June/445795.html

write(string)
class specEditor.SpecEditorFrame(*args, **kwds)

The main application window!

appendLog(text, color='BLACK')
askIfUserWantsToSave(action)

Give the user the opportunity to save the current document.

‘action’ is a string describing the action about to be taken. If the user wants to save the document, it is saved immediately. If the user cancels, we return False.

From pySketch example

doClose(event)

Respond to the “Close” menu command.

drawLocMap(event)

Respond to a request to redraw the contents of the decomposed map

highlight(l, type)
highlightCores(guilty, compiler)
initializeNewSpec()
onClickEditRegions(event)
onImportRegion(event)

Ask the user for a region file and then import it.

onLocPhraseSelect(event)
onMapSelect(event)

Show the map with overlayed regions so that the user can select a region name visually.

onMenuAbout(event)
onMenuAnalyze(event)
onMenuCompile(event)
onMenuConfigSim(event)
onMenuCopy(event)
onMenuCut(event)
onMenuMopsy(event)
onMenuNew(event)

Create a new specification.

onMenuOpen(event)

Ask the user for a specification file to open, and then open it.

onMenuPaste(event)
onMenuQuit(event)
onMenuRedo(event)
onMenuSave(event=None)

If the file has been saved already, save it quietly. Else, ask for a filename and then save it.

onMenuSaveAs(event)

Ask the user for a filename to save the specification as, and then save it.

onMenuSetCompileOptions(event)
onMenuSimulate(event)

Run the simulation with current experiment configuration.

onMenuUndo(event)
onMenuViewAut(event)
onMouseDwellEnd(event)
onMouseDwellStart(event)
onPropAdd(event)

Display a dialog asking for a proposition name and then add it to the appropriate proposition list.

onPropRemove(event)

Remove the selected proposition from the list.

onPropToggle(event)
onPropositionDblClick(event)

Add the proposition name to the spec when you double click the name

onRegionLabelStyleChange(event)
onSpecTextChange(event)
onStyleNeeded(e)
openFile(filename)
refineAnalysis()
updateFromRFI()

Update the GUI to reflect a newly loaded region file

class specEditor.WxAsynchronousProcessThread(cmd, callback, logFunction)

Make sure callbacks from AsynchronousProcessThreads are safe for threading in wx by wrapping with a wx.CallAfter.

regionEditor.py - Region Editor

A simple polygonal region editor. The code is kind of a mess, but it does what it needs to do.

Based on pySketch by Erik Westra (ewestra@wave.co.nz) and Bill Baxter (wbaxter@gmail.com)

class regionEditor.DrawingFrame(parent, id, title, fileName=None)

A frame showing the contents of a single document.

askIfUserWantsToSave(action)

Give the user the opportunity to save the current document.

‘action’ is a string describing the action about to be taken. If the user wants to save the document, it is saved immediately. If the user cancels, we return False.

checkSubfaces(obj)
createPoly(points)

Create poly object.

createRect(x, y, width, height)

Create a new rectangle object at the given position and size.

deselectAll()

Deselect every Region in our document.

doChooseAddPtTool(event=None)

Respond to the “Poly Tool” menu command.

doChooseCalibPtTool(event=None)

Respond to the “Toggle Calibration Point Tool” menu command.

doChooseDelPtTool(event=None)

Respond to the “Poly Tool” menu command.

doChoosePolyTool(event=None)

Respond to the “Poly Tool” menu command.

doChooseRectTool(event=None)

Respond to the “Rect Tool” menu command.

doChooseSelectTool(event=None)

Respond to the “Select Tool” menu command.

doClose(event)

Respond to the “Close” menu command.

doDelete(event=None)

Respond to the “Delete” menu command.

doDuplicate(event)

Respond to the “Duplicate” menu command.

doEditRegion(event=None)

Respond to the “Edit Region” menu command.

doExit(event)

Respond to the “Quit” menu command.

doMakeBoundary(event)
doNew(event)

Respond to the “New” menu command.

doOpen(event)

Respond to the “Open” menu command.

doRevert(event)

Respond to the “Revert” menu command.

doSave(event=None)

Respond to the “Save” menu command.

doSaveAs(event)

Respond to the “Save As” menu command.

doSelectAll(event)

Respond to the “Select All” menu command.

doSetBackground(event=None)
doShowAbout(event)

Respond to the “About Region Editor” menu command.

doUndo(event)

Respond to the “Undo” menu command.

drawRegions(dc, pdc, drawLabels=True, drawAdjacencies=True)
getProjectDir()

Make sure we’ve saved our region file somewhere so that our project directory and project name are defined.

loadContents()

Load the contents of our document into memory. Note that the drawing order of regions is last to first.

onDoubleClickEvent(event)

Respond to a double-click within our drawing panel.

onKeyEvent(event)

Respond to a keypress event.

We make the arrow keys move the selected object(s) by one pixel in the given direction.

onMouseEvent(event)

Respond to the user clicking on our main drawing panel.

How we respond depends on the currently selected tool.

onPaintEvent(event)

Respond to a request to redraw the contents of our drawing panel.

onRightClick(event)

Respond to the user right-clicking within our drawing panel.

We select the clicked-on item, if necessary, and display a pop-up menu of available options which can be applied to the selected item(s).

onTimerEvent(event)
onToolIconClick(event)

Respond to the user clicking on one of our tool icons.

recalcAdjacency()

Call the RegionFileInterface’s recalcAdjacency() method to figure out where to draw dotted transition lines

saveContents()

Save the contents of our document to disk.

select(obj)

Select the given Region within our document.

selectAll()

Select every Region in our document.

selectByRectangle(x, y, width, height)

Select every Region in the given rectangular region.

selectMany(objs)

Select the given list of Regions.

testBetween()
testNear()
class regionEditor.EditRegionDialog(parent, title)

Dialog box used to edit the properties of a region.

The user can edit the region’s name and color.

dialogToObject(obj)

Copy the properties from the dialog box into the given text object.

objectToDialog(obj)

Copy the properties of the given text object into the dialog box.

class regionEditor.ExceptionHandler

A simple error-handling class to write exceptions to a text file.

Under MS Windows, the standard DOS console window doesn’t scroll and closes as soon as the application exits, making it hard to find and view Python exceptions. This utility class allows you to handle Python exceptions in a more friendly manner.

write(s)

Write the given error message to a text file.

Note that if the error message doesn’t end in a carriage return, we have to buffer up the inputs until a carriage return is received.

class regionEditor.SketchApp

The main pySketch application object.

OnInit()

Initialise the application.

class regionEditor.TextObjectValidator

This validator is used to ensure that the user has entered something into the text object editor dialog’s text field.

Clone()

Standard cloner.

Note that every validator must implement the Clone() method.

TransferFromWindow()

Transfer data from window to validator.

The default implementation returns False, indicating that an error occurred. We simply return True, as we don’t do any data transfer.

TransferToWindow()

Transfer data from validator to window.

The default implementation returns False, indicating that an error occurred. We simply return True, as we don’t do any data transfer.

Validate(win)

Validate the contents of the given text control.

class regionEditor.ToolPaletteIcon(parent, iconID, iconName, toolTip)

An icon appearing in the tool palette area of our sketching window.

Note that this is actually implemented as a wx.Bitmap rather than as a wx.Icon. wx.Icon has a very specific meaning, and isn’t appropriate for this more general use.

deselect()

Deselect the icon.

The icon’s visual representation is updated appropriately.

select()

Select the icon.

The icon’s visual representation is updated appropriately.

regionEditor.main()

Start up the pySketch application.

class configEditor.addRobotDialog(parent, *args, **kwds)
onChangeHandler(event)
onChooseRobot(event)
onClickConfigure(event)
onClickOK(event)
onEditRobotName(event)
configEditor.drawParamConfigPane(target, method, proj)
class configEditor.handlerConfigDialog(parent, *args, **kwds)
onClickDefaults(event)
class configEditor.propMappingDialog(parent, *args, **kwds)
onClickApply(event)
onClickMapping(event)
onClickOK(event)
onEditMapping(event)
onSelectHandler(event)
onSelectProp(event)
onSelectRobot(event)
class configEditor.regionTagsDialog(parent, *args, **kwds)
onCheckRegion(event)
onClickAddTag(event)
onClickRemoveTag(event)
onClickTag(event)
class configEditor.simSetupDialog(*args, **kwds)
doClose(event)
onCheckProp(event)
onClickAddRobot(event)
onClickApply(event)
onClickCancel(event)
onClickConfigureRobot(event)
onClickEditMapping(event)
onClickEditRegionTags(event)
onClickOK(event)
onClickRemoveRobot(event)
onConfigDelete(event)
onConfigImport(event)
onConfigNew(event)
onSetMainRobot(event)
onSimLoad(event)
onSimNameEdit(event)

execute.py - Top-level hybrid controller executor

This module executes a hybrid controller for a robot in a simulated or real environment.

Usage:execute.py [-hn] [-p listen_port] [-a automaton_file] [-s spec_file]
  • The controlling automaton is imported from the specified automaton_file.
  • The supporting handler modules (e.g. sensor, actuator, motion control, simulation environment initialization, etc) are loaded according to the settings in the config file specified as current in the spec_file.
  • If no port to listen on is specified, an open one will be chosen randomly.
  • Unless otherwise specified with the -n or --no_gui option, a status/control window will also be opened for informational purposes.
class execute.LTLMoPExecutor

This is the main execution object, which combines the synthesized discrete automaton with a set of handlers (as specified in a .config file) to create and run a hybrid controller

initialize(spec_file, strategy_file, firstRun=True)

Prepare for execution, by loading and initializing all the relevant files (specification, map, handlers, strategy) If firstRun is true, all handlers will be imported; otherwise, only the motion control handler will be reloaded.

isRunning()

return whether the automaton is currently executing

loadAutFile(filename)

This function loads the the .aut/.bdd file named filename and returns the strategy object. filename (string): name of the file with path included

loadSpecFile(filename)
pause()

pause execution of the automaton

postEvent(eventType, eventData=None)

Send a notice that an event occurred, if anyone wants it

registerExternalEventTarget(address)
resume()

start/resume execution of the automaton

run()
shutdown()
class execute.RedirectText(event_handler)
flush()
write(message)
execute.execute_main(listen_port=None, spec_file=None, aut_file=None, show_gui=False)
execute.usage(script_name)

Print command-line usage information.

calibrate.py - A tool for finding the transformation between map and real coordinates

This script helps you experimentally determine the coordinate transformation between points on your region map and points in your localization system.

The specific points used for calibration are chosen in the Region Editor.

Usage:calibrate.py [spec_file]
class calibrate.CalibrateApp
OnInit()
class calibrate.CalibrateFrame(*args, **kwds)
doCalibration()
moveRobot(event, state=[False])
onButtonGo(event)
onPaint(event=None)
onResize(event)
setStepInfo(label, button)

simGUI.py - Experiment Monitor GUI

A basic user interface for watching the state of the robot during simulation/experiment, and pausing/resuming execution.

class simGUI.SimGUI_Frame(*args, **kwds)
appendLog(text, color='BLACK')
handleEvent(eventType, eventData)

Processes messages from the controller, and updates the GUI accordingly

initDialogue()
loadRegionFile(filename)
loadSpecFile(filename)
onClose(event)
onEraseBG(event)
onPaint(event=None)
onResize(event=None)
onSLURPSubmit(event)
onSimClear(event)
onSimExport(event)

Ask the user for a filename to save the Log as, and then save it.

onSimStartPause(event)
saveFile(fileName)

Write all data out to a file.