I'm using for my personal use Visual Studio Code IDE task for running ROS scripts remotely on device for some time. Now I polished it as far as ROS features allowed me and decided to share it: .
Prerequisites:
- Device with ROS 7.x. - tested on ROS 7.11.2 but probably compatible with other 7.x versions
- Visual Studio Code with Mikrotik RouterOS script language extension from Mikhail Korzhov (other extensions also can be used but then problemMatcher.owner in task configuration needs to be correctly set for used ROS language extension)
- bash shell - in VSCode running on macOS or Linux should work as is (tested on macOS with bash from MacPorts), it could work on Windows if bash shell (git/msys bash, WSL...) is avaiable from path or set in task configuration options.shell.executable
- command line OpenSSH client (ssh/scp)
- configured non-interactive (PKI) SSH authentication to ROS device for user that will be used for running script
Usage:
- extract attached archive and put tasks.json (task configuration file) into .vscode directory placed in scripts root or Workspace directory, see more about VSCode tasks: https://code.visualstudio.com/docs/editor/tasks
- edit that file and replace ROS_SSH_DST env. variable with SSH connection string to ROS device (user@host)
- in VSCode open scripts root folder (File->Open Folder...) or Workspace and in Explorer panel select ROS script file
- run task with name "Run ROS script" using Tasks: Run Task from Command Palette... or from GUI panel provided by some extension like Task Explorer
Example script run: Example script run with errors and displaying line error in editor:
Potential issues:
- if other scripts are running at same time on same device, VSCode terminal output will show logs from other scripts - afaik there is no way to relate exact script with script log topic
- false script error may occur for same reason as above, because script errors are also retrieved from log, proposed feature request how it will be possible to handle this
- if SSH connection to ROS device takes longer, adjustment of LOG_SEEK_OFFSET env. variable in task configuration is needed to proper interval for better finding all script logs
- stopping task in VSCode will not stop script job execution on ROS - if there are issues in script like infinite loops or long execution that needs to be terminated, script job needs to be removed from /system/script/job.
Share any suggestions for improvements and I will try to implement it when I find some time.