Repository Summary
Checkout URI | https://gitlab.com/OvGU-ESS/rosshell.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2015-09-14 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | UNRELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Packages
Name | Version |
---|---|
rosshell | 1.0.0 |
README
rosshell
Two simple nodes that can be used as mediators for shell commands.
Author: André Dietrich & Sebastian Zug
License: BSD
Source: https://gitlab.com/andre-dietrich/rosshell
1. Overview
This package provides the two nodes, that enable to run and interact with different non-ros-programs. rosshell can be used to start a program or any kind of shell-command. If some kind of interaction with the programs is required, use rosshellX to receive and send messages from stdin, stdout, and stderr.
2. Usage
The required commands are always defined as a string:
$ rosrun rosshell rosshell.py "command"
$ rosrun rosshell rosshellX.py "command"
have a look at the examples or at the included launch-files.
3. Examples
3.1 rosshell
This command is just used to generate some random noise …
$ rosrun rosshell rosshell.py "aplay -c 2 -f S16_LE -r 44100 /dev/urandom"
Pipe the results of /dev/random into a text file …
$ rosrun rosshell rosshell.py "cat /dev/random > test.txt"
or the some information about the current directory …
$ rosrun rosshell rosshell.py "ls -Shal > test.txt"
3.2 rosshellX
This node is used if you require some interaction with stdin, stdout, and stderr.
rosshellX is by default subscribed to /rosshellX/stdin and publishes at topic /rosshellX/stdout and /rosshellX/stderr, all of type std_msgs/String.
3.2.1 Some basic calculations
bc is just a simple commandline-calculator
-
open three shells
-
start bc with the following command:
$ rosrun rosshell rosshellX.py "bc"
- print the the results of bc stdout by running:
$ rostopic echo /rosshellX/stdout
- and now, send some inputs like:
$ rostopic pub /rosshellX/stdin std_msgs/String "99*99\n"
$ rostopic pub /rosshellX/stdin std_msgs/String "sqrt(2.0)\n"
$ rostopic pub /rosshellX/stdin std_msgs/String "33^3\n"
$ rostopic pub /rosshellX/stdin std_msgs/String "quit\n"
- to interact a bit with stderr, simply subscribe for:
$ rostopic echo /rosshellX/stderr
and publish some nonsense like
$ rostopic pub /rosshellX/stdin std_msgs/String "wtf\n"
3.2.1 Additional functionality
To get some filesystem-information try:
$ rosrun rosshell rosshellX.py "ls -Shal"
or
$ rosrun rosshell rosshellX.py _command:="ls -Shal"
both are the same but you also have the possibility to change the command and topics, also within the launch-file, have a look at rosshellX.launch …
<node pkg="rosshell" type="rosshellX.py" name="rosshellBC">
<param name="command" type="String" value="bc" />
<param name="stdout" type="String" value="bc/stdout" />
<param name="stdout" type="String" value="bc/stderr" />
<param name="stdin" type="String" value="bc/stdin" />
</node>
4. Nodes
4.1 rosshell
Allows to run commands with no interaction possibilities.
4.2 rosshellX
Allows to run commands and enables an interaction over stdin and stdout.
4.2.1 Subscribed Topics
/rosshellX/stdin (std_msgs/String)
The standard topic for stdin.
4.2.2 Published Topics
/rosshellX/stdout (std_msgs/String)
The current line of the stdout.
/rosshellX/stderr (std_msgs/String)
The current line of the stderr.
4.2.3 Parameters
command (string, default: “”)
Commands that will be executed.
stdout (string, default: /rosshellX/stdout)
Change the topic for stdout.
stdin (string, default: /rosshellX/stdin)
Change the topic for stdin.
stderr (string, default: /rosshellX/stderr)
Change the topic for stderr.