Skip to content

Privacy Zones Workflow

Suzanne Dazo edited this page Aug 11, 2014 · 2 revisions

Style Guide

UI items should specify what kind of object it is in the object name.

  • This is most important for buttons, least important for frames, spacers, and layouts.
    • stop_btn
    • export_img_btn
    • listItems_group
    • redColor_radio_btn
    • toolbar_vLayout

Variable Names

  • Use descriptive names. No "blah, foo, whatevs"
    • temporary variables such as those used in for loops are okay
    • i, j, index, and temp are preferred in those cases
  • Naming style can be variable_name or variableName
  • x, y, and z are for coordinates only

Commenting Function Definitions

  • Place comments detailing the purpose and output of a function before the definition
  • If the inputs are vague, detail those as well.

Encapsulation

Try to maintain organization between the Main Window (privacyZones.py) and its parts (components.py) If you are modifying signals, slots, or the functionality of the main UI, modify privacyZones.py

If you are creating a new component that is not a modification of the UI, modify components.py

If you are creating a modification that will be inherited by the UI, create a class in a separate file

  • customview.py
    • It is a modification of the QGraphicsView used in the UI to add mouse wheel functionality.
    • It is a part of the interface, not the underlying functionality
    • Looking at the UI File (pointSelect.py) the map_view inherits from customView instead of QGraphicsView

Existing Classes

DrawMap (Inherits from QGraphicsScene)

Draw map is used to register clicks placed into the scene, and it is what loads the map file. It is where markers and lines are added upon each click.

ZoneHandler

This handles the visual markers for the zone as well as a list of Zones.

  • Storage for markers, lines, and zones.
  • Importing of Zones to the overall list
  • Exporting all data

If you want to deal with the lines, markers, or the group of zones as a whole (not the individual) work with this class.

Zone (Inherits from QGraphicsPolygonItem)

This is an individual zone. It only stores its name, privacy mode, and position. Drawing of the zone and its visibility is handled by the ZoneHandler class.
drawPoly() is essentially a modified paint event. It only changes the shape/properties of the polygon and does not control adding it to the scene. When creating a QGraphicsItem, the boundingRect() and paint() functions need to be defined. This process is skipped by having the Zone class already be a QGraphicsPolygonItem. If you work with the visible properties of the polygon (shape, color, line properties, etc) then edit the drawPoly and brushSetup functions.

DrawPoint (Inherits from QGraphicsObject)

This is the elliptical marker that is placed. Do not edit unless you are trying to fix the positioning system for these markers.

Working with QtDesigner

If you are editing the UI layout in any way, ONLY USE QtDesigner. The UI file is located in remote_nav/interfaces/pointSelect.ui When you have finished editing the UI, run the command

pyuic4 pointSelect.ui -x -o pointSelect.py

in the directory of the .ui file. Replace the existing pointSelect.py file located in the privacy_zones directory. Do not try to hand-edit the pointSelect.py file without editing the .ui file, as changes will be lost if the .ui file is converted to the .py file at a later time.

You can edit the individual properties of each object in the init of privacyZones.py

What you need to know

To work on this project, you should know these things:

  • Python
  • ROS and how the /map frame works in rViz
  • PyQT or PySide (The PySide documentation is easier to understand from a Python developers' standpoint)
    • How to use QtDesigner
    • Signals and Slots
    • Creating a custom class inheriting from QGraphicsObject or QGraphicsItem
    • The positioning system in QGraphicsScene
  • the YAML library
    • how safe_load and dump works
    • How to get info out of the objects created through YAML

Clone this wiki locally