# Jupyter 다루기

현재 터미널 상황입니다.

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThfd7gAwVnEBfWz4s_%2Fimage.png?alt=media\&token=e69182cb-abbf-4528-b66c-8adb859e0a1d)

**\[내 PC]** roscore 실행합니다.

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThflxdZ0QLbp-smhfi%2Fimage.png?alt=media\&token=197f478e-d749-4490-bab5-fee9ee1a1ea9)

**\[R1mini w/ SSH]** 통신 포트에 권한을 설정합니다.

* 666 : 리눅스의 파일 최대 접근 권한으로 읽기(w), 쓰기(r) 권한을 부여한 상태입니다.

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThfs4rWQl1SQ22vOqp%2Fimage.png?alt=media\&token=77092d31-be22-4373-a769-28008664835f)

**\[R1mini w/ SSH]** bringup.launch를 실행합니다.

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThg2LvZz68BbM8sHTP%2Fimage.png?alt=media\&token=1048d304-e34d-4b80-bae4-8998c6d4d35f)

**\[Jupyter in 내 PC]** Jupyter 화면에서

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThgDAMkpLRjwPvROkb%2Fimage.png?alt=media\&token=932e8205-7e55-4406-809d-235ca7c50fea)

**\[Jupyter in 내 PC]** 필요한 라이브러리를 import 하고,

```python
import rospy
from geometry_msgs.msg import Point, Twist
```

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThgIRG7z398wLBHFVO%2Fimage.png?alt=media\&token=9a37c0da-f077-4fab-b549-5ea970027baf)

**\[Jupyter in 내 PC]** 사용할 변수들을 아래와 같이 초기화 해줍니다.

```python
speed = Twist()
rospy.init_node("test_cmd_vel")
rate = rospy.Rate(100)
pub = rospy.Publisher("/cmd_vel", Twist, queue_size=1)
```

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThgO_gSRvBq0IP9EcT%2Fimage.png?alt=media\&token=480f0ea4-5630-4460-9642-8dca7402b1cc)

**\[Jupyter in 내 PC]** speed 변수에 넣은 twist 데이터를 확인하고,

```python
speed
```

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThgRRRQY7PcHmg3p1P%2Fimage.png?alt=media\&token=53d6bf50-db20-49ca-b88f-0be3b06b5e82)

**\[Jupyter in 내 PC]** x의 방향과 속도를 0.5로 설정해줍니다.

```python
speed.linear.x = 0.5
```

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThggEIX2vZuBRTdkVf%2Fimage.png?alt=media\&token=fdb232f0-f4ae-45db-9f46-95bf7e730fa0)

**\[Jupyter in 내 PC]** 로봇을 동작 시켜보아요\~

```python
while True:
    pub.publish(speed)
    rate.sleep()
```

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThgj2BQ9qAL5DHISac%2Fimage.png?alt=media\&token=faa65ab1-af97-43bb-8ee7-4aa0055c8e54)

**\[Jupyter in 내 PC]** 멈추고 싶을 때는 정지 버튼을 누릅니다.

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThgmIQFQpG3CkPR8B1%2Fimage.png?alt=media\&token=9f6e31be-0725-4c74-9431-fb4312eefc92)

**\[Jupyter in 내 PC]** Battery 상태를 확인할 수 있게 하는 명령입니다.

```python
from omo_r1mini_bringup.srv import Battery

bat_status = rospy.ServiceProxy('/battery_status', Battery)
bat_status()
```

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThgrydnfLEWDPoRhwT%2Fimage.png?alt=media\&token=ba1f46fc-3e12-419b-979f-0e1922c712c6)

**\[Jupyter in 내 PC]** led의 색상을 변경할 수 있는 명령입니다.

```python
from omo_r1mini_bringup.srv import Color

set_leds = rospy.ServiceProxy('/set_led_color', Color)
set_leds(250,50,50)
```

![](https://491696592-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MK7gxD_6rkqAewni4tk%2F-MThe-kCNC5ADnUzqpng%2F-MThgxL7U27NIpGgxcGT%2Fimage.png?alt=media\&token=507e3d8c-ebd3-4f9d-aa0b-9fd8ec970ed0)
