코다마를 해봤어요.

코다마가 뭐예요?


raspberry pi의 VUI 키트입니다.오리지널 트리거 글자 만들기, 마이크 배열 음원 방향 측정 등 흥미롭다.
https://codama.ux-xu.com/
https://robotstart.info/2018/12/28/cidama-dev-01.html

하고 싶은 거: 코다마


나는 소리에 반응하는 캐릭터 로봇을 만들어 보고 싶다.
이제 다음 샘플을 이동해 보겠습니다.최종적으로 외부 포장도 설치할 예정이다.
· 샘플 1: 원시 촉발자와 반응하는 효과음
· 샘플 2: 말하는 방향에서 서보 모터를 사용하면 왠지 잘 어울린다

걸림돌도 몇 개 있어서 공유해요.그리고 저는 하드웨어 엔지니어이기 때문에 출처의 신뢰도가 그렇게 높지 않다는 것을 이해해 주시면 감사하겠습니다.

프로비저닝


기본적으로 아래 내용에 따라 설정하여 촉발자를 제작한다.
https://github.com/YUKAI/codama-doc-r0/wiki
걸려 넘어지는 요점은 코다마의 메인보드와 마이크판을 연결하는 케이블이 거꾸로 찌를 수 있다는 것이다.이 케이블의 방향은 주의해야 한다.빨간색 선은 사진의 방향이 정확하다.(백스핀은 손상되지 않았으나 동작하지 않음)

또 글자 등록을 깨울 때 조작판의 다이얼이 필요하다.출하 시 점퍼 상태이지만 기본 펌웨어가 시작됩니다.update.빈을 기입한 후 재킷을 꺼내 활용한다.나는 아래 사진처럼 한쪽만 끼고 재킷을 잃지 않았다.

이 두 가지를 제외하고는 기본적으로 교과서에 따라 하면 순조롭게 행동할 수 있다.

하드웨어 제작


다음 내용 준비
- raspi
- codama
- 스피커
- 서보 모터
하드웨어는 그다지 추천되지 않지만raspi의 5V계에서 서보를 이동합니다.코다마판의 CN10의 GND, 5V, GPIO4에 서보의 GND, VCC, Signal을 연결합니다.
스피커가 코다마 메인보드에 연결된 CN9.

이후 양면 테이프와 묶음끈으로 잘 만들었다.

견본1: 원시 촉발자에 반응효과음 재생


아주 간단해요.트리거 문자가 감지되면 GPIO27이 HIGH가 되므로 이를 모니터링하고 효과음을 재현하는 케이스 스크립트입니다.
Trigger_detect.sh
#!/bin/sh

if [ ! -f /sys/class/gpio/gpio27/value ]; then
  echo 27 > /sys/class/gpio/export
fi

TRGWORD=0
while true
do
  if [ "`cat /sys/class/gpio/gpio27/value`" = 1 ] ; then
    if [ $TRGWORD = 0 ] ; then
      aplay -c1 -r16000 -fS16_LE jump07.wav &
      TRGWORD=1
    fi
  else
    if [ $TRGWORD = 1 ] ; then
      TRGWORD=0
    fi
  fi
  sleep 0.2
done
관련 비디오
https://youtu.be/vFRrV7NrGRw
원시 촉발자는 상당히 정확하다.

샘플 2: 말하는 방향에서 서보 모터를 사용하면 왠지 잘 어울린다


코다마의 음원 방향을 이용하여 측정하다.
다음 명령을 통해 사용자가 터치하는 매개 변수를 알 수 있습니다.
pi@raspberrypi:~ $ cd codama/codama-doc/utils/
pi@raspberrypi:~/codama/codama-doc/utils $ ./codama_i2c -p
paramater              type    max          min          r/w          info                                    
---------              ----    ---          ---          ---          ----                                    
HPFONOFF               int     3            0            read-write   High-pass Filter on microphone signals.
                                                                      0 = OFF
                                                                      1 = ON - 70 Hz cut-off
                                                                      2 = ON - 125 Hz cut-off
                                                                      3 = ON - 180 Hz cut-off
AECSILENCELEVEL        float   0.93         1e-09        read-write   Threshold for signal detection in AEC [-inf .. 0] dBov (Default: -80dBov = 10log10(1x10-8))
AECSILENCEMODE         int     1            0            read-only    AEC far-end silence detection status. 
                                                                      0 = false (signal detected) 
                                                                      1 = true (silence detected)
AGCONOFF               int     1            0            read-write   Automatic Gain Control. 
                                                                      0 = OFF 
                                                                      1 = ON
AGCMAXGAIN             float   1000         1            read-write   Maximum AGC gain factor. 
                                                                      [0 .. 60] dB (default 30dB = 20log10(31.6))
AGCDESIREDLEVEL        float   0.99         1e-08        read-write   Target power level of the output signal. 
                                                                      [-inf .. 0] dBov (default: -23dBov = 10log10(0.005))
AGCGAIN                float   1000         1            read-write   Current AGC gain factor. 
                                                                      [0 .. 60] dB (default: 0.0dB = 20log10(1.0))
AGCTIME                float   1            0.1          read-write   Ramps-up / down time-constant in seconds.
BEAMWIDTH              float   1            0.2          read-write   Width of the beam for desired speech sources. 
                                                                      [23 .. 180] (default: 60 = sin-1(0.5) 360/ pi)
BEAMANGLE              float   1            -1           read-write   Center of the beam for desired speech sources. 
                                                                      [-90 .. 90] (default: 0 = sin-1(0.0) 360/2pi)
STATNOISEONOFF         int     1            0            read-write   Stationary noise suppression.
                                                                      0 = OFF
                                                                      1 = ON
GAMMA_NS               float   3            0            read-write   Over-subtraction factor of stationary noise. min .. max attenuation
MIN_NS                 float   1            0            read-write   Gain-floor for stationary noise suppression.
                                                                      [-inf .. 0] dB (default: -16dB = 20log10(0.15))
NONSTATNOISEONOFF      int     1            0            read-write   Non-stationary noise suppression.
                                                                      0 = OFF
                                                                      1 = ON
GAMMA_NN               float   3            0            read-write   Over-subtraction factor of non- stationary noise. min .. max attenuation
MIN_NN                 float   1            0            read-write   Gain-floor for non-stationary noise suppression.
                                                                      [-inf .. 0] dB (default: -10dB = 20log10(0.3))
ECHOONOFF              int     1            0            read-write   Echo suppression.
                                                                      0 = OFF
                                                                      1 = ON
VOICEACTIVITY          int     1            0            read-only    VAD voice activity status.
                                                                      0 = false (no voice activity)
                                                                      1 = true (voice activity)
SR_GAMMA_VAD           float   1000         0            read-write   Set the threshold for voice activity detection.
                                                                      [-inf .. 60] dB (default: 3.5dB 20log10(1.5))
KEYWORDDETECT          int     1            0            read-only    Keyword detected. Current value so needs polling.
DOAANGLE               int     359          0            read-only    DOA angle. Current value. Orientation depends on build configuration.
DOAANGLEKWD            int     359          0            read-only    DOA angle when keyword detects.
SOFTRESET              int     1            0            write-only   Soft Reset Request
MIC_ATTEN              int     0            -100         read-write   MIC input signal attenuator in decibels. [0 .. -100] dB (Default 0dB)
AEC_REF_ATTEN          int     0            -100         read-write   AEC reference signal attenuator in decibels. [0 .. -100] dB (Default: 0dB)
VERSION                int     2147483647   0            read-only    Version number
이번에는 사용해 보자DOAANGLE.
다음python 예시 코드를 만듭니다.raspi에서 서보 모터를 이동하는 라이브러리 사용pigpiod.처음에는 RPi.GPIO에서 진행되었으나 pwm의 소음으로 서보시스템이 빠르게 이동했습니다.
servo_test.py
import pigpio
import time
import subprocess
import signal
import sys

pin=4
pi = pigpio.pi()
pi.set_servo_pulsewidth(pin, 1500)


def res_cmd(cmd):
        return subprocess.Popen(cmd, stdout=subprocess.PIPE,shell=True).communicate()[0]

def main():
        current_angle = 90
        cmd = ("/home/pi/codama/codama-doc/utils/./codama_i2c DOAANGLE")
        while True:
                n=20
                i=0
                value = res_cmd(cmd).strip()
                target_angle = int(value.strip("DOAANGLE:"))
                if target_angle < 30 or target_angle > 150:
                        target_angle = 90
                print 'Target angle:' + str(target_angle)
                divided_angle = (current_angle - target_angle)/n
                while i<n:
                        current_angle -= divided_angle;
                        pi.set_servo_pulsewidth(pin, (85/9)*current_angle + 650)
                        time.sleep(0.05)
                        i+=1
                time.sleep(0.5)

if __name__ == '__main__':
  main()
다음을 수행합니다.
pi@raspberrypi:~/workspace $ sudo pigpiod
pi@raspberrypi:~/workspace $ sudo python servo_test.py 
관련 비디오
https://youtu.be/A05lSUaqGUc
말하면서 이쪽을 향한 기능이 흥미롭고, 가능성을 느꼈다.다만, 반응이 늦어졌다.또한 코다마 마이크의 사용 방법으로 마이크 진열을 프레임에 완전히 고정시켜 사용하는 것을 권장합니다. 이번 제 샘플에서 서보 앞부분의 이동 부분에 마이크를 설치하는 것도 정밀도가 약간 낮은 이유입니다.

아직 해결되지 않은 일에 빠지다


i2c가 보이지 않는 현상이 발생하다.
계속 이동하면 오류 메시지가 다음과 같이 거의 발생하지 않습니다.재현 조건은 불분명하지만 자신의 환경 이외에도 벌어지는 패턴이다.
rdwr ioctl error -1: No such device or address
Error: Control read command failed
해결 방법으로raspi와codama의 전원도 끊기고 다시 시작하면 대부분 회복됩니다.(하드웨어에서 5V를 다시 삽입합니다.reboot에서 NG)
이러지도 저러지도 못할 경우 다음과 같이 고치는 경우도 있다.
$ sudo raspi-config
  --> 5 Interfacing Options
   --> P5 I2C
       Select <No>
       Select <OK>
       Select <Finish>
一度、Raspberry Piを含め電源を落とし、入れ直す。起動したら、以下でI2Cデバイスが存在する事を確認。
$ ls -al /dev/i2c-1
이상은 코다마로 놀고 푹 빠진 포인트의 공유입니다.

좋은 웹페이지 즐겨찾기