Hello everyone.
I have the following question. I have a specific 'echo ...' command, which I send to the linux console via " OSProcess command:'echo ... ' ". This echo command, when executed on the native linux console, stands by until it receives some message. Following this, I have to execute a 'pub...' command, which gives some information that the echo command will print on screen. On linux, you run 'echo..' on a terminal and 'pub...' on another. My objective here is to capture the output of echo into a smalltalk variable for later use. Normally, if a console command prints something immediately to screen, I use (PipeableOSProcess command:'some command') output. It is here a little different though, since this command will not print something immediately to screen. I want to do something like this, where the final output of 'echo..' stays in stringVar. stringVar := (PipeableOSProcess command: 'echo...') output. (Delay forSeconds:3) wait. (OSProcess command: 'pub... '). (Delay forSeconds:3) wait. Thank you all. |
I've never known 'echo' to wait for input, and haven't heard of this echo & pub combination. Do you have some link to a tutorial showing how they are used? However just wildly guessing, are you wanting to get output from a long running command without blocking the Pharo UI? In that case, what about... [ stringVar := (PipeableOSProcess command: 'echo...') output ] fork. ? cheers -ben On Tue, Jan 13, 2015 at 9:18 AM, Demian Schkolnik <[hidden email]> wrote: Hello everyone. |
It is actually not a native linux command, but rather something belonging to ROS (Robot Robot Operating System). I did not want to complicate the question further.. The behaviour is as I described it. This echo command sits still in the console where it was called, and waits. When some message is send, then it just prints the message on screen and waits. The pub method (also belonging to ROS) publishes a message and exits.
I tried Ben's solution (thanks!), but unfortunately stringVar remains nil. I think the problem is we are assigning the output of the command to stringVar, which is nothing, at the moment. Any ideas? Thank you all. El Tue Jan 13 2015 at 6:15:01, Ben Coman <[hidden email]> escribió:
|
So you mean 'rostopic echo' and 'rostopic pub' ? So its a publisher/subscriber model with 'echo' as the subscriber ? (I'll needs others to confirm this is possible but...) the way to go may be to fork 'rotopic echo' and leave it running, parsing its results into a queue that some other part of your program consumes. To simplify this to check feasibility, I'd start with a single shell script outputting text at intervals like this... "test.sh" for VARIABLE in 1 2 3 4 5 .. N do echo $VARIABLE sleep 2 done and in Pharo, assuming you can process the output stream asynchronously, every time you receive a newline, open an inspector showing the line just received. But sorry I don't know PipeableOSProcess enough to know how. cheers -ben On Tue, Jan 13, 2015 at 11:05 PM, Demian Schkolnik <[hidden email]> wrote: It is actually not a native linux command, but rather something belonging to ROS (Robot Robot Operating System). I did not want to complicate the question further.. The behaviour is as I described it. This echo command sits still in the console where it was called, and waits. When some message is send, then it just prints the message on screen and waits. The pub method (also belonging to ROS) publishes a message and exits. |
Hi Demian, I am not sure if I understood well your questions, but maybe you can try something like: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= MyWriteStream>>nextPutAll: content Transcript show: content. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- and then execute: [(PipeableOSProcess command:'sh /Users/jsandova/workspace/test.sh') outputOn: (MyWriteStream with: Array new)] fork. Regards, Juampi 2015-01-13 12:47 GMT-03:00 Ben Coman <[hidden email]>:
Saludos, Juan Pablo |
Hello everyone. Thank you Juampi & Ben for your answers. This is the final working code, made with Johan's help:
| process output thread | thread := [process := (PipeableOSProcess command: 'rostopic echo /turtle1/cmd_vel __name:=echo2') ] fork. (Delay forSeconds:3) wait. (OSProcess command: 'rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- ''[3.0, 0.0, 0.0]'' ''[0.0, 0.0, 1.5]'' '). (Delay forSeconds:3) wait. output := process upToEnd. Thank you all for the help! El Tue Jan 13 2015 at 5:53:26 PM, Juan Pablo Sandoval Alcocer <[hidden email]> escribió:
|
Free forum by Nabble | Edit this page |