-
Notifications
You must be signed in to change notification settings - Fork 38
Debug Printing
The printf
command has also been overwritten. This functions in the same manner as the original printf
, except that it, like the original Debug.print
function, now accepts a debug level as its first argument.
If the debug level of a particular print command is less than the debug value stored in shared memory, then that print command will be displayed.
There are special functions for printing debug messages pertaining to vision. These print functions take _vision debug level_ as a first argument which is similar to the _debug level_ mentioned above but specific to vision, and also take a _vision debug mode_ as a second argument. After these two arguments, the vision print functions accept an arbitrary number of printable arguments. These are the `vprint` and `vprintf` functions.'Vision Debug Mode' values are stored in a visionmode
table within the Debug module. Vision print functions will only print a value when its debug level is less than that stored in memory and when its vision debug mode matches up with that stored in shared memory.
To set debug level, vision debug level, or vision debug mode, call the Debug.set_debuglevel(val)
, Debug.set_visiondebuglevel(val)
or Debug.set_visiondebugmode(mode)
functions, respectively. These will overwrite the value in shared memory with the new value.
To add a mode to the set of vision debug modes stored in shared memory, call Debug.add_visiondebugmode(mode)
. To remove a mode, call Debug.remove_visiondebugmode(mode)
.
visionmode = {}
visionmode.none = 0
visionmode.ball = 1
visionmode.goal = 2
visionmode.line = 4
visionmode.midfieldLandmark = 8
visionmode.freespace = 16
Inside ./Player/Vision/detectBall.lua:
...
Debug.vprint(2,1,'ground check fail');
...
Debug.vprint(1,1,'BALL DETECTED');
...
Running Lua on the robot:
> dofile('init.lua')
> require('Debug')
> Debug.set_visiondebuglevel(2)
> Debug.set_visiondebugmode(1)
-- vision process now printing:
'BALL DETECTED'
> Debug.set_visiondebugmode(0)
-- vision process now printing no debug information
> Debug.set_visiondebuglevel(3)
> Debug.set_visiondebugmode(1)
-- vision process now printing
'BALL DETECTED'
-- and
'ground check fail'