[Documentation] [TitleIndex] [WordIndex

Roshlets

Roshlets are how you run rosh scripts as standalone ROS nodes.

Here is an example 'roshlet' that simply echoes one topic to another:

   1 for m in topics.chatter[:]:
   2     topics.chatter_echo(m)

And here is the command to run it:

rosrun rosh rosh rosh/echolet.py

The main convenience of roshlets is that they eliminate much of the setup code that would normally be associated with writing a Python script. You are provided the same environment you get when you invoke the rosh interpreter.

Loading Plugins

If you use plugins, you specify those as a comma-separated list at the command-line:

rosrun rosh rosh rosh/echolet.py --plugins=rosh_common,rosh_geometry

The plugins will be automatically loaded so that you can use them immediately.

Hash Bang (#!)

Just like python scripts, rosh scripts should start with a hash-bang line. This enables making the script executable and running it without needing to pass it as an argument to rosh.

   1 #!/usr/bin/env rosh

However, the hash-bang spec does not consistently allow for passing of arguments, which means that if you use hash-bang, you need to explicitly load plugins in your script. For example:

   1 #!/usr/bin/env rosh
   2 load('rosh_common', globals())
   3 load('rosh_geometry', globals())

2024-11-16 17:43