I downloaded myrobotlab 14.9 and ran the bat file. The application worked fine but when I am trying to install/download services like arduino there are some errors like: need to reinstall processing. I'm just wondering if that version of myrobotlab is supported in 64 bit version OS/machine. BTW, my OS is Windows 7 Ultimate 64 bit. Anyway, I will try to use it in windows xp 32 bit.

No you don't need to download it.  It's a bug, I had to choose which services would be part of the initial install - I decided to package Jython with the initial install, but MRL does not realize it is already packaged - that's why it says its not installed when it already is...

GroG

12 years 3 months ago

When you run it, do you see a polygon in the opencv view ?
If not your color (hue/saturation/value) parameters may need changing .. this will depend on lighting, the object you want to track and other variables....

You can restart it with OpenCV and add the filters manually to find new values for the program...

The above polygon sent (235,75) to the Jython console...  
What do you see?
Send a log if you still can't get it to work...
Did you get the build from which I sent the link? --> (bleeding edge build)

michael96_27

12 years 2 months ago

Is it necessary to download the jython service? Cause it says here that it's not installed yet however, Jython service is visible in the tabs.

michael96_27

12 years 2 months ago

Tried the script again, with no luck. I've attached a log life(myrobotlab logfile3).

Here's a picture running the script:

You can notice that I edited the"valueMin" in InRange filter to "111"

 

 

 

And here's a pic OpenCV running on MRL with FindContours filter running successful :)

 

Ahhhh !

A picture says a 1000+ words !

I can tell from the picture the following things.

1. You did not "execute" the script - its that button on the top right of the Jython tab (looks like a gear & arrow) - if you hover your mouse over it, it will say execute - you need to press that button after putting in the script - The curly arrow is to recycle the Jython environment ... hmm maybe I need better symbols...

2. You don'1 want two OpenCV service running at the same time unless you have 2 cameras..  The script I will create an OpenCV service called "opencv" - so you don't want to create another one called "michael" 

Try this :
1. start myrobotlab
2. click the jython tab
3. paste the script into the editor
4. hit the execute button
5. click the jython tab - and the jython console tab
6. post picture of results

michael96_27

12 years 2 months ago

Maybe it's in the camera. Can I select the camera to be used? Cause I do have two cameras here XD

By the way, I tried using only jython and not openCV. Clicked the execute button, focused the object in the camera and nothing happens in jython console. But in java console, some words/codes are scrolling.

Show another picture of it....

If a new tab came up called "opencv" when you hit the execute button  "Jython" is working and something else is screwy...

michael96_27

12 years 2 months ago

 

When I hit the execute button, this happens:

Here's a picture showing java console:

 

 

And here's a picture showing jython console:

 

GroG

12 years 2 months ago

Your right... somethings wrong with the Jython...
When I stepped through the step I suggested - I copied and pasted the Jython script - and it gave me an ERROR .....

You can scan pretty quickly for ERRORs in the java console...
So this is an error because a copy/paste of the script I posted on the forum - does not have a tab indent before the print statement ...  

This is a formatting error (the original script has a tab indent) - but is the result of copying and pasting the script ... Grrrr !

Here's the same script indented... I'll see if I can embedded it without formatting in another comment...

GroG

12 years 2 months ago

from java.lang import String
from java.lang import Class
from org.myrobotlab.service import Runtime
from org.myrobotlab.service import OpenCV
from com.googlecode.javacv.cpp.opencv_core import CvPoint;
from org.myrobotlab.service import OpenCV
 
# create or get a handle to an OpenCV service
opencv = Runtime.createAndStart("opencv","OpenCV")
 
# add the desired filters
opencv.addFilter("PyramidDown1", "PyramidDown")
opencv.addFilter("InRange1", "InRange")
opencv.addFilter("Dilate1", "Dilate")
opencv.addFilter("FindContours1", "FindContours")
 
# change values of the InRange filter
opencv.setFilterCFG("InRange1","hueMin", "3")
opencv.setFilterCFG("InRange1","hueMax", "33")
opencv.setFilterCFG("InRange1","saturationMin", "87")
opencv.setFilterCFG("InRange1","saturationMax", "256")
opencv.setFilterCFG("InRange1","valueMin", "230")
opencv.setFilterCFG("InRange1","valueMax", "256")
opencv.setFilterCFG("InRange1","useHue", True)
opencv.setFilterCFG("InRange1","useSaturation", True)
opencv.setFilterCFG("InRange1","useValue", True)
 
# change value of the FindContours filter
# opencv.setFilterCFG("FindContours1","minArea", "150")
# opencv.setFilterCFG("FindContours1","maxArea", "-1")
# opencv.setFilterCFG("FindContours1","useMinArea", True)
# opencv.setFilterCFG("FindContours1","useMaxArea", false)
 
# ----------------------------------
# input
# ----------------------------------
# the "input" method is where Messages are sent to this Service
# from other Services. The data from these messages can
# be accessed on based on these rules:
# Details of a Message structure can be found here
# http://myrobotlab.org/doc/org/myrobotlab/framework/Message.html 
# When a message comes in - the input function will be called
# the name of the message will be msg_++_+
# In this particular case when the service named "opencv" finds a face it will publish
# a CvPoint.  The CvPoint can be access by msg_opencv_publish.data[0]
def input():
    #print 'found face at (x,y) ', msg_opencv_publish.data[0].x(), msg_opencv_publish.data[0].y()
    arrayOfPolygons = msg_opencv_publish.data[0]
    print arrayOfPolygons
    if (arrayOfPolygons.size() > 0):
    	 print arrayOfPolygons.get(0).centeroid.x(),arrayOfPolygons.get(0).centeroid.y()
    return object
 
# create a message route from opencv to jython so we can see the coordinate locations
opencv.addListener("publish", jython.name, "input", CvPoint().getClass()); 
 
# set the input source to the first camera
opencv.capture()
 

michael96_27

12 years 2 months ago

Finally, it WORKED! :))

 

Here's a picture:

Yaaaaay!

BTW -  if you want to see multiple tabs at once just right click on the tab a press - "detach"

That way you can see the video stream and the coordinates roll by...at the same time..

 

michael96_27

12 years 2 months ago

So, Color tracking is finished... What do we do next? :)) (so excited! XD)

Create a new post - Create content -> Page

Make it for your next project...
Add a picture of the pan / tilt kit

Is the webcam on it?

I'm close to having something which will work for the Arduino service, but it won't be ready for a couple days - then I'll need help testing & designing more...

I'm assuming you want the pan/tilt + webcam to begin following some colored targed

Does that sound like a plan?

michael96_27

12 years 2 months ago

Arduino(clone) is on the bottom, bluetooth shield and motor/servoshield follows :)

michael96_27

12 years 2 months ago

Is it okay to download the intermediate.754.201.... version instead of 751..... as indicated on your post? Cause 754.. is the only available :))

michael96_27

12 years 2 months ago

Okay:)

I'm working now on downloading OpenCV and Arduino service in MRL. :D

GroG

12 years 2 months ago

I think we've gone so far off topic, that its coming around again  (64 bit support), we'll see !

michael96_27

12 years 2 months ago

I think we are not so far off the topic cause' arduino and openCV service running on win7 64 bit! :))

Arduino:

 

 

And OpenCV:

 

michael96_27

12 years 2 months ago

Alrighty, Arduino and OpenCV services are installed and running, what should we do next :))

Wow, your just rocketing along !

Next step is verifying the Arduino service  "really" works - Here are the steps..

From the picture you sent in the previous post, it doesn't look like the Arduino program was compiled or uploaded to the Arduino clone board ?  Have you done this since?

After that is done, the next step would be to make sure the Arduino service can really talk to the board, and the board can talk back....   This would be done by following the tutorial and seeing one of the pins on the oscope..

michael96_27

12 years 2 months ago

Finished downloading the Arduino Service(So happy!) But when I tried to follow the steps in you post regarding the use of arduino service - in the uploading step, It took me so long and unfortunately, it's not yet done.

I've attached a logfile for you to check on for some errors. Filename:  myrobotlab(logfile 4)

I thought this would be easy but it isn't. However, This is a challenge for me as an entry level hobbyist and with your help, this challenge is not harder than it looks. Thanks for your help by the way. I hope to continue helping me as soon as my project's done :))

If it takes "long" ... its not working..
I need a little time to try to see what is going wrong...

Potentially there are many things which might be interesting...  but they take time..

And sure, I'm glad to lend a hand..  we'll figure it out soon ;)

GroG

12 years 2 months ago

You want to try the latest michael?

It's got some fixes, I don't necessarily think it will solve the issue you had but it has better logging, so it will help me figure out the issue...

This version has a nifty update functionality too regarding, updating...

The "really good part" is it only takes about 4 seconds to update & all of your previously loaded services are still installed !!

http://myrobotlab.dyndns.org:8080/job/myrobotlab/ws/myrobotlab/dist/intermediate.765.20120904.0647/*zip*/intermediate.765.20120904.0647.zip

 

Nice - what kind of board do you have (Atmel 328 - Duemilanove clone?)

Also if you have an account on LetsMakeRobots.com - could you post your picture & results on this post ?

http://letsmakerobots.com/node/34061

If you don't have an account I'd recommend you getting one,  its a great site, and very nice people there.

You'd be the first to get it working !!!  Nice work !

Now, next is Servos !

GroG

12 years 2 months ago

Is that 5 volts your playing with on the analog line... looks a little low, and the low value is a bit high for ground ?

michael96_27

12 years 2 months ago

Yes, it's a duemilanove clone. And yes, I do have an account in letsmakerobots.No, I will not post the results but 

I will post the WHOLE PROJECT in the site to help you share your 

GREAT works to others :)).            

 

Alrighty, I think we can move on to the last or second to the last step isn't it? XD

Um - we got a couple more ... probably some more bugs too...

So, unless I've broken something you "should" be able to load a Servo - and move it a bit...

You have to click over to the servo tab and connect it to the Arduino...

michael96_27

12 years 2 months ago

As for the servo shield, It uses it's own library to control servos. The thing is, it uses a decade counter to control servos just by using 2 arduino pins. You can control servos by sending 500-2400 uS pulses(for micro servos). So, we can't use servo service

But, I have an idea! Can you come up with a code that sends the angle of servo-pan and servo-tilt position in serial so that I can map the values like (0, 180, 500, 2400)? 

In order for the arduino to recognize if the given angle is for that specific servo, we can include an "id" character.

for example:

        to set the position of pan servo, we need to send an "a" character as a marker then send the position value, then send a character "b" to mark the end of the position data.

 

michael96_27

12 years 2 months ago

I don't have an exact link/documentation of the servo shield but here's a link that almost alike with the same libraries used  the only difference is that my servo shield only controls 8 servos while the "alike" shield controls 16 servos. MY servo shield uses pin 6 as CLK and 7 as RST:

Here's a link to the "alike" servo shield: http://www.renbotics.com/files/RenboticsServoShieldRev1.5.pdf

 

It uses 4 pins 6-9,
What 2 pins does your's use?

1 servo degree = 55 shield value ?

can you actually get 55 sub-degree discreet values for a Servo?

michael96_27

12 years 2 months ago

as for my shield, it only uses pins 6 and 7 thus, it only controls 8 servos. 

And as for the servo degree, We have to map the servo position from 0-180 into 500-2400 uS pulses for the corresponding position. This is my sample sketch for servo shield: 

 

BTW: the sensor is a potentiometer wired to analog pin 5

 

 

#include <ServoControl.h>
 
ServoShield servos;                       //Create an object to control up to 8 servos
#define servo 3
int sensor = 0;
int senseval = 0;
void setup()
{
  
  servos.setbounds( servo, 500, 2400);
  
  servos.start();                         //Start the servo control
}
 
void loop()
{
 
 sensor = analogRead(5);
 senseval = map(sensor, 25, 1024, 2400, 500);
  servos.setposition( servo, senseval);
  
}
 

Strange .. the doc said to map 0 - 180 to 1000 - 2000, differences in shield or particular servo used?

This is starting to come together in my head...

Need a ServoShield Service - the fact that it uses a different library will be a bit of "challenge" but we'll figure it out - as far as the details of mapping go - that should be easy enough

So, you'll be able to connect the ServoShield Service to the Arduino Service - and depending on type of ServoShield selected (e.g. Adafruit, Renbotics - rev 1.1, Renbotics - rev ??)   you'll get the correct mapping.

BTW : 

1. Is your board a "real" Renbotics ? if so what version/model ?

2. Can you try updating ?  Help->About->I feel lucky, give me the bleeding edge

michael96_27

12 years 2 months ago

No, I don't have the real renbotics shield. But the libraries they use are identical the only difference is the library name. Mine is ServoControl while the renbotics is ServoShield. The pulses are for particular servos. The pulses 500-2400 are for towerpro sg90 - the famous micro servo XD. And yes, i have already updated to latest build :)

 

BTW: the sensor is a potentiometer wired to analog pin 5

Is a potentiometer on the servo of the pan/tilt kit?

I'm going ahead with the ArduinoSheild service idea - but it's purpose will be to give access to the shields library methods.  A PID Service will be use to map the X,Y coordinates from OpenCV to the degree values of the Servos on the Shield..

So the flow will be :
Camera -> OpenCV Service -> 2D point -> PID Service -> Shield Service -> Arduino

 We've got to munge a PDE together...