参加过表情机器人培训讲座的同学们可能就对这个机器人有印象,这是表情机器人培训团队的澳大利亚籍讲师制作的。
1)设计图如下:
2)结构完成后的样品
3.)完成外表修饰
当这个机器人加上各种面具的时候,就显得更加生动。
作品视频:
开源程序(使用软件arduino1.0.1):
#include
// define global variables
byte transitionsteps=20; // controls the speed of face transformation: more steps = slower transition
byte emotion=0;
Servo servo[12]; // define servos as an array for easy control
int uSmin=600; // minimum servo position in uS - adjust this value to suit your brand of servo.
int uSmax=2400; // maximum servo position in uS - adjust this value to suit your brand of servo.
int servoposition[]={1500,1500,1500,1500,1500,1500,1500,1500,1500,1500,1500,1500}; // this array stores the current position of each servo in uS (typically 1000 - 2000 uS)
int servotransition[12]; // this array stores the speed and direction for each servo as it moves
int servopin[]={17,6,15,11,3,2,4,5,13,12,14,16}; // digital pins used for servos
// servo 0 = D17 neck 17
// servo 1 = D6 mouth right 06
// servo 2 = D15 teeth / tongue 15
// servo 3 = D11 mouth left 11
// servo 4 = D3 eyebrow left inside 03
// servo 5 = D2 eyebrow right inside 02
// servo 6 = D4 eyebrow left outside 04
// servo 7 = D5 eyebrow right outside 05
// servo 8 = D13 eye right tilt 13
// servo 9 = D12 eye blink 12
// servo 10 = D14 eye right pan 14
// servo 11 = D16 eye left pan 16
int expression[]={ // this array stores the servo positions for different facial expressions
// 0 1 2 3 4 5 6 7 8 9 10 11
1500,1500,1500,1500,1500,1500,1500,1500,1500,1500,1500,1500, // 0 NEUTRAL
1500,1600,1500,1300, 600,2400, 800,2300,1200,2000,1500,1500, // 1 SAD
1500, 800,1500,2000,1500,1500,1500,1500,1600,1300,1500,1500, // 2 HAPPY
1500,1600,1500,1300,2200, 600,2400, 600,1500,1500,1500,1500, // 3 ANGRY
1500,1500,1500,1500,1100,1000,1900,1700,1500,1500,1500,1500, // 4 CURIOUS
1500,1600,1500,2000,1200,1800,1800,1200,1500,1500,1500,1500, // 5 SURPRISED
1500,1500,1500,2000,2000,1000,2000,1000,1500,1500, 800, 800, // 6 MISCHEVIOUS
1500, 750,1500,2000,1000,2000,1500,1500,1700,1300, 800,2200 // 7 SILLY
};
void setup()
{
for (int i=0;i<12;i++) // loop to initialize servos and arrays
{
servo[i].attach(servopin[i],uSmin,uSmax); // initialize servos starting at D53 and counting backward (limit travel between uSmin & uSmax)
servo[i].writeMicroseconds(expression[emotion*12+i]); // set servos to initial expression
delay(50); // delay limits power surge by initializing the servos one at a time.
}
//delay(1000);
}
void loop()
{
//return;
for(emotion=0;emotion<8;emotion++)
{
Transition();
delay(2000);
}
}
//===================================================================================== face transforms from one expression to the next =============================
void Transition()
{
for(int i=0;i<12;i++) // scan through servo positions
{
servotransition[i]=(expression[emotion*12+i]-servoposition[i])/transitionsteps; // calculate servo speed and direction required to transform expression
}
for(int j=0;j
{
for(int i=0;i<12;i++)
{
servoposition[i]+=servotransition[i]; // adjust the servos position
servo[i].writeMicroseconds(servoposition[i]); // update the servos position
}
delay(30); // limits speed to suit servo electronics
}
}