gramaziokohler / roslibpy

Python ROS Bridge library
MIT License
273 stars 56 forks source link

roslibpy cmd line environment variables? #92

Closed jrjbertram closed 2 years ago

jrjbertram commented 2 years ago

Hi there,

I'd like to suggest adding some sort of command line parameter or environment variable handling of the remote server. Poking around in the source:

https://github.com/gramaziokohler/roslibpy/blob/main/src/roslibpy/__main__.py#L189

I see that the roslibpy command line utility assumes localhost for the roscore / rosbridge server. I noticed this when I was trying out rosbridgepy from a PC to a remote ros server where I was running roscore / rosbridge.

I'm able to specify the server in my python scripts which talk to the rosbridge server by specifying the remote server in my roslibpy.Ros(host='the-remote-server', port=9090) call. It'd be nice to be able to do the same with the command line utilities so we can seamlessly do things like:

roslibpy topic list '/mytopic'

Maybe with a command line option like:

roslibpy --host the-remote-server topic list '/mytopic'

Or with an environment variable like:

export ROSLIBPY_HOST=the-remote-server roslibpy topic list '/mytopic'

Perhaps if roslibpy.Ros doesn't receive a host parameter, it then looks it up from the environment. If nothing is found in the enviornment, it defaults to localhost?

Apologies if this support is already somewhere in the code. I wasn't able to find it if it is there, and I didn't see anything in the documentation either -- could be I just missed it!