全部 / 兴趣交流 / 生活杂谈 · 2022年10月8日 0

Want You Gone(feat. GlaDOS)

本文最后更新于 805 天前,其中的信息可能已经有所发展或改变。

上个学期的实训课

我负责剪辑,因为是机器人,就想到了GlaDOS的歌声

然后就有了以下视频

最难的地方是剪辑和组装

代码部分水一下,万一下届的同学看到

#include "VarSpeedServo.h"

VarSpeedServo RU;
VarSpeedServo RL;
VarSpeedServo LU;
VarSpeedServo LL;

const int vel = 50, vel_Back = 15, vel_turn= 15;
const int delay_Forward = 700, delay_Back = 750, delay_turn = 500;
int vel_Dance1 = 30,vel_Dance2 = 25,    vel_Dance3 = 40;
int delay_Dance1 = 300,delay_Dance2 = 750, delay_Dance3 = 200;
int vel_Dance4 = 20, delay_Dance4 = 400;
int vel_Dance5 = 20, delay_Dance5 = 400;
const int array_cal[4] = {90,90,90,90};
int RU_Degree = 0, LU_Degree = array_cal[2] + 5;
const int num1 = 6;

const int array_forward[num1][4] =
{
  {0,-40,0,-20},
  {30,-40,30,-20},
  {30,0,30,0},
  {0,20,0,40},
  {-30,20,-30,40},
  {-30,0,-30,0},
};

const int num3 = 5;
const int array_left[num3][4] =
{
   {-60,0,-40,0},
   {-60,30,-40,30},
   {0,30,0,30},
   {30,0,30,0},
   {0,0,0,0},
};

const int num4 = 5;
const int array_right[num4][4] = {
  {40,0,20,0},
  {40,-30,20,-20},
  {0,-30,0,-20},
  {-30,0,-30,0},
  {0,0,0,0},
};
const int num_dance1 = 10;
const int array_dance1[num_dance1][4] ={
  {0,-20,0,0},
  {0,-40,0,20},
  {0,-20,0,40},
  {0,0,0,20},
  {0,0,0,0},
  {0,0,0,20},
  {0,-20,0,40},
  {0,-40,0,20},
  {0,-20,0,0},
  {0,0,0,0},
};
const int num_dance2 = 32;
const int array_dance2[num_dance2][4] = {
                {20,0,40,0},
                {20,40,10,40},
                {20,0,10,40},
                {20,0,40,0},
                {20,0,10,0},
                {20,0,40,0},
                {20,0,40,-30},
                {20,80,40,-30},
                {20,0,40,-30},
                {20,-80,40,0},
                {20,0,40,-30},
                {20,30,40,-30},
                {20,0,40,20},
                {20,20,40,-30},
                {20,0,40,0},
                {0,0,0,0},
                {-40,0,-20,0},
                {-40,-20,-20,30},
                {-20,40,-20,30},
                {0,40,-20,30},
                {0,20,-20,30},
                {-40,20,-20,30},
                {-40,-20,-20,0},
                {-40,20,-20,-80},
                {0,40,-20,0},
                {-40,40,-20,80},
                {0,20,-20,0},
                {40,0,-20,-80},
                {-40,60,-20,0},
                {-40,60,-20,30},
                {-40,0,-20,60},
                {0,0,0,0},
};

const int num_dance4 = 44;
 const int array_dance4[num_dance4][4] = {
     {0,-40,0,0},
     {0,-40,0,40},
     {0,0,0,0},
     {0,-40,0,40},
     {0,0,0,0},
     {0,-40,0,40},
     {0,0,0,0},
     {0,-40,0,40},
     {0,0,0,0},
     {0,-40,0,40},
     {0,0,0,0},
     {0,-40,0,40},
     {0,0,0,0},
     {0,-40,0,40},
     {0,0,0,0},
     {0,30,0,80},
     {0,30,0,0},
     {0,30,0,45},
     {0,30,45,45},
     {0,30,-45,45},
     {0,30,0,0},
     {0,0,0,0},
     {0,-80,0,-40},
     {0,0,0,-40},
     {0,-45,0,-40},
     {-45,-45,0,-40},
     {45,-45,0,-40},
     {0,0,0,-40},
     {0,0,0,0},
     {0,30,0,80},
     {0,30,0,0},
     {0,30,0,45},
     {0,30,45,45},
     {0,30,-45,45},
     {0,30,0,0},
     {0,0,0,0},
     {0,-80,0,-40},
     {0,0,0,-40},
     {0,-45,0,-40},
     {-45,-45,0,-40},
     {45,-45,0,-40},
     {0,0,0,-40},
     {0,0,0,0},
};
const int num_dance3 = 16;
const int array_dance3[num_dance3][4] ={
   {0,-40,0,0},
   {20,-30,20,20},
   {40,0,40,30},
   {0,0,0,40},
   {-20,-20,-20,30},
   {-40,-30,-40,0},
   {0,-40,0,0},
   {0,0,0,0},
   {0,-40,0,0},
   {20,-30,20,20},
   {40,0,40,30},
   {0,0,0,40},
   {-20,-20,-20,30},
   {-40,-30,-40,0},
   {0,-40,0,0},
   {0,0,0,0},
 };

const int num2 = 6;
const int array_back[num2][4] ={
 {-40,0,-20,0},
 {-40,30,-20,30},
 {0,30,0,30},
 {40,0,20,0},
 {40,-30,20,-30},{0,-30,0,-30},
 };

const int num_dance5 = 25;
 const int array_dance5[num_dance5][5] = {
     {0,0,0,0},
     {0,40,0,0},
     {0,0,0,0},
     {0,40,0,0},
     {0,0,0,0},
     {0,0,0,-40},
     {0,0,0,0},
     {0,0,0,-40},
     {0,0,0,0},
     {0.40,0,-40},
     {0,0,0,0},
     {0.40,0,-40},
     {0,0,0,0},
     {0,-40,0,0},
     {0,0,0,0},
     {0,-40,0,0},
     {0,0,0,0},
     {0,0,0,40},
     {0,0,0,0},
     {0,0,0,40},
     {0,0,0,0},
     {0.-40,0,40},
     {0,0,0,0},
     {0.-40,0,40},
     {0,0,0,0},
     
};

#define RUN

void Servo_Init()
{
    RU.attach(3);
    RL.attach(5);
    LU.attach(6);
    LL.attach(9);
}

void Adjust()
{
   for(RU_Degree = array_cal[0] - 5; RU_Degree <= array_cal[0]; RU_Degree += 1) {
   RU.write(RU_Degree);
   LU.write(LU_Degree--);
   delay(15);
 }
}

//bool TooClose()
//{
//int tooclose = 0;
//for(int a=0; a<5; a++) {
// delay(50);
//int din = sonar.ping_in();
//if (din < 7 && din > 0) tooclose++;
// }
//if (tooclose < 5) return 1;
//return 0;
//}

void Forward()
{
    for(int x=0; x<num1; x++) {
     RU.slowmove (array_cal[0] + array_forward[x][0] , vel);
     RL.slowmove (array_cal[1] + array_forward[x][1] , vel);
     LU.slowmove (array_cal[2] + array_forward[x][2] , vel);
     LL.slowmove (array_cal[3] + array_forward[x][3] , vel);
     delay(delay_Forward);
    }
}
void Turnleft()
{

     for(int z=0; z<2; z++) {
          for(int y=0; y<num3; y++) {
          RU.slowmove (array_cal[0] + array_left[y][0] , vel_Back);
          RL.slowmove (array_cal[1] + array_left[y][1] , vel_Back);
          LU.slowmove (array_cal[2] + array_left[y][2] , vel_Back);
          LL.slowmove (array_cal[3] + array_left[y][3] , vel_Back);
          delay(delay_Back);
          }
    }
}

void Turnright(){
    for(int z=0; z<2; z++) {
         for(int y=0; y<num4; y++) {
          RU.slowmove (array_cal[0] + array_right[y][0] , vel_Back);
          RL.slowmove (array_cal[1] + array_right[y][1] , vel_Back);
          LU.slowmove (array_cal[2] + array_right[y][2] , vel_Back);
          LL.slowmove (array_cal[3] + array_right[y][3] , vel_Back);
          delay(delay_Back);
        }
    }
}

void Slide_2_Left(int times)
{
  for(int time1 = 0; time1 < times; time1++) 
  {
    for(int z=0; z<5; z++)
    {
    vel_Dance2 = 20;
    RU.slowmove (array_cal[0] + array_dance1[z][0] , vel_Dance1);
    LU.slowmove (array_cal[2] + array_dance1[z][2] , vel_Dance1);
     LL.slowmove (array_cal[3] + array_dance1[z][3] , vel_Dance1);
    delay(delay_Dance1);}
  }
}

void Left_Foot_Support(){
  for(int z=0; z<16; z++) {
  if ( z > 5 && z < 14) 
  {
       vel_Dance2 = 20;delay_Dance2 = 500; 
   }
   else {
         vel_Dance2 = 20;
        delay_Dance2 = 750; 
        }
  RU.slowmove (array_cal[0] + array_dance2[z][0] , vel_Dance2);
  RL.slowmove (array_cal[1] + array_dance2[z][1] , vel_Dance2);
  LU.slowmove (array_cal[2] + array_dance2[z][2] , vel_Dance2);
  LL.slowmove (array_cal[3] + array_dance2[z][3] , vel_Dance2);
  delay(delay_Dance2); 
  }
}


void Dancing1_2()
{
  Slide_2_Left(2);
  Left_Foot_Support();
 }
void Dancing4() 
{
     for(int z=0; z<num_dance4; z++) 
     {
       if ( z > 42) {
       vel_Dance4 = 10;
       delay_Dance4 = 1500;}
       else 
       {
       vel_Dance4 = 50;
       delay_Dance4 = 400;}
       RU.slowmove (array_cal[0] + array_dance4[z][0] , vel_Dance4);
       RL.slowmove (array_cal[1] + array_dance4[z][1] , vel_Dance4);
       LU.slowmove (array_cal[2] + array_dance4[z][2] , vel_Dance4);
       LL.slowmove (array_cal[3] + array_dance4[z][3] , vel_Dance4);
       delay(delay_Dance4);
   }
 }
 
void Dancing5() 
{
     for(int z=0; z<num_dance5; z++) 
     {
       if ( z > 23) {
       vel_Dance5 = 10;
       delay_Dance5 = 1500;}
       else 
       {
       vel_Dance5 = 60;
       delay_Dance5 = 400;}
       RU.slowmove (array_cal[0] + array_dance5[z][0] , vel_Dance5);
       RL.slowmove (array_cal[1] + array_dance5[z][1] , vel_Dance5);
       LU.slowmove (array_cal[2] + array_dance5[z][2] , vel_Dance5);
       LL.slowmove (array_cal[3] + array_dance5[z][3] , vel_Dance5);
       delay(delay_Dance5);
   }
 }

void Dancing3(int Times = 1, int Vel = 40, int Delay = 400, int low = 0, int high = 0)
{
  for(int time3=0; time3<Times; time3++) 
  {
   for(int z=0; z<14; z++) { if ( time3 > 1 && time3 < 4)
    {
    vel_Dance3 = Vel;
    delay_Dance3 = Delay;
    }
    else 
    {
    vel_Dance3 = 40;
    delay_Dance3 = 400;
    }
     RU.slowmove (array_cal[0] + array_dance3[z][0] , vel_Dance3);
     RL.slowmove (array_cal[1] + array_dance3[z][1] , vel_Dance3);
     LU.slowmove (array_cal[2] + array_dance3[z][2] , vel_Dance3);
     LL.slowmove (array_cal[3] + array_dance3[z][3] , vel_Dance3);
     delay(delay_Dance3);
     }
    }
  for(int z=14; z<8; z++) {
      RU.slowmove (array_cal[0] + array_dance3[z][0] , vel_Dance3);
      RL.slowmove (array_cal[1] + array_dance3[z][1] , vel_Dance3);
      LU.slowmove (array_cal[2] + array_dance3[z][2] , vel_Dance3);
      LL.slowmove (array_cal[3] + array_dance3[z][3] , vel_Dance3);
    delay(delay_Dance3);
    }
}

void Backward(){
  for(int y=0; y<num2; y++)
  {
  RU.slowmove (array_cal[0] + array_back[y][0] , vel_Back);
  RL.slowmove (array_cal[1] + array_back[y][1] , vel_Back);
  LU.slowmove (array_cal[2] + array_back[y][2] , vel_Back);
  LL.slowmove (array_cal[3] + array_back[y][3] , vel_Back);
  delay(delay_Forward);
 }
}
void setup()
{
#ifdef RUN
  Servo_Init();
  Adjust();
  RL.slowmove (array_cal[1] , vel);
  LL.slowmove (array_cal[3] , vel);
 delay(2000);
#endif
}

void loop()
{
 Dancing5();
 delay(1000);
 Forward();
 delay(1000);
 Backward();
 delay(1000);
 Dancing1_2();
 delay(1000);
 Dancing4();
 Dancing3();
 
}