> For the complete documentation index, see [llms.txt](https://lamhung81-2.gitbook.io/github-basic-tutorial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lamhung81-2.gitbook.io/github-basic-tutorial/ket-noi-ros-hai-may-tinh.md).

# Kết nối ROS hai máy tính

#### KẾT NỐI ROS cho hai máy tính

Gỉa sử có 2 máy tính:

Máy 1: ground station tên là nguyen3620

ip là 134.59.129.159,

Máy 2: odroid

ip là 134.59.129.151

* kiểm tra thiết lập tên và ip address: more /etc/hosts
* edit với: sudo /etc/hosts, cần thiết lập cho may ground station và máy odroid

127.0.0.1 localhost

134.59.129.159 nguyen3620

134.59.133.151 odroid

.....

* mở 1 terminal mới, trên máy ground station, đặt

export ROS\_MASTER\_URI=<http://134.59.129.159:11311>

* mở 1 terminal mới, trên máy odroid, đặt

export ROS\_MASTER\_URI=<http://nguyen3620:11311>

* check với lệnh&#x20;

echo $ROS\_MASTER\_URI

Một số thông tin khác có thể cần check lại

echo $ROS\_IP

echo $ROS\_HOST\_NAME

## MỞ CÁC ỨNG DỤNG NHƯ GEDIT, CUTECOM, RQT\_GRAPH TRÊN REMOTE COMPUTER

Từ máy ground station, mở 1 terminal, type

ssh odroid\@134.59.129.151 -Y

(Hoặc ssh odroid\@134.59.129.151 -X , for untrusted client??)

Nếu có warning:

```
Gtk
```

```
-
Message
:
Failed
 to load module 
"canberra-gtk-module"
```

```
sudo apt
```

```
-
get install libcanberra
-
gtk
*
```

## MAVROS

<http://wiki.ros.org/mavros>

### imu\_pub <a href="#mavros.2bac8-plugins.imu_pub" id="mavros.2bac8-plugins.imu_pub"></a>

Publish IMU state

#### Published Topics <a href="#mavros.2bac8-plugins.published_topics-3" id="mavros.2bac8-plugins.published_topics-3"></a>

\~imu/data ( [sensor\_msgs/Imu](http://docs.ros.org/api/sensor_msgs/html/msg/Imu.html))

* Imu data, orientation computed by FCU

\~imu/data\_raw ([sensor\_msgs/Imu](http://docs.ros.org/api/sensor_msgs/html/msg/Imu.html) )

* Raw IMU data without orientation

\~imu/mag ([sensor\_msgs/MagneticField](http://docs.ros.org/api/sensor_msgs/html/msg/MagneticField.html) )

* FCU compass data

\~imu/temperature ([sensor\_msgs/Temperature](http://docs.ros.org/api/sensor_msgs/html/msg/Temperature.html))

* Temperature reported by FCU (usually from barometer)

\~imu/atm\_pressure ([sensor\_msgs/FluidPressure](http://docs.ros.org/api/sensor_msgs/html/msg/FluidPressure.html))

* Air pressure.

## DÙNG ỨNG DỤNG ROSTOPIC ECHO ĐỌC DỮ LIỆU IMU

**rostopic echo /mavros/imu/data\_raw**

hoặc

**rostopic echo /mavros/imu/data**

Có kiểu **sensor\_msgs/Imu.msg**

Trong đó angular\_velocity có kiểu **geometry\_msgs/Vector3**

Và Vector3 có 3 thành phần x, y, z

Có thể tra cứu thông tin trực tiếp trên ROS, dùng **rosmsg show sensor\_msgs/Imu**&#x20;

Do đó, ví dụ, muốn hiển thị thành phần x của angular*velocity trên rqt\_graph* , cần chọn

**/mavros/imu/data/angular\_velocity/x**

## DÙNG ỨNG DỤNG ROSTOPIC ECHO LƯU DỮ LIỆU IMU

Giả sử cần lưu dữ liệu trong **home/android** vào 1 file có tên imu*14sept2017.txt*

**rostopic echo /mavros/imu/data >imu*****14sept2017.txt***

## DÙNG ỨNG DỤNG RQT\_GRAPH

rosrun rqt\_*graph rqt\_graph*

rồi ví dụ chọn trên cửa sổ bên trên góc trái /mavros/imu/data/angular\_velocity/x

## COPY DỮ LIỆU GIỮA 2 COMPUTER KHI KẾT NỐI SSH

Syntax:

```
scp  < source > < destination >
```

To copy a file from `B` to `A` while logged into `B`:

```
scp /path/to/file username@a:/path/to/destination
```

To copy a file from `B` to `A` while logged into `A`:

```
scp username@b:/path/to/file /path/to/destination
```

Vi du

scp imu\_data.txt nguyen\@134.59.129.159:/home/nguyen

scp -r odroid\@odroid:/home/odroid/catkin\_ws/src/i3s\_img\_proc /home/lhnguyen/catkin\_ws/src

### COPY FOLDER TỪ 1 COMPUTẺR TỚI COMPUTER KHÁC KHI KẾT NỐI SSH

ou can use secure copy (scp) with the recursive option (`-r`):

```
scp -r /path/to/local/dir user@remotehost:/path/to/remote/dir
```

Alternatively, I recommend rsync because you can resume transfers if the connection breaks, and it intelligently transfers only the differences between files:

```
rsync -avz -e 'ssh' /path/to/local/dir user@remotehost:/path/to/remote/dir
```

Note that in both cases you should be careful of trailing slashes: moving`/path/to/local/dir`to`remotehost:/path/to/remote/dir/`results in`/path/to/remote/dir/dir`
