Skip to content

Allow configuring project attributes from options menu #18

Description

@OldUser101

New editions of Shepherd read "project attributes" from source files before execution. These are used to set the project name and startup options (power enable, initial servo positions). We should allow users to set these through the options menu, since it's much more ergonomic than writing this sort of thing at the top of files:

#::sheep:enable_12v:false
#::sheep:enable_5v:true
#::sheep:project_name:Test
#::sheep:servo0_pos:90

import time
import robocon.vision

C = robocon.vision.Camera()

...

Attributes are formatted like this:

#::sheep:KEY:VALUE

Where KEY and VALUE are non-empty strings, and the entire attribute string is terminated by a newline. KEY and VALUE cannot contain :, since it would obviously break parsing.

Keys Shepherd currently looks for:

Key Values Description
project_name Any non-empty string The name of the current project, set by Sheep automatically
enable_12v true or false exactly Enable 12V power on startup
enable_5v true or false exactly Enable 5V power on startup
servo0_pos Any integer between -100 and 100 inclusive Initial position of servo 0
servo1_pos Any integer between -100 and 100 inclusive Initial position of servo 1
servo2_pos Any integer between -100 and 100 inclusive Initial position of servo 2
servo3_pos Any integer between -100 and 100 inclusive Initial position of servo 3

All attributes other than project_name should be configurable. project_name is set automatically by Sheep, user editing would likely conflict.


My initial idea of user interface for this:

  • a table with each key/value pair in columns
  • "delete" button beside each row to remove the attribute
  • "new" button at the bottom to create a new row
  • "key" column contains a dropdown to select from supported key names
  • "value" column contains something appropriate for each key, e.g. toggle for booleans; up/down spin box for servos, etc.

There may be better UI for this, but I couldn't think of one at the time. Feel free to adapt it.

I have an implementation of parsing and displaying attributes in the branch sheep-metadata of this repository, one may wish to base changes off this, or write their own implementation.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions