loading
 
If a Different Object Recognized= Different Robot Action
William from United States  [2 posts]
8 year
Hello,
I have three different objects. The Object Recognition module performs excellent and if any of the three objects are recognized, my Trossen Robotics turret performs an action perfectly. I want to recognize three different objects, and if Object 1 is recognized, Action 1 is carried out; if Object 2 is recognized, Action 2 is taken, etc.  Is there a cut and paste script?
Thank you
Steven Gentner from United States  [273 posts] 8 year
There isn't a cut and paste script. Something you might consider is

http://www.roborealm.com/help/State_Machine.php

but this can also be emulated using the If_Statement

http://www.roborealm.com/help/If_Statement.php

and checking the results of the object recognition variable for specific results. You would have one "If_Statement" per object with its "actions" within the If_Statement area.

STeven.
William from United States  [2 posts] 8 year
Hi - I attached a screen shot. The object recognition sees my object named "Red", and labelled it on the screen.
The object name shows up as "Red" in the Watch_Variable.
I'm at a loss as to how to tweak the Roborealm so the Rotate_Servo will move the servo? I'm using Arduino and Sparkfun which moves my Trossen Roboturret when running the object tracking.
Thank you

 
Steven Gentner from United States  [1446 posts] 7 year
William,

You are on the right track. If you add the Sparkfun_Arduino module and select that Rotate_Servo variable in one of the PWM servo channels that should change the servo value when a particular object is seen. I'm assuming that in the Rotate Left state tab in the state machine module you assign a different value to Rotate_Servo and then have it transition immediately (immediate transition selection) back to the State 1 tab? Likewise the other objects would need to be added below the Red Condition to go to the respective tabs. Essentially State 1 acts like a switch or select statement that will call other tabs to set the variable accordingly and then return back to state 1 in case other objects become in view.

As long as each state uses the correct servo position (typically 500 to 2500) you can use that variable directly in the Arduino module to control a particular channel.

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