loading
 
Sending variables to other processes
Anonymous
15 year
Hi steven
I need some help with getting variables to another C program, Im not an experienced programmer so I dont no how to use IPC sockets and pipes to attain the end goal, but if it requires me to learn im willing.
I sorted out my .robo program and am using the Api to control it but i need to pass a variable say for instance the centre of gravity x to another C Api.

The variable will need to streamed or sent multiple times. Could you recommend a solution, i looked into OSC and i cant find much information in that area. What are your thoughts?

Your help is much appreciated
Thanks mark
Anonymous 15 year
Mark,

There are many options. If you look at

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

you can find the technique you would be most comfortable with. Using the API is normally what most people go for. There are examples in the download example API.zip at

http://www.roborealm.com/downloads/API.zip

and you should be able to figure out the C++ example (which can be adapted to a C program) to get a variable. The API is quite simple with the most complex part being the socket open. Using the API and get_variable xml string you should be able to grab that variable.

Alternatively a lot of people have also just used the Write_Variable module to just write a variable to a text file and keep polling that text file in another program to grab the value ... again, lots of possibilities here, probably too many to make an easy decision, yes?

STeven.

Anonymous 15 year
Thanks so much Steven
i chose to go the socket route with sending variables from your API (roborealm) to another C program I created, but Im having difficulties getting a variable repeatedly and displaying it.
When i run the program it runs and displays the first disparity value (which is intialised in VB in the program to be the difference in x values of the two images from two webcams) but it has trouble writing the next 3 times, and returns an error(or a 0 reading if i leave out the error checker) do you know of any way to rectify the problem?

rr.run("on");
    for (i=0; i<4; i++)
    {
        rr.waitVariable("image_count","20",10000);
        
        rr.getVariable("disparity",buffer,64);
        
        if (atoi(buffer)==0)
        {
        printf("error in get the disparity function");
        getchar();
        exit(-1);
        }    
        printf("%d",atoi(buffer));//cool this works nicely
        printf("\n");
    }

    rr.setCamera("off");

thanks very much
Anonymous 15 year
Mark,

You may want to check that the value is not actually zero ... perhaps the object goes out of view or it not found for a split second which would cause the disparity to go to zero.

You can check this by setting a variable to a static value and run the above against that variable to see if it is an API issue or a value issue. I.e. one would not expect the value to ever change ... if it does not then your disparity variable is changing for some reason, if the value does change that we can look into other network API issues.

STeven.
Anonymous 15 year
Hi.Yes i just tried it using the image height and the value prints fine the first time then it fills the buffer with "timeout exceeded" which i showed by printing the characters in the buffer, that explains the atoi(buffer)=0=error. I also removed the for loop and then printed the image height then using the example in the API
set variable custom =test and the get variable using the same "buffer" array as previous and this worked fine showing "test" which was expected.
so it seems that the problem lies in the loop somewhere but im not sure where.
Thanks mark
Anonymous 15 year
hello steven do you think it is the version of my roborealm that is the problem, im using 1.8.11.2. Do you think that is the problem? I was wondering if you can get the variables multiple times? Because then it must be the older version.
Anonymous 15 year
Instead of using

rr.waitVariable("image_count","20",10000);

which waits for image_count to be the absolute value of 20 ... which it will only do once and then continue to increment upwards until you stop RR ... i.e. you will have one change for this to trigger and from then on it will just timeout due to the 10 second timeout. Instead of this line you probably want to use

rr.waitImage();

instead which just waits for the next image to be processed and thus a new disparity value would be calculated.

STeven.
Anonymous 15 year
Great, thanks steven.
It works perfect now, sorry bout the hassels.
Thanks again
Mark

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