자율주행

    천정의 마커 인식을 통한 로봇의 위치인식

    http://blog.daum.net/pg365/295

    result

    #!/usr/bin/env python# license removed for brevity import rospyfrom std_msgs.msg import UInt16MultiArrayfrom std_msgs.msg import UInt16 pub = rospy.Publisher('control',UInt16MultiArray,queue_size=10)cmd_vel = UInt16MultiArray()cmd_vel.data = [0,0] def callback1(msg): rospy.loginfo(msg.data[0]) cmd_vel.data[0] = msg.data[0] cmd_vel.data[1] = msg.data[1] pub.publish(cmd_vel) def callback2(msg): cm..

    (10) 카메라 세팅 및 Opencv 설치

    라즈베리파이에 usb웹캠, opencv를 사용하기 위해 관련 패키지를 설치해보자. opencv package 설치 $sudo apt install ros-kinetic-opencv*cs usb cam 패키지 설치 sudo apt-get install ros-kinetic-usb-camcs rqt 패키지 설치 sudo apt-get install ros-kinetic-rqt ros-kinetic-rqt-common-pluginscs usb 웹캠을 라즈베리파이에 연결하고rosrun usb_cam usb_cam_node 명령어로 usb_cam 패키지 실행rqt_image_view명령어로 rqt를 실행한다영상이 안나오면 왼쪽 상단 image View밑에있는 버튼을 눌러서 /usb_cam/image_raw를 선택..

    (9) 아두이노 펌웨어

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 #if (ARDUINO >= 100) #include #else #include #endif #include #include #include ros::NodeHandle nh; Servo servo; int dir = 8; int pwm = 11; int val = 0; int angle = 100; void servo_cb( const std_msgs::UInt16MultiArray& cmd_msg){ val = cmd_msg.data[0]; //set servo angle, shoul..

    ROI 성공

    그레이처리, 가우시안 블러, 캐니 엣지, 허프변환 , ROI 를 사용해 직선과 곡선을 찾아낸다. #!/usr/bin/env python# -*- coding: cp949 -*- import rospyimport cv2import numpy as npfrom cv_bridge import CvBridge, CvBridgeErrorfrom sensor_msgs.msg import Imagefrom sensor_msgs.msg import CompressedImage class Display_image(): def __init__(self): self.selecting_sub_image = "raw" if self.selecting_sub_image == "compressed": self._sub = rosp..

    opencv roi

    import cv2import numpy as np def grayscale(img): # 흑백이미지로 변환 return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) def roi(img, vertices): mask = np.zeros_like(img) cv2.fillPoly(mask,vertices,255) masked = cv2.bitwise_and(img,mask) return masked img = cv2.imread('test.jpg')px = img.shape[0]px1 = img.shape[1]print(px, px1)r= 600.0/img.shape[1]dim = (800,int(img.shape[0]*r))resized = cv2.resize(img, dim, i..

    (8) motor_control 노드 작성

    motor_control 노드 #!/usr/bin/env python# license removed for brevity import rospyfrom std_msgs.msg import UInt16MultiArray pub = rospy.Publisher('cmd_vel',UInt16MultiArray,queue_size=10)cmd_vel = UInt16MultiArray()cmd_vel.data = [0,0] def callback1(msg): rospy.loginfo(msg.data[0]) cmd_vel.data[0] = msg.data[0] cmd_vel.data[1] = msg.data[1] pub.publish(cmd_vel) def motor_control(): rospy.init_node..

    (7) 키보드 조작노드 작성 (keyboard teleoperation)

    #!/usr/bin/env python import rospy from std_msgs.msg import Int32MultiArray import sys, select, termios, tty ROSCAR_MAX_ACCELL_VEL = 255 ROSCAR_MAX_STEERING_VEL = 180 ROSCAR_MIN_ACCELL_VEL = 0 ROSCAR_MIN_STEERING_VEL = 0 msg = """ Control Your ROSCAR! --------------------------- Moving around: w a s d x w/x : increase/decrease accell velocity a/d : increase/decrease steering velocity space key, ..