Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited

Reading And Using Servo Values In Tracking

Hello,

I have two cameras mounted on servos. They are set it up in tracking color mode (red). I have an 10 foot square area. The cameras are mounted in two locations (5 feet from a corner), 90 degrees from each other, against the outside wall . While tracking, I want to read the values the servos are at, and display the value. I know I can only read the information sent, not the true value.

I want to take these values and compare them to a preset value or coordinates.

My end goal is to track a Movement Panel to these two values.

My scripting skills are minimal to say the least, but can someone point me in a direction to find examples of these concepts?

I search around and know the "servo read" is somewhere, but I can't remember where.

Rich, Dave and Richard R, posted some information about this. Any ideas?

Ron R

AI Support Bot
Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#15  
The calculations would have to take into account the size of the robot or object from each camera image to be used to estimate the distance that the object is from the camera. From there, using the position that each servo is pointing to get the object centered in the camera view should allow you to get an idea of the location of the robot.
#16  
Hi Dave,

I am only looking at position for now. The area I want to track in is relatively small so the error of distance shouldn't screw it up to much for the test. Later maybe 3 ultra sonic pings and more math will have to be considered, especially when object avoidance is used.

Thanks,

Ron R
#17  
Ok, interesting method. I like it. Gets my gears turning. Just thinking out loud here but ... thinking about mounting both cameras on the robot and glyphs or solid color cards in the center of each of two adjoining walls . Could even be lights. Most cameras are sensitive to infrared so it could be invisible to boot.

When the robot wants to get a fix on it's coordinates it sets the cameras to 0,0 and each sweeps until it finds the objects on each wall. The distance it moves to find it would be related to where it is in the room. In the dead center of the room, it should find both objects at it's 0,0 initial point. That would also be a way to calibrate it. Mounting the cameras on the robot would also make it more autonomous and mean that all you need is to put cards, or whatever, in each room to be navigated. That, as opposed to a set of cameras in each room. Maybe different colors or glyphs for different rooms so it knows what room it is in.

Just a thought. Don't mean to impugn your strategy in any way or worm my way into your project. For all I know that has already been suggested to you and rejected for reasons of which I have not realized. :D

Anyway, good luck and if you need help with the scripting, let me know.
#18  
Hi WBS00001, Opinions and help is always accepted. Thank you.

@jstearns had built something like you mentioned in the past but, I don't know if he went any further with it. I hadn't seen him on the forum for quite a while.

I really don't want to use any external cards or markers. My final wish is an Infra red or other invisible beacon on the robot. The other issue is items in the room may block the targets on the walls. That is why I want the robot to be tracked. The cameras would be mounted where they would not be blocked tracking the robot. I am also waiting for the possibility of an ez robot wireless cameras once spoke of, coming out again. My plan is to mount cameras in the rooms I want to navigate. I would send the go-to coordinates to the robot to track to. I have an inexpensive wifi camera and I will try it once I get the initial testing done.

Between the Holidays, my R2D2 project and my poor servo-less Adventure Bot, it may be a while before this really gets going. The tests with the two servos works, so now I need to build the continuous servos for the Adventure Bot and try the tracking script Dj mentioned.

I will post my progress.

Ron R
#19  
I have returned to the correct posting for my idea for a very simple navigation script. I wanted to find out if I could look at the program for the camera tracking, but found it isn't a script, but a program.

I have written a conceptual script for moving and tracking to one coordinate. I tried to load it, but due to my lack of knowledge, I wasn't able to have it work or load. It is as follows:

GetDigital(D10) #Data, taken from tracking camera servo to show current location
$doorxcoordinate #variable, input of location desired (desired track servo value)
$minusdestination #variable, a minus value calculated from current location to desired location. Information determines travel direction and speed.
$plusdestination #variable, a plus value calculated from current location to desired location. Information determines travel direction and speed.
ClearVariables() #set all to 0

:loop

GetDigital(D10) # camera is mounted on servo D10 which is tracking the robot. Data is servo position value. ( this worked in a trial script)

GetAsByte($doorxcoordinate) # coordinate loaded from speech recognition. (this worked in a trial script)

if (GetDigital(D10) => $doorxcoordinate) # do math, equal more than
goto (math1)
Sleep(500)

if GetDigital(D10) <= $doorxcoordinate) #do math, equal less than
goto (math2)
Sleep(500)

endif

math1:
$plusdestination = (GetDigital(D10) - $doorxcoordinate #do math to find coordinate error on plus from location
$minusdestination = $doorxcoordinate - (Getdigital (D10) #do math to find coordinate error on minus from location

if $plusdestination => 10 Forward, 200 # a near target value and speed

if $plusdestination =>1,<=9 forward, 50 # a near target value and speed

if $plusdestination = 0, Stop # a target value and stop command

math2: # same description as math 1

if $minusdestination => 10 reverse, 200

if $minusdestination =>1,<=9 reverse, 50

if $minusdestination = 0, Stop

goto (loop)

I really want to continue this idea to see if it will work. Any advice would be appreciated. I want to keep this as simple as possible.

The first goal is to use Omni wheels on two continuous servos to track to locations in an Auto Position file. These files will be called on from speech recognition. The above is only 1/2 the needed script (X coordinate) for the testing. I will add the Y coordinate, if, and once this is working.

Ron R
#20  
@ANDY ROID can you please post using the proper UBB tags.... It's really hard to read your code in a plain post....
#21  
Hi Richard,

I never got it to load. Can I still copy if it has a bunch of syntax errors?

Ron R
#22  

Code:


GetDigital(D10) #Data, taken from tracking camera servo to show current location
$doorxcoordinate #variable, input of location desired (desired track servo value)
$minusdestination #variable, a minus value calculated from current location to desired location. Information determines travel direction and speed.
$plusdestination #variable, a plus value calculated from current location to desired location. Information determines travel direction and speed.
ClearVariables() #set all to 0

:loop

GetDigital(D10) # camera is mounted on servo D10 which is tracking the robot. Data is servo position value. ( this worked in a trial script)

GetAsByte($doorxcoordinate) # coordinate loaded from speech recognition. (this worked in a trial script)

if (GetDigital(D10) => $doorxcoordinate) # do math, equal more than
goto (math1)
Sleep(500)

if GetDigital(D10) <= $doorxcoordinate) #do math, equal less than
goto (math2)
Sleep(500)

endif

math1:
$plusdestination = (GetDigital(D10) - $doorxcoordinate #do math to find coordinate error on plus from location
$minusdestination = $doorxcoordinate - (Getdigital (D10) #do math to find coordinate error on minus from location

if $plusdestination => 10 Forward, 200 # a near target value and speed

if $plusdestination =>1,<=9 forward, 50 # a near target value and speed

if $plusdestination = 0, Stop # a target value and stop command

math2: # same description as math 1

if $minusdestination => 10 reverse, 200

if $minusdestination =>1,<=9 reverse, 50

if $minusdestination = 0, Stop

goto (loop)


Ok I got it. I'm worst than Nomad sometimes..
#23  
For one thing you have to use a new line per command... a comma doesn't work for the next command...
For example...

Code:


if($whatever>10)
Reverse()
else
Forward()
endif


Quote:

Ok I got it. I'm worst than Nomad sometimes..

No your not...:)
#24  
I see I need to fix the command to set the servo for movement, forward, and set the speed which I didn't address in the script. I was more concerned about doing the math and proving it out.
#25  
I just got your reply. Do you see what I am trying to do and am I on the right track? I think, for a simple idea, it should work.
#26  
I have to go out now, but I will try to make it more basic and rewrite it. This way I will learn more and build an example to use.

Thanks for the reply

Nomad has been quiet lately... I wish him well !

Ron R
PRO
Synthiam
#27  
Sorry Andy, absolutely none of that code makes any sense.

* IF conditions without closing ENDIFs

* Comparing GetDigital() with integer values. As the manual states, GetDigital returns a True (1) or a False (0) only, because it is Digital. Read dictionary definition of the word Digital

* Incorrect comparison used for Greater Than Equals, should be >= not =>

* Random single line functions not assigned to variables (i.e. GetAsByte()). Also a bunch of variables with nothing being assigned specified on single lines.

* ClearVariables() being used, which i don't know why that would ever be done outside of loading a new project because it clears every variable in the stack.

My advise is to visit the LEARN section and click on ACTIVITIES course. There are lessons which explain how to do basic tracking. Once you have successfully accomplished those activities, use the EXAMPLES folder in ARC to see examples of EZ-Script functions and how they work.
#28  
I will continue to work at learning more about scripting. Thanks for the constructive criticism.

Ron R
#29  
@ANDY ROID Approach ARC scripting like Lego... Get a small piece working then build from there... It's best to download other people's code or look at the built in examples in ARC....

For example

Code:


$plusdestination = GetDigital(D10)
if($plusdestination =1) #true
Reverse() #or whatever you want to do
else
Forward()
endif
#30  
Thanks Richard,

I had only wanted to post "CONCEPT" not real code. That is why I listed it in thread # 20 with labels, not using the UBB Code. Dj' s reply was code issues , not concept issues, so he replied firmly.

In the future I will build my ideas in code to the best of my ability. Your advice is well taken and I will do line by line testing of my script to be sure it works. I will then post the real scripting.

I still think my idea will do what I want.

More to come...LOL

Ron R
#31  
I got the test script working. I can load a verbal command (Goto A) which loads a coordinate. It runs the continuous servos until the camera servo value matches the coordinate.

My next problem is getting better vision/tracking. I was using a web cam, but now I think I will need to, at minimum, use the "old" Ez robot camera. I think Dj said it was better than a web cam, but not as good as the new release one. I am hoping a wireless unit once spoke of comes out soon. Otherwise I will have to buy a new one or any suggestions?

What has been found to be the best color to use for tracking? Can I use a light beacon? Any suggestions. I was thinking a maybe white because it is neutral?

I am getting closer to a full trial.

Ron R
#32  
This is the Test script. It is not fully completed but it worked for testing. I am aware it needs additional work. Posted for @castlephelps.

Code:

#Navigation Test Code 1-4-2016

# $xcoordinate is loaded from speech recognition robot go to door or robot go home


:loop

$apos = GetServo(D10)

if ($apos >= $xcoordinate)
goto(math1)
endif
sleep (500)

if($apos <= $xcoordinate) # for reverse test

endif
sleep (500)



:math1
$plusdestination = ($apos - $xcoordinate)
if ($plusdestination >= 0+1)
Servo(d0,119)
Servo(d1,99)
endif
if ($plusdestination = 0)
Servo (d0,109)
Servo(d1,109)
endif
:math2
$minusdestination = ($apos - $xcoordinate)
if ($minusdestination <= 0-1)
Servo(d0,99)
Servo(d1,119)
endif
if ($minusdestination = 0)
Servo (d0,109)
Servo(d1,109)
endif

Goto(loop)


I will be labeling the lines soon.

Ron R
#33  
I forgot to mention these are continuous servos, D0 and D1. D0 values: forward =119, stop=109. D1 values forward=99, stop=109. The camera servo is D10.

@castlephelps
Maybe you could load locations? instead of numbers?

Ron R
#34  
I just want to bump the camera question from #32. I am wanting to use a reliable target or beacon. I want to determine if an onboard lamp is beter than a plain target. Lighting in the room will vary. Is Lidar the way to go?

Ron R