ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Is it possible to remote execute a python ROS file

asked 2019-06-13 16:29:29 -0500

pitosalas gravatar image

The question is hard to summarize. My goal is: to have a student in a brief Robotics workshop, with their own computer, to write or modify a simple python ROS script and run it and see the results. The student will have an arbitrary computer and we don't want the to have to try and install ROS.

Laptop "A" running Win, Lin or Mac, does not have a working ROS installation. Robot "R" is running Linux, and has a working ROS installation.

User on "A"writes a python ROS script and "submits it for execution" on the robot. What does it mean to "submit it for execution"? I am not sure. For example, one might scp the python file from "A" to "R" and into the "right" directory. And then ssh to the robot and issue a catkin_make, and roslaunch. That would work pretty well but requires careful use of shell commands.

Next level: we write a sophisticated shell script (in python even) which issues those commands, with good error checking and recovery. Still kludgy but at least easier on the "A" user.

Next level: there is a way to cause a node python file to run and establish contact with roscore and publish and subscribe to topics with a partial ros installation. What would be required? I am not sure.

Another option: "A" computer ssh's to "R" and does their editing and running there. Drawback is that the "R" SBC is slow and it won't allow user of "A" to use their favorite text editor.

Thoughts? I am sure others have had this particular scenario!

edit retag flag offensive close merge delete

Comments

How would you feel about using a build server like teamcity? Students could have their own repository for their code. When they're ready to run it, they commit and push. The build server then builds the code, and deploys it to the robot.

ChuiV gravatar image ChuiV  ( 2019-06-13 17:01:42 -0500 )edit

Very interesting idea.... How would that work? I don't know TeamCity But for example github actions seem to be useful to activate when code is pushed to a repo. But github is a service and my robots are in the lab. They do have static IP addresses but they are not accessible from outside (I hope :). Even if they were how would the github action deliver the code to the robot and then trigger the roslaunch etc?

DO you have a more specific scenario?

pitosalas gravatar image pitosalas  ( 2019-06-13 22:07:04 -0500 )edit

So regarding teamcity in particular, You could install it on a server within your lab. Within teamcity, you can configure each build project to be triggered when somebody pushes code (doesn't matter if the code repo is cloud hosted, or hosted on your server). As part of the build, you can have it run arbitrary shell/bash scripts which could compile the code, copy it to the robot, and start the required launch file. You could even have it send certain commands to the robot to test the code/ execute certain maneuvers.

ChuiV gravatar image ChuiV  ( 2019-06-14 09:03:55 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-14 02:34:55 -0500

gvdhoorn gravatar image

updated 2019-06-14 11:26:43 -0500

Another option: "A" computer ssh's to "R" and does their editing and running there. Drawback is that the "R" SBC is slow and it won't allow user of "A" to use their favorite text editor.

you have quite a nr of constraints, but two approaches that come to mind:

  1. use SSH + an SCP client
  2. use some incarnation of a self-hosted web based IDE + deployment solution

The first would be a low-fi solution, almost trivial to setup: SSH clients are available on all OS, and SCP clients as well. Find an SCP client which allows to continuously synchronise a directory on the students laptop/pc/whatever with one on the robot (winscp for Windows supports this). Open a shell session over SSH, navigate to synchronised directory, execute script.

The second would be fancier, and would probably appeal to non-command-line users. I haven't done this myself, but there are web based IDEs, even ones that allow you to execute code remotely as well. There are two main variants:

  1. IDE is cloud based, target device is local. Development happens in browser, deployment is to local target device
  2. IDE is self-hosted, running on the robot. Development happens in browser, deployment is to the same robot

An example of option 1 would be os.mbed.com (note: it's an example of the concept, I'm not suggesting you use mbed os or their online environment). Perhaps the team city approach mentioned by @ChuiV is an example of this as well. I believe the main work here will be setting up your robot to make it a suitable target device for deployment.

The second option is essentially similar to the first one, but you'd run one of the cloud-based web IDEs in their self-hosted configuration. As 'everything' is already running on the robot, it would already be the target device. I imagine there will be less setup work, but I'm not sure.

A variant of the second option could be where a more powerful machine (but still local) hosts the web-based IDE and your robot is still setup as a target device. That could work around limited hw/processing capabilities of your robot.


Note that none of the web-based approaches will allow students to use "their favourite text editor". But tbh I doubt that is really something you should constrain yourself by. Unless that text editor happens to be an actual IDE, things like code-completion and linting are not going to be automatically available. Those are valuable features, so I wouldn't want to develop without them, but these are students, so perhaps your goals are different.


Finally: the SSH+SCP approach should take 30 mins to setup, max. The web-based stuff is much nicer but will take some time to figure out and setup.


Edit: if you don't have a particular need to use an actual rospy installation, then perhaps something like rosbridge_suite in combination with gramaziokohler/roslibpy might also work. Requires no ROS installation and can be ... (more)

edit flag offensive delete link more

Comments

For my own students I actually feel learning to use the command line is a very important skill, almost indispensable. At least with the current state of things you cannot ignore it, and after some initial hickups, most students do not have a problem with it.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-14 02:36:20 -0500 )edit

And just found judge0/ide, which seems to support Python and can be self-hosted. The web ide is a bit spartan, but seems functional and is relatively easy to understand.

And a random other alternative: theia-ide.org.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-14 02:41:48 -0500 )edit

@gvdhoorn Thanks... Two clarifications: when I said "their favorite editor" really all I meant was an editor other than nano or gedit. Graphical and running on "A", so e.g. atom, vscode, sublime, etc.

Second: I am organizing a 2-4 hour "workshop" for students curious about robotics so I want a rapid path to success, and not presuming any particular level of knowledge. For the real course certainly they need to know the command ine.

pitosalas gravatar image pitosalas  ( 2019-06-14 09:05:10 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-06-13 16:29:29 -0500

Seen: 516 times

Last updated: Jun 14 '19