ããŒã1
ããŒã2
ããŠã誰ãããã§ã«ã¹ãã¢ããŒããšçµã¿ç«ãŠãããããããã泚æããŸãããïŒ ããããã埩掻ããæãæ¥ãŸããã
ä»æ¥ã¯ãœãããŠã§ã¢ãåæããŸãã
ç§ãæäŸãããªãã·ã§ã³ã¯ã§ããã ãç°¡åã§ãã 圌ã«ãŠããŒã¯ãªèœåãæåŸ ããªãã§ãã ããã 圌ã®ä»äºã¯ãã ä»äº
äžååãªããšã«å¯Ÿããé建èšçãªæ¹å€ã¯ç¹ã«å¿ èŠãããŸãã:)ç§ã¯ãã§ã«æ¬ ç¹ãç¥ã£ãŠããŸãã ããããäœãã¯ã£ããããªãããšãããã°ãå°ããŠã説æããŸãã
ãããè¡ããïŒ
ã¿ã¹ã¯ãåçŽãªã¹ãããã«åå²ããŸãã
ãªã³ããŒãã³ã³ãããŒã©ãŒ
- åé²/åŸéããã³ã³ãŒããªã³ã°çšã®ãã£ã¿ãã©ã¢ãŒã¿ãŒã®å¶åŸ¡
- ã«ã¡ã©ãµãŒãå¶åŸ¡
- Bluetoothçµç±ã§åä¿¡ããã¢ãŒã·ã§ã³ã³ãã³ããå®è¡ããã«ã¡ã©ã®ãµãŒããå¶åŸ¡ãã
PC /ã©ããããã
- 移åæ¹åãèšå®ããããã®ã¢ãŒã¿ãŒã®é床ã®èšç®
- Bluetoothçµç±ã§å¶åŸ¡ãã±ããã転éãã
- ç°¡åã«å¶åŸ¡ã§ãããžã§ã€ã¹ãã£ãã¯æ¥ç¶
åé²/åŸéããã³ã³ãŒããªã³ã°çšã®ãã£ã¿ãã©ã¢ãŒã¿ãŒã®å¶åŸ¡
ããåºãã®HããªããžãL293D / L298Nã§ã¯ãªããæ¢è£œã®MotorShieldã䜿çšããŠãããããçºæããã®ã«ç¹ã«è€éãªãã®ã¯ãããŸããã AFMotorã©ã€ãã©ãªãŒã䜿çšããŸãã Motorshield V3ããããSPIãã¹ãå¿ èŠãªå Žåã¯ã ä¿®æ£çã䜿çšããŠãã ãã ã
ã³ã¡ã³ãã¯ããç°¡æœã§çããããéåžžã¯è±èªã§ã³ã¡ã³ããæžããŸãã
ã¢ãŒã¿ãŒãå¶åŸ¡ããããã®å€æ°ã宣èšããŸãã å³åŽã®ã¢ãŒã¿ãŒã¯4çªç®ã®ããŒãã«æ¥ç¶ãããå·ŠåŽã®ã¢ãŒã¿ãŒã¯3çªç®ã®ããŒãã«æ¥ç¶ãããŸãã
AF_DCMotor rMotor(4); //Right motor AF_DCMotor lMotor(3); //Left motor
äžããããæ¹åãšé床ã«å¿ããŠãã¢ãŒã¿ãŒã«å転ãåœããŸãïŒå·Šã®ã¢ãŒã¿ãŒã®å ŽåïŒïŒ
switch (lDirection){ case 0: lMotor.run(RELEASE); break; case 1: lMotor.run(FORWARD); lMotor.setSpeed(lSpeed); break; case 2: lMotor.run(BACKWARD); lMotor.setSpeed(lSpeed); break; }
é©åãªãšã³ãžã³ã®å ŽåïŒ
switch (rDirection){ case 0: rMotor.run(RELEASE); break; case 1: rMotor.run(FORWARD); rMotor.setSpeed(rSpeed); break; case 2: rMotor.run(BACKWARD); rMotor.setSpeed(rSpeed); break; }
lDirectionïŒãŸãã¯rDirectionïŒã¯æ¬¡ã®å€ãåããŸãã
0-ã¢ãŒã¿ãŒãåæ¢ããŸã
1-æ£è»¢
2-å転ããã¯ã
ã«ã¡ã©ãµãŒãå¶åŸ¡
ãµãŒããå¶åŸ¡ããããã«ã2ã€ã®ãªããžã§ã¯ãpanServoïŒã«ã¡ã©ã®å転ãæ åœïŒãštiltServoïŒãã«ããæ åœïŒã宣èšããŸãã ãµãŒãã¯æ©æ¢°çã§ãããå³åº§ã«å転ããªãããããã©ã€ããå転ã³ãã³ããå®è¡ããããã«å¿ èŠãªé 延ã®å€æ°ãå°å ¥ããŸãïŒ15ããªç§ã§ååã§ãïŒ
Servo panServo, tiltServo; long interval = 15; // interval at which to control servo long previousMillis = 0; unsigned long currentMillis;
previousMillisãšcurrentMillisã¯ããµãŒãã®å®è¡äžã«å¶åŸ¡ã«ãŒãã§æãã«åŸ æ©ããããšãé¿ããããã«äœ¿çšãããŸãã 確èªããŸã-æåŸã®ã³ãã³ããã15ããªç§ãçµéããŠããªãå ŽåããµãŒãã«ã³ãã³ããéä¿¡ããŠãç¡é§ã§ã-ãŸã ããžãŒã§ãã
ã«ã¡ã©ã®å転ãæ åœããéšåïŒ
//Rotate camera currentMillis = millis(); if(currentMillis - previousMillis > interval) { previousMillis = currentMillis; if (lastPan!=pan) panServo.write(pan); // tell pan servo to go to position if (lastTilt!=tilt) tiltServo.write(tilt); // tell tilt servo to go to position lastPan=pan; lastTilt=tilt; }
Bluetoothçµç±ã§åä¿¡ããã¢ãŒã·ã§ã³ã³ãã³ããå®è¡ããã«ã¡ã©ã®ãµãŒããå¶åŸ¡ãã
Arduinoã®èŠ³ç¹ããèŠããšãBluetoothã¢ãžã¥ãŒã«ã¯åã«ã·ãªã¢ã«ïŒUARTïŒããŒãã§ãã
ãããã£ãŠãã³ã³ãã¥ãŒã¿ãŒããäœããæ¥ãŠãããã©ããã確èªããããã«ããµã€ã¯ã«ã§åãåãããŸãã ãããã¡å ã«äœããèŠã€ãã£ãå Žåãã¹ããªãŒã å ã®ãã±ããã®å é ãæ¢ããŠããŸã-$ FFãã€ãïŒãµãŒãã®æ¥µç«¯ãªäœçœ®ãš255ã®ã¢ãŒã¿ãŒé床ã¯å®è³ªçã«åœ¹ã«ç«ããªã-ãµãŒãã³ãã¯ããæ©ãé£æ¥ãã250-255ã®é床ã¯å€ãããªãã®ã§ããã®å€ã¯ã¹ããªãŒã ã§éåžžã«é«ããªããŸããŸãã«ãããã«ããããã±ãŒãžã®å é ããã£ããã§ããŸããã¢ã«ãŽãªãºã ãè€éã«ããããšã§ä¿¡é Œæ§ãé«ããããšãã§ããŸãããããã§ååã§ãã
ããããŒãèŠã€ãã£ããããšã³ãžã³ã®æ¹åããšã³ãžã³ããšã«2ãããã§ãšã³ã³ãŒããããŠãããã€ããåãå ¥ããŸãã 次ã«ããšã³ãžã³ã®é床ãèªã¿åããŸã-ãšã³ãžã³ããã1ãã€ãïŒlSpeedãrSpeedïŒããã³ã«ã¡ã©ãµãŒãã®äœçœ®ïŒãã³ããã«ãïŒã
if (Serial.available()>0) { Header=Serial.read(); //If header found then get and process Cmd if (Header==255){ while(Serial.available()<5){}; Direction=Serial.read(); lSpeed=Serial.read(); rSpeed=Serial.read(); pan=Serial.read(); tilt=Serial.read();
次ã«ãå·Šå³ã®ãšã³ãžã³ã®æ¹åã匷調ããŸã
lDirection=Direction & 0x03; rDirection=(Direction & 0x0C) >> 2;
æåŸã®ã³ãã³ããåä¿¡ããŠââããæ¹åãŸãã¯é床ãå€æŽãããå Žåã¯ããšã³ãžã³ã®é床ãèšå®ããŠã«ã¡ã©ãå転ãããŸãã
ãããã¡ã€ã³ã®ã¯ãŒã¯ãµã€ã¯ã«å šäœã§ãã
void loop() { if (Serial.available()>0) { Header=Serial.read(); //If header found then get and process Cmd if (Header==255){ while(Serial.available()<5){}; Direction=Serial.read(); lSpeed=Serial.read(); rSpeed=Serial.read(); pan=Serial.read(); tilt=Serial.read(); lDirection=Direction & 0x03; rDirection=(Direction & 0x0C) >> 2; //Left if ((lastlDir!=lDirection) or (lastlSpeed!=lSpeed)){ switch (lDirection){ case 0: lMotor.run(RELEASE); break; case 1: lMotor.run(FORWARD); lMotor.setSpeed(lSpeed); break; case 2: lMotor.run(BACKWARD); lMotor.setSpeed(lSpeed); break; } lastlDir=lDirection; lastlSpeed=lSpeed; } //Right if ((lastrDir!=rDirection) or (lastrSpeed!=rSpeed)){ switch (rDirection){ case 0: rMotor.run(RELEASE); break; case 1: rMotor.run(FORWARD); rMotor.setSpeed(rSpeed); break; case 2: rMotor.run(BACKWARD); rMotor.setSpeed(rSpeed); break; } lastrDir=rDirection; lastrSpeed=rSpeed; } //Rotate camera currentMillis = millis(); if(currentMillis - previousMillis > interval) { previousMillis = currentMillis; if (lastPan!=pan) panServo.write(pan); // tell pan servo to go to position if (lastTilt!=tilt) tiltServo.write(tilt); // tell tilt servo to go to position lastPan=pan; lastTilt=tilt; } } } }
ã芧ã®ãšãããç°¡åãªããšã¯ã»ãšãã©ãããŸãã:)
Googleã³ãŒãã®ãããžã§ã¯ãããŒãžããã¹ã±ãããããŠã³ããŒãã§ããŸã ã
ã·ã£ãŒã·ã«ã³ãã³ããå®è¡ããããã«æããŸããã 次ã«ããããã®éä¿¡æ¹æ³ãåŠç¿ããå¿ èŠããããŸãã
ããã°ã©ãã³ã°ãç解ããã®ãé¢åããŸãã¯Delphiã®ã€ã³ã¹ããŒã«ã«æ¶æ¥µçã§ãã人ã¯ã ã³ã³ãã€ã«ãããããŒãžã§ã³ãããŠã³ããŒãã§ããŸã
ïŒLogitech Extreme 3D Proãžã§ã€ã¹ãã£ãã¯ãŸãã¯äžåœã®EasyTouchã²ãŒã ãããã§åäœããŸãïŒã
æ®ãã®éšåã§ã¯ããã«é²ã¿ãŸã:)
å¿ èŠãªãã®ïŒ
- Delphi 2010ïŒDelphi 7ã§ããããžã§ã¯ããã¡ã€ã«ã®æ°è¡ãä¿®æ£ããã ãã§æžã¿ãŸãïŒ
- ãªãŒãã³ComPortã©ã€ãã©ãªã® TComPortã³ã³ããŒãã³ãïŒ4.11ãã€ã³ã¹ããŒã«ãããŠããŸãïŒ
- JEDI VCLã®ã³ã³ããŒãã³ãTjvHIDDeviceãTjvHIDDeviceControllerã ç§ã¯v3.38ã䜿çšããŠããŸãããææ°ã®ãã®ãããŠã³ããŒãã§ããŸãã å šéšå ¥ããŠã䟿å©ã«
æ¹åãèšå®ããããã®ã¢ãŒã¿ãŒã®é床ã®èšç®
ååŸã«ç§»åããŠãåé¡ã¯ãããŸãããåãå·Šå³ã®ã¢ãŒã¿ãŒé床ãšåãæ¹åãèšå®ããã ãã§ãã
åãã®æ¹å転æã®ããã«ãçŽé²ããã®éžè±ã®å€ã§ããã¹ãã¢ã®æŠå¿µã玹ä»ããŸãã ãšã³ãžã³é床ã¯ã次ã®ããã«ååŸã«ç§»åããããã«èšç®ãããŸãã
if Speed>0 then begin //Forward //Left/Right turn lSpeed:=Speed-Steer; rSpeed:=Speed+Steer; if lSpeed<0 then lSpeed:=0; if rSpeed<0 then rSpeed:=0; if lSpeed>MaxSpeed then lSpeed:=MaxSpeed; if rSpeed>MaxSpeed then rSpeed:=MaxSpeed; end else begin //Backward //Left/Right turn lSpeed:=Speed+Steer; rSpeed:=Speed-Steer; if lSpeed>0 then lSpeed:=0; if rSpeed>0 then rSpeed:=0; if lSpeed<(-MaxSpeed) then lSpeed:=-MaxSpeed; if rSpeed<(-MaxSpeed) then rSpeed:=-MaxSpeed; end;
ã€ãŸããå·ŠåŽã®ãšã³ãžã³ã®é床ããåæ¹ã«ç§»åããå Žåãåå·®ãæžç®ããå³åŽã®ãšã³ãžã³ã®é床ã«å ç®ããŸãã ããããã®ãã©ãã¯ã«ãã¬ãŒããããããšãã·ã£ãŒã·ãå®å šã«åæ¢ããããšãªãã¹ã ãŒãºã«å転ããŸãã åŸæ¹ã«ç§»åãããšããèšå·ã¯åã«å€åããŸãã
ããŠãé床ãæ倧蚱容å€ãè¶ ããŠãããã©ããã確èªããŸãã ç¹ã«ãããã¯å¿ èŠä»¥äžã«é«ãé»å§ã§ã¢ãŒã¿ãŒã«é»åãäŸçµŠããŠãã人ã«åœ¹ç«ã¡ãŸã-æé«é床ãå¶éããã ãã§ã¢ãŒã¿ãŒã¯ç¡å·ã«ãªããŸãã
管çäŸïŒ
åé² -äž¡æ¹ã®ã¢ãŒã¿ãŒãžã®æ¹åã¯ã1ãã§ãé床ã¯åãã§ã
æ»ã -äž¡æ¹ã®ã¢ãŒã¿ãŒã®æ¹åã¯ã2ãã§ãé床ã¯åãã§ã
åããå·Šå³ã«å€ããã«ã¯ ãæ¹åãåãã«èšå®ããé床ã¯ç°ãªããŸãã é床ãé ãåŽã«åããŸãã
æå®ã®äœçœ®ã«åãããã« -é床ã¯åãã§ãã¢ãŒã¿ãŒã®æ¹åã¯ç°ãªããŸã-ããã¯äžå¿ãåã£ãŠå転ããŸãã
åæ¢ -äž¡æ¹ã®ã¢ãŒã¿ãŒã®æ¹åã0ã
Bluetoothçµç±ã§å¶åŸ¡ãã±ããã転éãã
Bluetoothã¢ãžã¥ãŒã«ãPCã«è¿œå ãããšã2ã€ã®ä»®æ³COMããŒãã圢æãããŸãïŒ1ã€ã¯ã€ã³ããŠã³ãããã1ã€ã¯ã¢ãŠãããŠã³ãïŒã
ããããã«æ¥ç¶ããã«ã¯ãçºä¿¡ããŒããéãã ãã§ãã Bluetoothèšå®ã®ããŒãã®ãªã¹ãã§ããŸãã¯ãã«ãŒããã©ãŒã¹æ¹åŒã§æå®ã§ããŸã-æ£ããããŒãã«æ¥ç¶ãããšãããã°ã©ã ã¯èªãããã¢ãžã¥ãŒã«ã®LEDã¯ç¹æ» ãåæ¢ããŸã-æ¥ç¶ã確ç«ãããããããã«çŽæ¥æ¥ç¶ãããŠãããšæ³å®ã§ããŸãã
procedure TfTank.bConnectClick(Sender: TObject); begin if Tank.Connected then begin Tank.Disconnect; bConnect.Caption:='Connect'; end else begin Tank.Port:=cbPort.Text; Tank.Connect; bConnect.Caption:='Disconnect'; MessageBeep(MB_ICONINFORMATION); end; end;
䟿å®äžããããããšã®éä¿¡ã«é¢é£ãããã¹ãŠã®ã¢ã¯ã·ã§ã³ãå®è£ ããTRCTankãšããå°ããªã¯ã©ã¹ãäœæããŸããã
TRCTank=class private fPort:string; ComPort:TComPort; Cmd, lastCmd:TControlPacket; fConnected:Boolean; function isConnected: boolean; protected public constructor Create; destructor Destroy;override; procedure Connect; procedure Disconnect; procedure SendCommand(lDir,left, rDir, right, pan, tilt:Byte); property Port:string read fPort write fPort; property Connected:boolean read isConnected; end;
æ¥ç¶ãšåæã¯ãåºæ¬çã«ããŒããééããã ãã§ãçŸåšã®ç¶æ ã確èªããŠãéããŠããããŒããéãããéãããããªãããã«ããŸãã
ããããã«ã³ãã³ããéä¿¡ããã«ã¯ãããããããã£ããããããããŒãäœæããŸãïŒã³ãŒã255ã®ãã€ãããããŸãïŒã ãããŠããããããããããåŸ ã£ãŠããé åºã§ã³ãã³ããæžãçããŸãã ãã®ãããªæ§é ãå€æ
TControlPacket=record Header, Direction, lSpeed, //left motor speed rSpeed :Byte;//right motor speed pan, tilt :Byte; //Camera pan & tilt end;
ã³ãã³ããéä¿¡ããæ©èœã§ã¯ãèšåãã䟡å€ã®ããå¯äžã®ããšã¯ã2ã€ã®ãªãã»ããã§1ãã€ãã«äž¡æ¹ã®ãšã³ãžã³ã®æ¹åããããã³ã°ããããšã§ãã æ®ãã¯æããã§ãã
procedure TRCTank.SendCommand; begin if not fConnected then Exit; Cmd.Header:=255; Cmd.Direction:=lDir + rDir shl 2; Cmd.lSpeed:=left; Cmd.rSpeed:=right; Cmd.pan:=pan; Cmd.tilt:=tilt; if (lastCmd.Direction=Cmd.Direction) and (lastCmd.lSpeed=Cmd.lSpeed) and (lastCmd.rSpeed=Cmd.rSpeed) and (lastCmd.pan=Cmd.pan) and (lastCmd.tilt=Cmd.tilt) then Exit; ComPort.Write(cmd, SizeOf(cmd)); lastCmd:=Cmd; end;
ç°¡åã«å¶åŸ¡ã§ãããžã§ã€ã¹ãã£ãã¯æ¥ç¶
æ®å¿µãªãããã€ã³ã¿ãŒãããäžã§è³¢æãªHIDããã€ã¹ã®æäœã«é¢ããããã¥ã¡ã³ãã¯ããŸããããŸããã ãã®çµæãMIDIããŒããä»ããŠåäœããããã«éä¿¡ãããããžã§ã€ã¹ãã£ãã¯ã2軞ãš4ã€ã®ãã¿ã³ãåããããã€ã¹ãšèŠãªãå€æ°ã®å€ãã³ãŒãã調ã¹ãŸããã ãã®ãªãã·ã§ã³ã¯ç§ã«ã¯åããŠããŸããã§ããã TjvJoystickã³ã³ããŒãã³ãã«é¢ããæ å ±ã¯ã©ãã«ããªãã£ããããå¶ç¶å¶ç¶èŠã€ããŸããã æ®å¿µã§ããããã®æç¹ã§æ¢ã«ã³ã³ããŒãã³ããäœæããŸãã:)ã ãããããããªãããããç解ããã®ãé¢åã§ãªããã°ãJEDI VCLã®æ¢è£œã®ã³ã³ããŒãã³ãã䜿çšã§ããŸãã
HIDããã€ã¹ãçŽæ¥æäœãããã®ã¬ããŒãããã€ãåäœã§åæããŸãã ãã ãããã¹ãŠã®ãžã§ã€ã¹ãã£ãã¯è»žïŒEasyTouchã«ã¯4ã€ãããŸãïŒãšãã¹ãŠã®ãã¿ã³ïŒ10ã12åã®ãžã§ã€ã¹ãã£ãã¯ïŒã䜿çšå¯èœã§ãã
ããã¯æ¬¡ã®ããã«æ©èœããŸãããã©ãŒã äžã®TjvHIDDeviceControllerã³ã³ããŒãã³ãã䜿çšããŠãã·ã¹ãã å ã®HIDããã€ã¹ã®ãªã¹ããååŸããã³ã³ãããã¯ã¹ã«åºåããŸãã SelectJoystickByIDïŒVIDãPIDïŒWordïŒãåŒã³åºããŠãéžæããããã€ã¹ãTRjoystickã¯ã©ã¹ã®ãªããžã§ã¯ãã«æž¡ããŸãã ïŒVendorIDããã³ProductIDã«ãã£ãŠéžæãããŸã-ããšãã°ãã·ã¹ãã ã®ããã€ã¹ãããŒãžã£ãŒã§è¡šç€ºã§ããŸãïŒã
TRjoystickã¯ã©ã¹ã¯ãã§ãã¯ã¢ãŠããå®è¡ãããžã§ã€ã¹ãã£ãã¯ããã¬ããŒããåãåããå€ã解èªãããã¿ã³ãšè»žã®ããããã£ãèšå®ãããã³ãã©ãŒããã·ãŒãžã£ãåŒã³åºããŸãã ããã°ã©ã ã§ã¯ããã³ãã©ãŒã¯æ¬¡ã®ããã«ãªããŸãã
procedure TfTank.OnJoyData; var Hat:THatPosition; CenterCamera:Boolean; begin Hat:=hCenter; CenterCamera:=False; //Easy touch joystick if (joyPID=6) and (joyVID=121) then begin scrPitch.Position:=TREasyTouchJoystick(Joy).rZ; scrAileron.Position:=TREasyTouchJoystick(Joy).Z; scrRudder.Position:=TREasyTouchJoystick(Joy).X; scrThrottle.Position:=TREasyTouchJoystick(Joy).Y; cbFire.Checked:=TREasyTouchJoystick(Joy).Btn1; cbAltFire.Checked:=TREasyTouchJoystick(Joy).Btn10; Hat:=TREasyTouchJoystick(Joy).Hat; CenterCamera:=TREasyTouchJoystick(Joy).Btn2; Speed:=Round(((TREasyTouchJoystick(Joy).rZ)-127)*2); Steer:=Round((TREasyTouchJoystick(Joy).Z)-127)*2; end; //Logitech Extreme 3D Pro if (joyPID=49685) and (joyVID=1133) then begin scrPitch.Position:=TRLogitechExtreme(Joy).Pitch; scrAileron.Position:=TRLogitechExtreme(Joy).Aileron; scrRudder.Position:=TRLogitechExtreme(Joy).Rudder; scrThrottle.Position:=TRLogitechExtreme(Joy).Throttle; cbFire.Checked:=TRLogitechExtreme(Joy).Btn1; cbAltFire.Checked:=TRLogitechExtreme(Joy).Btn2; Hat:=TRLogitechExtreme(Joy).Hat; CenterCamera:=TRLogitechExtreme(Joy).Btn1; Speed:=(TRLogitechExtreme(Joy).Pitch div 8)-255; //4096 to -256..256 Steer:=(TRLogitechExtreme(Joy).Aileron div 4)-127; //1024 to -127..128 end; ApplyDeadZone(Speed,DeadX); ApplyDeadZone(Steer,DeadY); if Speed>MaxSpeed then Speed:=MaxSpeed; if Speed<-MaxSpeed then Speed:=-MaxSpeed; if Speed>0 then begin //Forward //Left/Right turn lSpeed:=Speed-Steer; rSpeed:=Speed+Steer; if lSpeed<0 then lSpeed:=0; if rSpeed<0 then rSpeed:=0; if lSpeed>MaxSpeed then lSpeed:=MaxSpeed; if rSpeed>MaxSpeed then rSpeed:=MaxSpeed; end else begin //Backward //Left/Right turn lSpeed:=Speed+Steer; rSpeed:=Speed-Steer; if lSpeed>0 then lSpeed:=0; if rSpeed>0 then rSpeed:=0; if lSpeed<(-MaxSpeed) then lSpeed:=-MaxSpeed; if rSpeed<(-MaxSpeed) then rSpeed:=-MaxSpeed; end; scrLeft.Position:=-lSpeed; scrRight.Position:=-rSpeed; if (cbAltFire.Checked) and (bConnect.Caption='Connect') then bConnect.OnClick(Self); case Hat of hUp: Inc(Tilt); hUpRight:begin Inc(Tilt);Dec(pan); end; hRight: Dec(pan); hRightDown: begin Dec(Pan); Dec(tilt); end; hDown: Dec(Tilt); hLeftDown: begin Inc(pan);Dec(tilt); end; hLeft: Inc(pan); hLeftUp: begin Inc(pan);Inc(tilt); end; hCenter: if CenterCamera then begin pan:=panCenter; tilt:=tiltCenter; end; end; //Limit Pan&Tilt range if pan<minPan then pan:=minPan; if tilt<minTilt then tilt:=minTilt; if pan>maxPan then pan:=maxPan; if tilt>maxTilt then tilt:=maxTilt; //Show info lJoy.Caption:='S:'+IntToStr(Speed)+' D:'+InttoStr(Steer)+' L:'+InttoStr(lSpeed)+' R:'+InttoStr(rSpeed); lhat.Caption:=THatPosString[Integer(Hat)]; //Show camera position on sliders scrPan.Position:=pan; scrTilt.Position:=tilt; //Send command to tank Command2Tank; end;
ãŸãã軞ã®åº§æšã®çã®å€ãé床ç¯å²-256..256ããã³æ¹å-127..128ã«æå®ããŸãã
äœéã§ã®ç·åœ¢å¶åŸ¡ã§ã¯ãã¢ãŒã¿ãŒã«ã¯ãã®å ŽæãããããããåããåããªããããïŒçµéšã«ããïŒå°ããªäžæ垯ãå°å ¥ããŸã-ç¹å®ã®é床å€ããã®ã¿åããŸãã ïŒApplyDeadZoneïŒSpeedãDeadXïŒ; ApplyDeadZoneïŒSteerãDeadYïŒ;ïŒ
ã©ããŒãèæ ®ããåŸãé床ãç¯å²å€ã«ãªã£ãŠããªãããšã確èªããã¹ã©ã€ããŒã䜿çšããŠãã©ãŒã ã®ã¢ãŒã¿ãŒã®é床ã衚瀺ããŸãã
次ã«ãåžœåã®äœçœ®ã«å¿ããŠãã«ã¡ã©ã®æ¹åãå€æŽãããäžå€®ã«é 眮ããå¶éã確èªããŸãïŒéåžžãããžã¿ã«å¶åŸ¡ã®å¶éã«éããåã«ãµãŒããæ©æ¢°çã«åæ¢ããŸãïŒã å¥ã®ã¹ã©ã€ããŒãã¢ã§ã«ã¡ã©ã®äœçœ®ã衚瀺ããé床ã衚瀺ããæŠè»ã«ã³ãã³ããéä¿¡ããŸãã
procedure TfTank.Command2Tank; begin lDir:=0; rDir:=0; //prepare rDir, lDir data based on tracks speed case lSpeed of 0:lDir:=0; //stop 1..255: lDir:=1; //forward -255..-1:lDir:=2; //backward end; case rSpeed of 0:rDir:=0; //stop 1..255: rDir:=1; //forward -255..-1:rDir:=2; //backward end; Tank.SendCommand(lDir,Abs(lSpeed),rDir,Abs(rSpeed), pan, tilt); end;
ã³ãŒãã«ã¯ããŸããŸãªå®éšããããéžæããããŒããšãžã§ã€ã¹ãã£ãã¯ã®ä¿åãã«ã¡ã©ã®å¶åŸ¡ãšã»ã³ã¿ãªã³ã°ã®å¶éã®ä¿åãšèªã¿èŸŒã¿ãæ åœããéšåãããããžã§ã€ã¹ãã£ãã¯ã§ã¯ãªãé床ãšæ¹åã®ã¹ã©ã€ããŒãçŽæ¥åŒããŠå¶åŸ¡ãæ»ãããšãã§ããŸãã ããããããã¯ç®¡çã®äž»ãªã¿ã¹ã¯ã«ã¯é¢ä¿ãããŸããã 奜ããªããã«ã³ãŒãã䜿çšã§ããŸããå¿ èŠã«å¿ããŠãBolgenOSãé 眮ãããããšãã§ããŸãã
R BT RC Tankã®ãœãŒã¹ã¯ ããããžã§ã¯ãã®Webãµã€ãã§Googleã³ãŒãã§ããŠã³ããŒãã§ããŸãã
ç§ã¯æåã®äººããå¶åŸ¡ããã»ã¹ãåé€ããããšããŸããããã«ã¡ã©ã§ç»é¢ãæ®åœ±ããããšã¯æ©ç¥ãããªä»äºã§ãããããªãå¹³å¡ãªãã®ã§ããã ããããäžè¬çãªæå³ã¯æ確ã§ãã
PSçŸåšãã·ã£ãŒã·ã¯åå å·¥ã®ããã«å解ãããŠãããããããŒããŠã§ã¢äžã®ã³ãŒãã®å€æŽããã°ãã確èªããããšã¯ã§ããŸããã ãã ãããããªã§èŠãããããã«ãããŠã³ããŒãå¯èœãªããŒãžã§ã³ã¯å®å šã«æ©èœããŸãã