본문 바로가기
푸닥거리

파이썬을 활용한 로봇제어 응용

by [김경민]™ ┌(  ̄∇ ̄)┘™ 2020. 12. 6.
728x90

파이썬을 활용한 로봇제어 응용

 

 

 

cars.altinocoding.com/

 

Oceanit Altino Simulator

 

cars.altinocoding.com

 

#include <Altino.h>

 

void setup() {

  Serial.begin(115200);

  Go(500, 500);

  Steering(1);

  delay(4500);

  Go(0, 0);  

  Go(1000, 1000);  

  Steering(3);

  delay(5000);

  Go(0, 0);  

}

 

void loop() {

 

}

 

www.altinocoding.com/lessons-1-10

 

Altino Online - Lessons 1-10

Using the Display function to display letters, numbers, and characters on the Altino Virtual Car. Open the Cheat Sheet or it's posted on the left below, and look at Page 4.

sites.google.com

www.saeon.co.kr/main/sub_page.php?page_idx=92

 

새온

새온, 알티노, 알티노라이트, 스마트팜

www.saeon.co.kr

edu.saeon.co.kr/site/online/online2.html

 

새온에듀

새온에듀

edu.saeon.co.kr

 

www.hawaiinewsnow.com/2019/02/06/geek-beat-students-use-coding-move-altino-cars/

 

Geek Beat: Students use coding to move Altino cars

A student program is helping teach students how to code.

www.hawaiinewsnow.com

 

 

from Altino import*

Open('com7')

 

Go(300,300) #AI 자율주행 자동차 로봇 300 속도로 전진

delay(1000) #1초간 지연

Go(0,0) #AI 자율주행 자동차 로봇 멈춤

 

Close()

 

 

 

from Altino import*

Open('com7')

 

# Go(300,300) #AI 자율주행 자동차 로봇 300 속도로 전진

# delay(1000) #1초간 지연

# Go(0,0) #AI 자율주행 자동차 로봇 멈춤

 

#조도, 적외선0번 거리

# print(sensor.CDS, sensor.IR[0])

 

while 1:

    try :

        print(sensor.IR[0], sensor.IR[1], sensor.IR[2])

        delay(1000)

    except :

        break

 

Close()

 

 

 

from Altino import*

Open('com7')

 

Go(300,300) #AI 자율주행 자동차 로봇 300 속도로 전진

Steering(3) #오른쪽

delay(1000) #1초간 지연

Go(0,0) #AI 자율주행 자동차 로봇 멈춤

Steering(2) #중앙

#조도, 적외선0번 거리

# print(sensor.CDS, sensor.IR[0])

 

Close()

 

자율주행 기본 구조 코드

 

 

 

from Altino import*

Open('com7')

  

while 1:

 

    print(sensor.IR[0], sensor.IR[1], sensor.IR[2]) 

 

    status = 0

 

    if sensor.IR[0] > 400 :

        status = 0x01

    else:

        pass

 

    if sensor.IR[1] > 400 :

        status = status + 0x02

    else:

        pass

 

    if sensor.IR[2] > 400 :

        status = status + 0x04

    else:

        pass

 

    print(status) 

 

 

    if status == 0 :

     # 속도

     Go(400, 400)

     # 전방

     Steering(2)

    elif status == 1 :

     # 속도

     Go(400, 400)

     # 왼쪽

     Steering(1)

    elif status == 2 :

     # 속도

     Go(-400, -400)

     # 왼쪽

     Steering(1)

    elif status == 3 :

     # 속도

     Go(-400, -400)

     # 오른쪽

     Steering(3)

    elif status == 4 :

     # 속도

     Go(400, 400)

     # 오른쪽

     Steering(3)

    elif status == 5 :

     # 속도

     Go(400, 400)

     # 오른쪽

     Steering(2)

    elif status == 6 :

     # 속도

     Go(-400, -400)

     # 오른쪽

     Steering(1)

    elif status == 7 :

     # 속도

     Go(-400, -400)

     # 왼쪽

     Steering(1)

    else:

        pass

 

Close()

 

 

 

 

 

 

from Altino import*

Open('com7')

  

while 1:

 

    print(sensor.IR[0], sensor.IR[1], sensor.IR[2]) 

 

    status = 0

 

    if sensor.IR[0] > 400 :

        status = 0x01

    else:

        pass

 

    if sensor.IR[1] > 400 :

        status = status + 0x02

    else:

        pass

 

    if sensor.IR[2] > 400 :

        status = status + 0x04

    else:

        pass

 

    print(status) 

 

 

    if status == 0 :

     # 속도

     Go(400, 400)

     # 전방

     Steering(2)

     Led(0x0000|0x0003)

     Sound(37)

    elif status == 1 :

     # 속도

     Go(400, 400)

     # 왼쪽

     Steering(1) 

     Led(0x0020|0x0003)

     Sound(38)

    elif status == 2 :

     # 속도

     Go(-400, -400)

     # 왼쪽

     Steering(1)

     Led(0x0020|0x00c0)

     Sound(39)

    elif status == 3 :

     # 속도

     Go(-400, -400)

     # 오른쪽

     Steering(3)

     Led(0x0010|0x00c0)

     Sound(40)

    elif status == 4 :

     # 속도

     Go(400, 400)

     # 오른쪽

     Steering(3)

     Led(0x0010|0x0003)

     Sound(50)

    elif status == 5 :

     # 속도

     Go(400, 400)

     # 오른쪽

     Steering(2)

     Led(0x0000|0x0003)

     Sound(42)

    elif status == 6 :

     # 속도

     Go(-400, -400)

     # 왼쪽

     Steering(1)

     Led(0x0020|0x00c0)

     Sound(43)

    elif status == 7 :

     # 속도

     Go(-400, -400)

     # 왼쪽

     Steering(1)

     Led(0x0020|0x00c0)

     Sound(44)

    else:

        pass

 

Close()

 

 

 

 

 

 

 

 

from Altino import*

Open('com7')

  

while 1:

    

    print(SensorData.GSensor[1])

    print(sensor.IR[0], sensor.IR[1], sensor.IR[2]) 

   

    status = 0

 

    if SensorData.GSensor[1] >= 20 :

        Steering(1)

    elif SensorData.GSensor[1] <= -20 :

        Steering(3)

    else:

        pass

  

Close()

 

 

 

 

 

 

 

 

 

 

 

728x90

댓글