StewartOlatform

Dependencies:   mbed

Committer:
heroistired
Date:
Wed Oct 11 07:05:25 2017 +0000
Revision:
0:2b80f11eb1d3
stewart platform

Who changed what in which revision?

UserRevisionLine numberNew contents of line
heroistired 0:2b80f11eb1d3 1 #include "mbed.h"
heroistired 0:2b80f11eb1d3 2 #include <stdio.h>
heroistired 0:2b80f11eb1d3 3 #include <stdlib.h>
heroistired 0:2b80f11eb1d3 4 #include <math.h>
heroistired 0:2b80f11eb1d3 5 #include "StewartPlatform.h"
heroistired 0:2b80f11eb1d3 6 DigitalOut myled(LED1);
heroistired 0:2b80f11eb1d3 7 Serial pc(SERIAL_TX, SERIAL_RX);
heroistired 0:2b80f11eb1d3 8 StewartPlatformType Platform; //动感平台数据结构体
heroistired 0:2b80f11eb1d3 9
heroistired 0:2b80f11eb1d3 10 int main()
heroistired 0:2b80f11eb1d3 11 {
heroistired 0:2b80f11eb1d3 12 while(1)
heroistired 0:2b80f11eb1d3 13 {
heroistired 0:2b80f11eb1d3 14 myled = 1; // LED is ON
heroistired 0:2b80f11eb1d3 15 wait(0.2); // 200 ms
heroistired 0:2b80f11eb1d3 16 myled = 0; // LED is OFF
heroistired 0:2b80f11eb1d3 17 wait(1.0); // 1 sec
heroistired 0:2b80f11eb1d3 18
heroistired 0:2b80f11eb1d3 19
heroistired 0:2b80f11eb1d3 20 Platform.topRadius = 244.95; //平台参数初始化
heroistired 0:2b80f11eb1d3 21 Platform.topInterval = 100;
heroistired 0:2b80f11eb1d3 22 Platform.bottomRadius = 332.54;
heroistired 0:2b80f11eb1d3 23 Platform.bottomInterval = 340;
heroistired 0:2b80f11eb1d3 24 Platform.lengthOfSteelWheel = 150;
heroistired 0:2b80f11eb1d3 25 Platform.lengthOfCardan = 150;
heroistired 0:2b80f11eb1d3 26 Platform.lengthOfBar = 368;
heroistired 0:2b80f11eb1d3 27 Platform.x = 25; //设定上平台姿态
heroistired 0:2b80f11eb1d3 28 Platform.y = 31;
heroistired 0:2b80f11eb1d3 29 Platform.z = 278;
heroistired 0:2b80f11eb1d3 30 Platform.a = 15;
heroistired 0:2b80f11eb1d3 31 Platform.b = 12;
heroistired 0:2b80f11eb1d3 32 Platform.c = 22;
heroistired 0:2b80f11eb1d3 33 CalStewartPlatform(&Platform); //解析平台数据
heroistired 0:2b80f11eb1d3 34 pc.printf("Angle: %.2f %.2f %.2f %.2f %.2f %.2f \r\n", Platform.theta[0], Platform.theta[1], Platform.theta[2], Platform.theta[3], Platform.theta[4], Platform.theta[5]);
heroistired 0:2b80f11eb1d3 35 pc.printf("Servo Angle: %.2f %.2f %.2f %.2f %.2f %.2f \r\n", Platform.theta_servo[0], Platform.theta_servo[1], Platform.theta_servo[2], Platform.theta_servo[3], Platform.theta_servo[4], Platform.theta_servo[5]);
heroistired 0:2b80f11eb1d3 36 pc.printf("BarLength: %.2f %.2f %.2f %.2f %.2f %.2f \r\n", Platform.BarLength[0], Platform.BarLength[1], Platform.BarLength[2], Platform.BarLength[3], Platform.BarLength[4], Platform.BarLength[5]);
heroistired 0:2b80f11eb1d3 37 }
heroistired 0:2b80f11eb1d3 38 }