loading
 
Identifying X and Y COG serial data of two objects
Wilfredo Molina from United States  [13 posts]
11 year
So far, I have been tracking one object by color. I have been using the variables COG_X and COG_Y for the coordinates of this unique object and sending them via serial (let's say .[COG_X],[COG_Y];  So far so good. Now, I would like to track two objects. I understand I have to create another Center of Gravity for the second object. If I use COG_X and COG_Y as the coordinates of the first object, what variables should I use to read the coordinates of the second object? Thank you.
Anonymous 11 year
Inbetween the two COG modules use the Set Variable module to copy the data into some other variable that will not be overwritten.

STeven.
Wilfredo Molina from United States  [13 posts] 11 year
Thank you Steven. My project is very simple. I will follow your directions. Anyway Here my project:
program.robo
Wilfredo Molina from United States  [13 posts] 11 year
Hello STeven. I still confuse about the use of Set Variable in my serial sequence. Again, I have the following serial 'parser' for one object:     .[COG_X],[COG_Y];
Then I want, let's say, the following  'parser' for two objects:
.[COG_X],[COG_Y]:[COG_X2]-[COG_Y2];     how could I implement that?
Thank you very much.
Anonymous 11 year
Wilfedo,

I'm not sure what you are asking ... the sequence

.[COG_X],[COG_Y]:[COG_X2]-[COG_Y2];

should work just fine in the serial module. Are you asking how to parse that out in your microcontroller? Or are you trying to perform a calcuation of COG_X2 - COG_Y2?

STeven.
Wilfredo Molina from United States  [13 posts] 11 year
Hello STeven and thanks for your answer. I am asking how to make Roborealm to send a parser according to my sequence:

.[COG_X],[COG_Y]:[COG_X2]-[COG_Y2];

The characters . , : - ; are just flags to my microcontroller about who's who in the sequence. I don't have problems identifying them on my microcontroller but I need first to send the sequence. Please, I need your help with a simple project that, let's say, track two small balls. One orange and one green, and send their coordinates via serial according to a parser pretty much similar to the one above. Thank you again.
Anonymous 11 year
What happens when you just plug that exact sequence into the serial send sequence? That's the exact format that you use ... or is that not working for you?

So on your microcontroller you could expect to see something like

.110,200:150-114;

IF you are using sub pixel COG then it would look like

.110.20,200.60:150.40-114.10;

which will cause a problem because you now have 5 '.'s instead of one. You may want to use another delimiter than a period in that case.

STeven.
Wilfredo Molina from United States  [13 posts] 11 year
I can choose any other character. Instead of '.' I can choose '?' or '$'. I can also change any of the other characters. Per object I am using only Color_Filter, Center of Gravity and Serial, but I still confused about how to use the Set_Variable to distinguish the X and Y coordinates of the first object from the second one. Could you, please, send me an example? Thank you STeve.
Anonymous 11 year
Attached.

STeven.
program.robo
Wilfredo Molina from United States  [13 posts] 11 year
I'm really truly grateful STeve. I will be playing with it and keep you posted about it. By the way, I must say I'm impressed with all your patience and spirit of collaboration with all of us in this forum!

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