owned this note
owned this note
Published
Linked with GitHub
# Locobot setup for admin
###### tags : `SIS2021`
# Hardware and Software Setup
## LoCoBot
The LoCoBot is a low-cost mobile manipulator suitable for both navigation and manipulation from Carnegie Mellon University(CMU) and designed to run Facebook AI's PyRobot. PyRobot is an open source, lightweight, high-level interface on top of the robot operating system (ROS).
> The default LoCoBot is built on as following
- Yujin Robot Kobuki Base (YMR-K01-W1)
- Intel NUC NUC8i3BEH core i3 Mini PC
- WidowX 200 Mobile Manipulator
- Intel® RealSense™ Depth Camera D435

The LoCoBot's NUC is no GPU, so we added
to execute perception algorithms or deep learning model, and also used switch let NUC, Xavier-NX and laptop can connect each other.
> For the sis2021 course required
- Xavier-Nx
- Switch

## Network setup
Xavier-NX and NUC are connected to switch by RJ45, and they wifi connect EE-assistive_5G-1 so that can connect each other and use Internet. The LoCoBot wired fix ip and wifi fix ip can setting by yourself. The LoCoBot and Xavier-NX password are **locobot** and **111111**, respectively.

> LoCoBot wired fix ip
- Xavier-NX is 10.42.0.3
- NUC is 10.42.0.2
> LoCoBot wifi fix ip
| LoCoBot | Jetson hostname | NUC hostname | Xavier-NX | NUC |
|:--------:|:----------:|:-------:|:------:|:--:|
| 1 | xavier-nx01 | locobot | 192.168.50.101 | 192.168.50.201 |
| 2 | xavier-nx02 | locobot | 192.168.50.102 | 192.168.50.202 |
| 3 | xavier-nx03 | locobot | 192.168.50.103 | 192.168.50.203 |
| 4 | xavier-nx04 | locobot | 192.168.50.104 | 192.168.50.204 |
| 5 | xavier-nx05 | locobot | 192.168.50.105 | 192.168.50.205 |
| 6 | xavier-nx06 | locobot | 192.168.50.106 | 192.168.50.206 |
| 7 | xavier-nx07 | locobot | 192.168.50.107 | 192.168.50.207 |
| 8 | xavier-nx08 | locobot | 192.168.50.108 | 192.168.50.208 |
| 9 | xavier-nx09 | locobot | 192.168.50.109 | 192.168.50.209 |
| 10| xavier-nx10 | locobot | 192.168.50.110 | 192.168.50.210 |
Setting Xavier-NX and NUC wired and wireless network can use manual or command methods.
### manual
> LoCoBot
1. wired setting
Click setting --> network --> edit wired network --> IPV4
Change IPV4 method --> manual
Address --> 10.42.0.2
Netmask --> 24
Related setting can see below picture.

2. wifi setting
Click wifi --> wifi setting --> choose network and key passeword.
edit wifi --> IPV4
Change IPV4 method --> manual
Address --> 192.168.50.201
Netmask --> 24
Gateway --> 192.168.50.1
DNS --> 8.8.8.8
Related setting can see below picture.

3. check
*And then you can tested your setting by ifconfig.*
```
$ ifconfig
```

*Make sure you connect Internet.*
```
$ ping 8.8.8.8
```

### command
> For Xavier-NX
**nmcli** is a command-line tool for controlling NetworkManager and reporting network status.
1. wired setting
*Edit network.*
```
$ nmcli connection add con-name wired_name type ethernet ifname
eth0 autoconnect yes ip4 10.42.0.3/24 ipv4.method manual
```
*Connection this network.*
```
$ nmcli connection up wired_name
```
2. wifi setting
*you can see all accessible wifi.*
```
$ nmcli device wifi list
```
*Connect wifi.*
```
$ nmcli device wifi connect SSID-Name password wireless-password
```
*Modify wifi.*
```
$ nmcli connect modify SSID-Name command
```
*Reload wifi.*
```
$ nmcli connect up SSID-Name
```
3. check
*And then you can tested your setting by ifconfig.*
```
$ ifconfig
```
*Make sure you connect Internet.*
```
$ ping 8.8.8.8
```
## SSH
SSH (Secure Shell), can directly connect the remote server execute our commands on the local machine, and use below command.
```
$ ssh remote_hostname@remote_ip
```
If you don't input this command every time, the **sshpass** package and **alias** can achieve this idea. The sshpass can use ssh to execute command so that can directly connect the remote server with one command.
```
$ sudo apt-get install sshpass
$ sshpass -p password ssh remote_hostname@remote_ip [command]
```
Although sshpass is convenient approach, the command is so long. The alias can simplify it. You can customize frequently used and long commands as aliases, which will save a lot of time in execution.
*Edit bashrc.*
```
$ sudo vim ~/.bashrc
```
*Add command on the below.*
```
alias simplified_name="command"
```
*Source bashrc to refresh it.*
```
$ source ~/.bashrc
```
*Finally, you can input simplified_name to execute command.*
```
$ simplified_name
```
## ROS connection
In order to connect two or above machines under ros connection, the master must to be established on host, and the other machines which want to control need to connect the host.
> For LoCoBot
- host set on the Xavier-NX, and it ip is 10.42.0.3
- Slave set on the NUC, and it ip is 10.42.0.2
*On the host.*
```
$ sudo vim ~/.bashrc
```
*Add two commands on the below.*
```
export ROS_MASTER_URI=http://host_ip:11311
export ROS_IP=host_ip
```
*On the slave.*
```
$ sudo vim ~/.bashrc
```
*Add two commands on the below.*
```
export ROS_MASTER_URI=http://host_ip:11311
export ROS_IP=slave_ip
```
## laptop setup
The laptop can connect two methods wired and wireless, you can see the below picture.

### Network setting
Your laptop fix wired ip is 10.42.0.X, X is arbitrary number, but **1, 2 and 3 are used**. The fix wired ip setting can refer manual and command setting.
*After setting, checked by ping.*
```
laptop $ ping 10.42.0.2
laptop $ ping 10.42.0.3
```
*Connect wifi and check Internet.*
```
$ nmcli device wifi connect SSID-Name password wireless-password
$ ping 8.8.8.8
```
### SSH
*SSH to LoCoBot and Xavier-NX(number).*
```
$ ssh locobot@10.42.0.2
$ ssh xavier-nx(number)@10.42.0.3
```
### ROS connection
*Setting environment variable to connect ROS.*
```
$ export ROS_IP=l0.42.0.X
$ export ROS_MASTER_URI=http://10.42.0.3:11311
```
# Remote connection
## VNC setting
If want to use VNC, the VNC server and VNC viewer need to install on robot and laptop respectively, but if use noVNC, the VNC viewer is no need to install.
## VNC server
The VNC server required install on the robot, and setting password, launch server wait client to connect.
*Install VNC server.*
```
robot $ sudo apt-get install x11vnc
```
*set password, the default path is ~/.vnc/passwd*
```
robot $ x11vnc --storepasswd [stored path]
```
*Edit no screen resolution.*
```
robot $ sudo vim /etc/X11/xorg.conf
```
*Add setting.*
```
Section "Monitor"
Identifier "Configured Monitor"
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Default Device"
SubSection "Display"
Depth 24
Virtual 1920 1080
EndSubSection
EndSection
```
**Make sure launch auto login!**
*launch server.*
```
robot $ x11vnc -display :0 -rfbauth ~/.vnc/passwd -rfbport 5900 -loop -shared
```
## noVNC(recommended!)
The noVNC is very convenient method to remote connection, and only install on robot, so you don't need install noVNC on your laptop.
*Clone noVNC repo, and run noVNC.*
```
robot $ git clone https://github.com/novnc/noVNC.git
robot $ cd noVNC && ./utils/launch.sh --vnc localhost:5900
```
The port 5900 must be consistent with the port set by the VNC server, and the noVNC port is default 6080.
Use another computer to open the browser URL input ==http://remote_IP:6080/vnc.html==
you will see login interface, click connect and input password, then you will can remote the robot.


## VNC viewer on linux
You must install VNC viewer on your laptop, and connect VNC server to remote your robot. Take ubnutu 18.04 for example, the other os like Windows or macOS, please refer this website [VNC viewer download](https://www.realvnc.com/en/connect/download/viewer/linux/).
*Install VNC viewer.*
```
laptop $ wget https://www.realvnc.com/download/file/viewer.files/VNC-Viewer-6.20.529-Linux-x86.deb
laptop $ sudo dpkg -i VNC-Viewer-6.20.529-Linux-x86.deb
```
*If your laptop cannot install, please fix missing and broken packages, and install again.*
```
laptop $ sudo apt --fix-broken install
```
### How to use VNC viewer
*Open VNC viewer.*
```
laptop $ vncviewer
```
You will see this window.

select File --> new connection or press Ctrl+n

Fill VNC Server and Name, and then click it to connect VNC server, if you see this picture. Now you can remote the robot!

## VNC viewer on Mac
Enter vnc://remote_ip location in Safari to use your Mac as a VNC Viewer.
# byobu
This tool is very useful for managing your terminal, whether it is local or remote, it can be accessed by anyone.
*Install.*
```
$ sudo apt-get install byobu
```
*Open terminal, and type.*
```
$ byobu
```
*Then you can start use byobu.*
The common commands are as following
* `F2` create a new window
* `F3` and `F4` switch window
* `shift`+`F2` create a horizontal terminal
* `ctrl`+`F2` create a vertical terminal`
* `ctrl`+`D` delete current window
* `shift`+ arrow key change window