DonkeyCar3.1.0에 MPU 6050을 탑재하여 데이터 시각화

2794 단어 donkeycar
차리다
차에 MPU 6050을 설치하다


VCC, GND, SCL, SDA를 CPU 보드의 I2C에 연결
myconfig.py의
# HAVE_IMU = False
열다
HAVE_IMU = True
바꾸다
호스트 PC의
~/projects/donkeycar/donkeycar/management/makemovie.py

def draw_user_input(self, record, img):
마지막으로 다음 내용 추가
    if 'imu/acl_x' in record:
        imu_acl_x = float(record["imu/acl_x"]) / 10
        imu_acl_y = float(record["imu/acl_y"]) / 10
        imu_acl_z = float(record["imu/acl_z"]) / 10
        imu_gyr_x = float(record["imu/gyr_x"]) / 100
        imu_gyr_y = float(record["imu/gyr_y"]) / 100
        imu_gyr_z = float(record["imu/gyr_z"]) / 100

        textFontFace = cv2.FONT_HERSHEY_SIMPLEX
        textFontScale = 0.4
        textColor = (255,255,255)
        textThickness = 1

        cv2.putText(img,str(round(imu_acl_x,2)),(0,29),textFontFace,textFontScale,textColor,textThickness)
        cv2.putText(img,str(round(imu_acl_y,2)),(0,39),textFontFace,textFontScale,textColor,textThickness)
        cv2.putText(img,str(round(imu_acl_z,2)),(0,49),textFontFace,textFontScale,textColor,textThickness)
        cv2.putText(img,str(round(imu_gyr_x,2)),(0,79),textFontFace,textFontScale,textColor,textThickness)
        cv2.putText(img,str(round(imu_gyr_y,2)),(0,89),textFontFace,textFontScale,textColor,textThickness)
        cv2.putText(img,str(round(imu_gyr_z,2)),(0,99),textFontFace,textFontScale,textColor,textThickness)

        cv2.line(img,(width//2,0),(width//2,height-1),(255,255,0),1)
        cv2.line(img,(0,height//2),(width-1,height//2),(255,255,0),1)

        x=int(round(width/2+width/2*imu_acl_y))
        y=int(round(height/2))
        img = cv2.circle(img,(x,y),2,(0,255,0),-1)
        x=int(round(width/2))
        y=int(round(height/2+height/2*imu_acl_x))
        img = cv2.circle(img,(x,y),2,(0,255,0),-1)

        x=int(round(width/2+width/2*imu_gyr_y))
        y=int(round(height/2))
        img = cv2.circle(img,(x,y),2,(255,0,0),-1)
        x=int(round(width/2))
        y=int(round(height/2+height/2*imu_gyr_x))
        img = cv2.circle(img,(x,y),2,(255,0,0),-1)

        x=int(round(width/2+width/2*imu_gyr_z))
        y=int(round(height/2))
        img = cv2.circle(img,(x,y),2,(0,0,255),-1)
주: 기판의 설치 방향을 비단의 x-y 방향으로 조정했지만 위화감이 있어 x와 y(24, 25, 28, 29줄)로 바꿨습니다.
비디오 생성
교사 데이터를 만들어 호스트 PC로 전달
호스트 PC에서
donkey makemovie --tub ./data/--out ./movie.mp4
실행 프로그램

좋은 웹페이지 즐겨찾기