0
$\begingroup$

Rosanswers logo

Hello, I'll try to be clear. I want to build a ROS node in which some code will execute terminal commands without the user input. In fact i have a script that does some elaborations to .txt files and that takes only terminal (I'm on Ubuntu) commands to do its elaborations. For example, this is how i call the script from a terminal window:

get_hrv -R test.txt

So, what i want, it's a node that will have, for example, this piece of code above nested in some ROS code, so the terminal window with the results of the elaboration will show up when I'll run the node. I hope that it's all clear, let me know if you need a better explanation. Maybe, there is a ROS package that does the job that i want, i don't know, I'm searching it. Thank you in advance for your help!

Marco


Edit: Many thanks to both of you. In fact, since i'm using C++, i just used the code

system("get_hrv -R test.txt");

and all went fine! Thank you again and sorry for my bad knowledge of programming languages, i must use ROS and so on because i'm doing a project for my university, but i come from a completely different field, since i'm a mechanical engineer. Thank you!!!


Originally posted by Marcofon on ROS Answers with karma: 17 on 2016-11-10

Post score: 1


Original comments

Comment by gvdhoorn on 2016-11-11:
@Marcofon: could I ask you to please not post answers unless you are actually answering a question? ROS Answers is slightly different from a 'normal' forum.

If any of the answers posted by @rbbg or @Airuno2L answered your question, could you please mark it as such by ticking the checkmark? Thanks!

Comment by Marcofon on 2016-11-11:
Ok, i'm very sorry! No problem!

Comment by gvdhoorn on 2016-11-11:
No need to apologise. Just keep it in mind.

Comment by Marcofon on 2016-11-11:
Sure! Of course!

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

There is nothing in ROS that prevents you from doing what you would normally do with python or C++. For example in python you could simply do this:

import os
os.system('get_hrv -R test.txt')

(Just a note, os.system is easy to use but is slowly being replaced by subprocess which isn't as easy to use in my opinion but is more capable. The main point is like rbbg said, this is really a python or C++ question, the fact that you want to do it with ROS doesn't really change anything).


Originally posted by Airuno2L with karma: 3460 on 2016-11-10

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Marcofon on 2016-11-10:
Thank you for your reply, the problem is that i'm not experienced with programming. For example i have never used python and i really don't know how implementing it in a ros node. More over, i must use c++ in my node, for other reasons. Can you help me with it?

$\endgroup$
0
$\begingroup$

Rosanswers logo

Hi Marco,

The way to do this depends on your system and the language you use for writing your node and you don't need ROS to do so. Stackoverflow offers a number of options both for Python and C++.


Originally posted by rbbg with karma: 1823 on 2016-11-10

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Marcofon on 2016-11-10:
Thank you. As i wrote it on the other comment, can you help me to implement the code i need ? I must use c++ and my OS is Ubuntu 14.04. Can you help me with a detailed explanation? Sorry if i'm stealing your time, but i'm afraid that i will get lost on asking or reading on stackoverflow.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.