TungstenVn

Test số mecanum

Jul 5th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1.   Channels[0] = map(ps2x.Analog(PSS_LY), 256, 0, -255, 255);    
  2.   Channels[1] = map(ps2x.Analog(PSS_LX), 0, 256, -255, 255);
  3.   Channels[2] = map(ps2x.Analog(PSS_RX), 0, 256, -255, 255);
  4.  
  5.   Motors[0] = Channels[0];                      
  6.   Motors[1] = Channels[0];
  7.   Motors[2] = Channels[0];
  8.   Motors[3] = Channels[0];
  9.  
  10.   Motors[0] += Channels[1];
  11.   Motors[1] -= Channels[1];
  12.   Motors[2] -= Channels[1];
  13.   Motors[3] += Channels[1];
  14.  
  15.   Motors[0] += Channels[2];
  16.   Motors[1] -= Channels[2];
  17.   Motors[2] += Channels[2];
  18.   Motors[3] -= Channels[2];
  19.  
  20.   if (motors[i]>=0) {
  21.       analogWrite(MotorInput[i], motors[i]);
  22.       analogWrite(MotorOutput[i], 0);
  23.     } else {
  24.       analogWrite(MotorInput[i], 255+motors[i]);
  25.       analogWrite(MotorOutput[i], 255);
  26.     }
  27.  
  28. Đi thẳng: Núm trái y = 0,x = 128, núm phải: x =128
  29. channel 0 = 255, channel 1 = 0 ,  channel 2 = 0
  30. motor 0 = 255 + 0 + 0 = 255
  31. motor 1 = 255 - 0 - 0 = 255
  32. motor 2 = 255 - 0 + 0 = 255
  33. motor 3 = 255 + 0 - 0 = 255
  34.  
  35.  
  36.  
  37. đi chéo trái: núm trái: y = 92, x = 70, núm phải: x = 128
  38. channel 0 = 183,channel 1 = -139, channel 2 = 0
  39.  
  40. motor 0 = 183 -139 +0 = 44
  41. motor 1 = 183 +139 - 0 = 322
  42. motor 2 = 183 + 139 +0 = 322
  43. motor 3 = 183 - 139 - 0 = 44
Advertisement
Add Comment
Please, Sign In to add comment