United Kingdom
Asked — Edited
Resolved Resolved by CochranRobotics!

Help With Roborealm Saying Detected Objects

Hey guys.

I need a little help with some script. As the title suggests, I'm trying to get an ARC script to speak an identified object using RoboRealm. It is all set up and passing variables to ARC, and I have a couple of objects trained, but I'm having trouble writing a correct script. Here's what I've got so far...

if($RR_NV_ARR_OBJ_NAME[0])
say("Steve")
elseif($RR_NV_ARR_OBJ_NAME[1])
say("control")
endif

I would be grateful for any help with this to get me started.

Thanks.


ARC Pro

Upgrade to ARC Pro

Subscribe to ARC Pro, and your robot will become a canvas for your imagination, limited only by your creativity.

#1  

if($RR_NV_ARR_OBJ_NAME[0] = "Steve" )
say("Steve" )
elseif($RR_NV_ARR_OBJ_NAME[1] = "Control")
say("control")
endif



another way to do this is


:startofloop
waitforchange($RR_NV_ARR_OBJ_NAME[0])
Say($RR_NV_ARR_OBJ_NAME[0])
goto(startofloop)


United Kingdom
#2  

Thanks for replying David.

I tried the first script you cleaned up for me, but every time I press start it just keeps saying my name whether I'm in front of the camera or not. And when it detects the control object, I get a debug message saying "error on line 3. Index was out of the bounds of the array".

So I tried the second script and it doesn't seem to be doing anything. Any ideas?

Basically what I'm trying to do is when I different is detected on RoboRealm, is for ARC to speak the name of that person (or object), but not having much luck so far.

#3  

Use the second example. See if that works for you. The error is that you don't have 2 objects recognized when running the script.

The second script waits for a change. Let me get to a computer and I will write the script.

#4  

First script change This script will do the same as the second script but is written out.


$lastobject = ""
:Startofloop
if($RR_NV_ARR_OBJ_NAME[0] != $lastobject)
say($RR_NV_ARR_OBJ_NAME[0] )
endif
$lastobject = $RR_NV_ARR_OBJ_NAME[0] 
goto(startofloop)

Second script should work when the object changes in the view of the camera.


:startofloop
waitforchange($RR_NV_ARR_OBJ_NAME[0])
Say($RR_NV_ARR_OBJ_NAME[0])
goto(startofloop)

im in the middle of doing some testing on EZ-AI so I haven't tested this, but it should work fine.

Also, I would suggest adding a variable watcher so that you can see what the $RR_NV_OBJ_NAME[0] variable is set to if you dont have that in your project yet.

United Kingdom
#5  

Thanks David.

That's working much better. I've got two seperate script controls and run the both together and so for it seems to be doing the job. At least that will give me something to build on (or at least try to:P).

Thanks again.

United Kingdom
#6  

@David.

Quick question. Can you learn new objects using the EZ-B camera with Roborealm? The problem I'm having is all the object learning is being done through my laptops webcam, and that's where the detection is happening, but even though I'm getting the EZ cameras feed, I cannot train new objects or do any recognition with it. I thought I had it working before but can't honestly remember now (stressfull week and all).

Thanks.

#7  
United Kingdom
#8  

@Dave.

I already used your video to set it up initially. I do have the custom web server already set up, and when I click "ReadHTTP http://127.0.0.1:8020/CameraImage.jpg?c=Camera, I can get the same feed through the v4 camera. But when I go back to AVM, it reverts back to the webcam.

#9  

Let me get to a computer. It will take me about an hour to get to one.

United Kingdom
#10  

No problem. That's David.:)

#11  

Make sure the that ReadHTTP is before the AVM Navigator in RoboRealm and the AVM Navigator is before the EZ-Robot Variables module.

From looking at it, that is the only thing that strikes me as possibly being configured wrong. Let me know and I will keep looking.

United Kingdom
#12  

@David.

That's exactly what it was. Many thanks. I moved it around and works great now, except...

User-inserted image

Every time I now launch Roborealm, I get the above message. It's not the end of the world as when I click "OK" it continues to launch and seems to work ok. Any ideas what's causing that?

#13  

I would change the port that you are using to something like 2080 instead of 8020. It is worth a shot. If something else is using that port, it could cause issues. If that doesn't fix the issue, post a message on the RoboRealm forum with the error. They are pretty good at letting you know what the issue is.

United Kingdom
#14  

Cool, will do. Thanks again David. I do have one more question regarding the original topic of this post I hope you can help with. I am running the following two scripts in two separate script controls...

$lastobject = ""
:Startofloop
if($RR_NV_ARR_OBJ_NAME[0] != $lastobject)
say($RR_NV_ARR_OBJ_NAME[0] )
endif
$lastobject = $RR_NV_ARR_OBJ_NAME[0] 
goto(startofloop)

and

:startofloop
waitforchange($RR_NV_ARR_OBJ_NAME[0])
Say($RR_NV_ARR_OBJ_NAME[0])
goto(startofloop)

and running it through a speech recognition control with the following...

say(" That is ")
sleep(2000)
ControlCommand("Sensors and Lights", ScriptStart, "Face rec 1")
ControlCommand("Sensors and Lights", ScriptStart, "Face rec 2")
sleep(5000)
ControlCommand("Sensors and Lights", ScriptStop, "Face rec 1")
ControlCommand("Sensors and Lights", ScriptStop, "Face rec 2")

The problem I'm having is when the robot says "That is" he will say the last object detected before he says anything else. Any ideas on how to improve that?

Thanks.

#15  

You really should only have to run one of these. They do the same thing. Remove the Say(RR_NV_ARR_OBJ_NAME[0]) command from the first two scripts.

I suspect the issue that you are having is that it is looping and catching the change in the recognized object. These scripts will currently say the name of the recognized object so I think what you are seeing is

"Bob, that is (wait 2 seconds) Bob. " I would even go as far as to say that the last script wouldnt be needed and just put the line SAY("That is " + RR_NV_ARR_OBJ_NAME[0]) in place of Say(RR_NV_ARR_OBJ_NAME[0]) and just let it run in a loop. I personally like the second script better as it is less typing:)

You could start this script with an init script that is launched when you connect to the V4. I would also add things like battery monitoring or check to see if there is a connection and if not, reconnect that would be launched from this same init script. These would be separate scripts that would also loop.

United Kingdom
#16  

Well I gave the changes a try, and now it doesn't work at all. confused

Also, I changed the port numbers as you suggested on Roborealm, and all is good now.:)

#17  

:startofloop
waitforchange($RR_NV_ARR_OBJ_NAME[0])
Say("That is " + $RR_NV_ARR_OBJ_NAME[0])
goto(startofloop)

This should work. Is the script started?

#18  

Try this with a variable watcher up


:startofloop
waitforchange($RR_NV_ARR_OBJ_NAME[0])
$TheNamePhrase = "That is " + $RR_NV_ARR_OBJ_NAME[0]
goto(startofloop)

See if the name changes when different things are recognized.

United Kingdom
#19  

Yep, that's working now. Thanks very much for your help David. Most greatful.:D

#20  

Thought I would reopen this tread as I'm having the same problem as the poster. It would be easier that way as I would not have to rewrite everything that was tried in it.

I want to have EZB say the name of the object that RoboRealm has detected. First off (if you see this) thanks David for the great video about setting up RoboRealm it helped me a great deal.

Where to start ... I have 3 different items detected by RoboRealm. The variable ($RR_NV_ARR_OBJ_Name) does show in the variable watch list in EZB. Have tried all the scripts that were mentioned in this post and none seem to work for me. I must be missing something easy but can't seem to figure out just what it is.

Any help would be greatly appreciated.

#21  

I just saw this. Let me get work squared away this morning and I will see if I can't help you get it going.

It may be an hour or so.

#22  

Its great that the variable is showing up in the watcher list. This means that everything is configured correctly and we just need to figure out the script. Can you give me exactly what the name of the variable is? For example, is there a [0] at the end of it or some other number?

Thanks David

#23  

Make a script called something like SayNameOfObject or whatever you want it to be with this code.


#Replace $RR_NV_ARR_OBJ_NAME with the name of the variable in all of the lines below.
$RR_NV_ARR_OBJ_NAME[0] = ""
:startofloop
waitforchange($RR_NV_ARR_OBJ_NAME[0])
#use Say or SayEZB in the next line
Say($RR_NV_ARR_OBJ_NAME[0])
goto(startofloop)

This can run by itself and just loop. it will say the name of the object when the name of the object changes. The variable initialization in the first line could be moved to an init script that launches when the robot first starts up. This is there because the script will probably fail if you haven't yet launched RoboRealm to identify an object yet as the variable wouldn't exist yet. Once RoboRealm has been launched, the variable is initialized and set by RoboRealm so it wouldn't be needed anymore. This is why it is outside of the loop.

The WaitForChange line will wait for the object name from RoboRealm to change before it continues so you shouldn't have to worry about this script consuming many resources.

If this script fails, please send me the error message it returns.

Thanks David

#24  

Can you give me exactly what the name of the variable is? For example, is there a [0] at the end of it or some other number?

Yes there is a [0]

#Replace $RR_NV_ARR_OBJ_NAME with the name of the variable in all of the lines below. $RR_NV_ARR_OBJ_NAME[0] = "" :startofloop waitforchange($RR_NV_ARR_OBJ_NAME[0]) #use Say or SayEZB in the next line Say($RR_NV_ARR_OBJ_NAME[0]) goto(startofloop)

I still must be doing something wrong or miss understanding this. Can you give me a example, say with the variable name of "box".

I have been getting nowhere ... lol

Thanks

#25  

do you have Team Viewer installed? If so, I can connect to your computer and see what is happening. If not, I will get something working here and post it for you.

#26  

I do have it on my main computer but not the robot which has a onboard computer.

#27  

okay, let me slap together a project real quick. I will post a link shortly.

#28  

Actually, I just tested the script and it is working. Can you send me a screenshot of your ARC with the variable list being displayed?

This is the code that I am running without any issue. This will say the value of the first item in the array. Roborealm can identify a lot of objects so it is possible to have more items than just the one in position 0. These would be 1 and up. Can you see the value of the variable changing as you show the camera different objects? If the original object is in the view of the camera, it will hold position 0 and the new object will get position 1. if the old object is not in the view of the camera any longer, the new object will be in position 0. It would be possible to modify the code to say the name of multiple objects but we need to get it saying the name of one of them first.


:StartOfLoop
WaitForChange($RR_NV_ARR_OBJ_NAME[0])
say("I see " + $RR_NV_ARR_OBJ_NAME[0]+ ".")
Goto(StartOfLoop)

Another option is to connect to your robot from your main machine, but my assumption is that roborealm isnt installed on this computer so it wouldnt work. If it is on your main computer, I could connect and check it out from start to finish for you.

#32  

Look at 1 of the tutorials see if they have information. I do have a code.

#33  

if($RR_NV_ARR_OBJ_NAME[0]) say("Steve") elseif($RR_NV_ARR_OBJ_NAME[1]) say("control") endif

#34  

this is working fine for him with the code that was supplied. The port wasn't enabled in ARC.

The code mentioned in the previous post isn't what should be used and is not good code. It won't do what you want it to do.

This code is working code that allows the name of the object, as specified in RoboRealm to be said. There is no need to do what is being done in the code above.


:StartOfLoop
WaitForChange($RR_NV_ARR_OBJ_NAME[0])
say("I see " + $RR_NV_ARR_OBJ_NAME[0]+ ".")
Goto(StartOfLoop)

#35  

@Aidan Your code in post #34 won't work.... Your comparator has no exact match.... What your code says is that if $RR_NV_ARR_OBJ_NAME[0] contains any text string, say Steve... What if $RR_NV_ARR_OBJ_NAME[0] = Fred or Frank or rubber chicken? Part of your code would sort of work if you only trained one object (Steve in this case) in RoboRealm, but what if you had many trained objects? Look at David's code in post #35.... that's how it should be done....

#38  

Wait I know this go to learn on ez robot.com there is a tutorital for this

United Kingdom
#39  

@Aiden.

The script you supplied in post #34 was copied from what I originally posted in post #1. This script, as already mentioned by others and tried by the poster, does not and will not work. That is the reason why I started this thread, so I could get the correct script from somebody and compair where I went wrong to help others facing the same issue. 10 out of 10 for your willingness to help which is great, but be sure any advice you offer is tried and tested and correct. My advice for what it's worth is to study the tutorials in depth and learn what ARC has to offer. That way you will have great fun building and controlling robots and you will become a great asset to the community.:)

@Herr Ball.

Sorry I couldn't reply to you sooner to offer some help. I've been away from the forum for a while dealing with life's little problems it seems to be throwing at me at the mo. I'm pleased David got you sorted out and you finally got it working.