Suppose, the ip for Remote Server is xxxx.xxxx.xxxx.xxxx
. If you use a computer as both Local Machine and Remote Server, replace the ip xxxx.xxxx.xxxx.xxxx
with 127.0.0.1
in the below tutorial.
docker run -it --name ros --restart=always --gpus all --shm-size=32G -p 6006:6606 -p 8888:8888 -p 6080:80 -p 8022:22 -v ~/new_project:/notebooks silvesterhsu/ros_gpu:noetic-desktop-ubuntu20.04
Ignore all the information when run the code above, and goes to the Step 2
Browse http://xxxx.xxxx.xxxx.xxxx:6080/ to connect to the desktop inside this ROS container.
Once we can access the vnc through browser, we can close the terminal of step 1.
Get to the ROS Desktop first (browse http://xxxx.xxxx.xxxx.xxxx:6080/). And run the commond below in the terminator to install pycharm_remote
automatically.
wget -O - http://jupi.ink:83/ros/install_pycharm_remote.sh | bash
Double click the pycharm_reomte
icon on the remote ROS desktop.
Once it started, everything on the Remote Server is ready. And press any key to exit.
-
Open Pycharm to set ssh connection
-
Pycharm > Preferences > Tools > SSH Configuration > Add
-
Change the
host
into your service IP addressxxxx.xxxx.xxxx.xxxx
. -
Change the
port
to8022
-
The default username is
root
, and the password isShARC
-
After configuration, you can test connection and save the configure
-
-
Connect to remote Python interpreter
- Pycharm > Preferences > Project > Python Interpreter
- Click
to show all Python Interpreters, and select "add" to add new python interpreter
- Select the existing server configuration
- Click next to map the project path to ROS container's path
/notebooks
, and finish interpreter configuration - File synchronization will start automatically. To view remote files, Tools > Deployment > Browse Remote Host
-
Add ROS lib to Python interpreter
- Show the paths for the remote interpreter
- Add ROS path
/opt/ros/noetic/lib/python3/dist-packages
into python interpreter
-
Select remote Python interpreter for your project
- Edit Run/Debug Configurations
- Select "Remote Python" in the Python interpreter
-
And run the code below for test
import torch #test torch with cuda import tf #test ros tf import rospy #test ros rospy print([torch.cuda.get_device_name(i) for i in range(torch.cuda.device_count())]) #check GPUs def print_hi(name): print(f'Hi, {name}') if __name__ == '__main__': print_hi('PyCharm')