麦轮nijie

12 篇文章 5 订阅

在这里插入图片描述

/**
 *@title Mecanum Mobile Platform firmware config file
 * Copyright: Copyright (c) 2019 Abot [https://github.com/tloinny/STM32-for-Abot]
 *
 *@created on 2019-4-28  
 *@author:tony-lin
 *@version 1.0.0 
 * 
 *@description:	麦克纳姆轮移动平台运动学逆解
 */
#include "inverse_solution.h"

wheel_speed W_S;
car_speed C_S;

void speed_inverse_solution()
{
	W_S.Vw0 = C_S.Vx - C_S.Vy - C_S.W *(a+b);
	W_S.Vw1 = C_S.Vx + C_S.Vy + C_S.W *(a+b);
	W_S.Vw2 = C_S.Vx - C_S.Vy + C_S.W *(a+b);
	W_S.Vw3 = C_S.Vx + C_S.Vy - C_S.W *(a+b);
}

#include "delay.h"
#include "sys.h"
#include "timer.h"
#include "motor_gpio.h"
#include "led.h"
#include "encoder.h"
#include "motor_operate.h"
#include "inverse_solution.h"
#include "pid.h"

/**
 *@description define 
 *在这里配置用户代码中的define值
 */
#define a 0.0824
#define b 0.0665


#define TIM3_ARR 0XFFFF
#define TIM3_PSC 71
#define TIM4_ARR 100
#define TIM4_PSC 7199
#define MAX_RPM 70
#define waiting_forever 0
#define error -1

/**
 *@description extern 
 *在这里配置用户代码中的extern值
 */
typedef struct motor
{
	GPIO_TypeDef* motor_gpio_type[3];
	GPIO_InitTypeDef motor_gpio[3];
}motor;
 
extern int scan;
extern motor Motors[];
extern u8  TIM3CH1_CAPTURE_STA;
extern u16 TIM3CH1_CAPTURE_VAL;
extern u8  TIM3CH2_CAPTURE_STA;
extern u16 TIM3CH2_CAPTURE_VAL;
extern u8  TIM3CH3_CAPTURE_STA;
extern u16 TIM3CH3_CAPTURE_VAL;
extern u8  TIM3CH4_CAPTURE_STA;
extern u16 TIM3CH4_CAPTURE_VAL;
extern u32 temp0;
extern u32 temp1;
extern u32 temp2;
extern u32 temp3;

extern u32 rpm0;
extern u32 rpm1;
extern u32 rpm2;
extern u32 rpm3;

typedef struct wheel_speed
{
	float Vw0;
	float Vw1;
	float Vw2;
	float Vw3;
}wheel_speed;
extern wheel_speed W_S;

typedef struct car_speed
{
	float Vx;
	float Vy;
	float W;
}car_speed;
extern car_speed C_S;



#endif

/**
 *@title Mecanum Mobile Platform Firmware
 * Copyright: Copyright (c) 2019 Abot [https://github.com/tloinny/STM32-for-Mecanum-Mobile-Platform]
 *
 *@date on 2019-4-24  
 *@author:tony-lin
 *@version 1.0.0 
 * 
 *@description: Mecanum Mobile Platform application
 */
 
#include "sys_conf.h"

u32 temp0 = 0;
u32 temp1 = 0;
u32 temp2 = 0;
u32 temp3 = 0;
u32 rpm0 = 0;
u32 rpm1 = 0;
u32 rpm2 = 0;
u32 rpm3 = 0;

int main(void)
{
	delay_init();
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	LED_Init();
	uart2_init(115200);
	motor_init();
	LED0 = 1;
	
	C_S.Vx = 50;
	C_S.Vy = 500;
	C_S.W = 5;
		speed_inverse_solution();
		motor_run();
		TIM_SetCompare1(TIM4,100);
	TIM_SetCompare2(TIM4,100);
	TIM_SetCompare3(TIM4,100);
	TIM_SetCompare4(TIM4,100);
//	u32 temp0 = 0;
//	u32 temp1 = 0;
//	u32 temp2 = 0;
//	u32 temp3 = 0;
	while(1)
	{
		int num = 1;
		printf("rpm%d:%d \r\n",num,read_speed(num,waiting_forever,2));
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值