loading
 
Getting a boolean variable for target identification
Toyalima from United States  [1 posts]
4 years
Hi, I am trying to get a boolean result from the network table of roborealm, so that, when the camera identifies the goal, the variable output is yes or no (true/false). But I really don't know how to. It will be extremely helpful if you can suggest a way.
Steven Gentner from United States  [1371 posts] 4 years
Toyalima,

It partly depends on how you are detecting the target and what variables would get set or not if a target is present. For example, if you use the one in the tutorials the presence or absence of the BFR_COORDINATES. For example you could modify the VBScript slightly to add a variable like:

list = GetArrayVariable("BFR_COORDINATES")
if isArray(list) then
  if ubound(list) > 0 then

    SetVariable "/SmartDashboard/Target_Seen", 1

    ... other code to get distance ...

  else
    SetVariable "/SmartDashboard/Target_Seen", 0
  end if
else
  SetVariable "/SmartDashboard/Target_Seen", 0
end if

which when that variable does not contain a valid array (i.e. no target is seen) the variable /SmartDashboard/Target_Seen will be set accordingly. When you run this, you can then edit the NT module and add that variable to be sent. Then in your CRio or other system you can pick up on that value.

Note that it is necessary to include the 'else' statements which are currently not in the current VBScript since those are needed to ensure that the variable is set to 0 when the target goes missing. Alternatively, you could also set

SetVariable "Distance", 0

and trigger of a zero value for the distance as to if a target is seen or not. Either way should work.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index