ステッピングモーター動作
メディア技術基礎(3Dプログラミング)最終課題
ある程度形になったのでとりあえず貼っておく
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | import SimpleOpenNI.*; import ddf.minim.*; SimpleOpenNI kinect; HashMap<Integer, PVector>hands= new HashMap<Integer, PVector>(); PVector posLeft = new PVector( 0 , 0 ); PVector posRight = new PVector( 0 , 640 ); boolean flag= false ; Minim minim; AudioPlayer hajime; AudioPlayer ok1; AudioPlayer ok2; AudioPlayer count; AudioPlayer bluescreen; void setup () { minim= new Minim( this ); ok1=minim.loadFile( "ok1.wav" ); ok2=minim.loadFile( "ok2.wav" ); hajime=minim.loadFile( "hajime.wav" ); hajime.play(); kinect= new SimpleOpenNI( this ); kinect.enableDepth(); kinect.setMirror( true ); kinect.enableRGB(); kinect.alternativeViewPointDepthToImage(); kinect.enableGesture(); kinect.addGesture( "Wave" ); kinect.addGesture( "RaiseHand" ); kinect.enableHands(); size(kinect.depthWidth(), kinect.depthHeight()); } void draw() { kinect.update(); //tint(128, 128, 128, 255); image(kinect.rgbImage(), 0 , 0 ); drawHands(); strokeWeight( 1 ); line(posLeft.x, 0 , posLeft.x, kinect.depthHeight()); line(posRight.x, 0 , posRight.x, kinect.depthHeight()); } void drawHands() { for (Map.Entry entry:hands.entrySet()) { int id=(Integer)entry.getKey(); PVector pos3d=(PVector)entry.getValue(); PVector posScreen = new PVector(); kinect.convertRealWorldToProjective(pos3d, posScreen); } } void onRecognizeGesture(String strGesture, PVector idPosition, PVector endPosition) { println( "ジェスチャー名:" +strGesture); kinect.startTrackingHands(endPosition); if (strGesture.equals( "Wave" )== true ) { if (flag== false ){ bluescreen=minim.loadFile( "bluescreen.wav" ); bluescreen.play(); flag= true ; } else { count=minim.loadFile( "count.wav" ); count.play(); } delay( 3000 ); PImage img1; img1=createImage( int (posRight.x-posLeft.x- 1 ),kinect.rgbHeight(),RGB); img1=kinect.rgbImage().get( int (posLeft.x), 0 , int (posRight.x-posLeft.x- 1 ),kinect.rgbHeight()); img1.save( "img1.jpg" ); save( "img.jpg" ); } else if (strGesture.equals( "RaiseHand" )== true ){ for (Map.Entry entry:hands.entrySet()) { int id=(Integer)entry.getKey(); PVector pos3d=(PVector)entry.getValue(); PVector posScreen = new PVector(); kinect.convertRealWorldToProjective(pos3d, posScreen); if (posScreen.x<kinect.depthWidth()/ 3 ) { posLeft=posScreen; println( "Left:" +posLeft.x+ "," +posLeft.y); ok1.play(); } else if (posScreen.x>kinect.depthWidth()/ 3 * 2 ) { posRight=posScreen; println( "Right:" +posRight.x+ "," +posRight.y); ok2.play(); } } } } void onUpdateHands( int handId, PVector pos, float time) { hands.put(handId, pos); } void onDestroyHands( int handId, float time) { hands.remove(handId); } |
パーツ到着
ステッピングモーターに続いて
・ArduinoMEGA
・RAMPS(1.4)
・A4988
と一通り部品が揃いました
RAMPSやステッピングモータードライバの使い方がはじめはさっぱりだったのですが
データシートやらwebで他のステッピングモータードライバの使い方を調べて、
念のため早稲田さんにメールで確認もとれたので近日中にまずはモーターを動かします
以下、進捗があれば追記していきます@1/11
RAMPSとドライバを使わず、前回と同じやり方で
ArduinoからのHIGH/LOWだけで制御することは可能@1/14
ドライバのみ、RAMPS+ドライバでは相変わらず動かず@1/17
http://reprap.org/wiki/RAMPS_1.4
http://www.pololu.com/file/download/a4988_DMOS_microstepping_driver_with_translator.pdf?file_id=0J450
Z様のRAIDボリューム破損
突然の青ゲロの後に、RAID破損のエラーが出たのでメーカー送りになりましたとさ・・・
アキバでデータ復旧してくれるところに相談したけど
SSDのRAIDの場合はやっぱり桁違いに高くなるのね
Z様がもう一台買えちまうわ・・・
最終課題のコードとスライドが一式消えたのを復旧せねば