資源簡介
麥克納倫控制原理和方法詳解及C語言代碼實現控制車底盤。

代碼片段和文件信息
//時間:2015-5-3
//作者:0721的
//描述:RM戰車2號程序
//QQ??:825470791
#include?“main.h“
extern?unsigned?char?sbus_rx_buffer[25];
extern?volatile??int?sbus_rx_buffer_2[25];
extern?unsigned?int?ANGLE_L;?
extern?struct?RC_Ctl_t?RC_Ctl;
int?current_v_201=0target_v_201=0current_v_203=0target_v_203=0;??
int?current_p_201=0target_p_201=0current_p_203=0target_p_203=0;??
int?xian_wei_y=0xian_wei_p=0;
int32_t?L=250W=200R=75;?????????????????//車尺寸,單位mm
int32_t?X_speed=0;
int32_t?Y_speed=0;?
int32_t?W_speed=0;
int32_t?right_or_left=0;
int32_t?forward_or_back=0;
int32_t?W_right_or_left=0;??
char?tiao_bian;
char?ALLOW_LAUNCH=0;
char?ALLOW_DBUS=0;?
char?motor1_Direction;????????????//0或者1???????四個輪子方向
char?motor2_Direction;????????????//0或者1
char?motor3_Direction;????????????//0或者1
char?motor4_Direction;????????????//0或者1?
int?pwm_data1=0pwm_data2=0;???????????????//電機1輸出?????pwm_data_n int?pwm_data3=0pwm_data4=0;???????????????//電機2的輸出??
int?pwm_launch=20;?????????????????????????????//發射電機
int32_t?W1=0W2=0W3=0W4=0;???????????????????//四個電機的轉速單位mm/s
int?CH0=1024CH1=1024CH2=1024CH3=1024S1=0S2=0XX=0YY=0ZZ=0;????//通道數據寄存
void?MOTOR_GPIO_Configuration(void);
void?Encoder_Configuration(void);
void?CH_TO_SPEED(void);
void?CH_TO_CLOUD(void);
int?main(void)
{
??MOTOR_GPIO_Configuration();
??//PWM_Configuration();??????/*-PWM1---(PA9---TIM1_CH2)--PWM2---(PA8---TIM1_CH1)--*/
TIM6_Configuration();
CAN1_Configuration();?????/*----CAN1_TX-----PA12----CAN1_RX-----PA11----*/
//CAN2_Configuration();?????/*----CAN2_TX-----PB13----CAN2_RX-----PB12----*/
USART2_Configuration();???/*-----USART2_RX-----PA3-*/?//for?D-BUS
USART3_Configuration();???/*-----USART3_TX-----PB10----USART3_RX-----PB11-----*/
//Encoder_Configuration();??//TIM3?TIM5?connect?to?encodera-b
//TIM3_CH1?-----?PC6//TIM3_CH2?-----?PC7
//TIM5_CH1?-----?PA0//TIM5_CH2?-----?PA1
TIM6_Start();??????????????
????while(1)
????{?
if(ALLOW_DBUS==0)????????//若采集完成進行使用,不許采集
{??
CH_TO_CLOUD();
CH_TO_SPEED();??
ALLOW_DBUS=1;
}?
????}
}
void?CH_TO_SPEED(void)
{
???????if(CH0<364)CH0=364;if(CH0>1684)CH0=1684;??????//檢驗
???????if(CH1<364)CH1=364;if(CH1>1684)CH1=1684;
???????if(CH2<364)CH2=364;if(CH2>1684)CH2=1684;
???????if(CH3<364)CH3=364;if(CH3>1684)CH3=1684;?
???????if(CH1<=1684&&CH1>=1024)????????//CH2戰車右直走
?{?? ?
?Y_speed=CH1-1024;
?right_or_left=1;
?}
?
???????else?if(CH1<1024&&CH1>=364)?????????//CH2戰車左直走
?{??
?Y_speed=1024-CH1;?
?right_or_left=-1;
?} ?
?
???????if(CH0<=1684&&CH0>=1024)?????????//CH3戰車前進
?{??
?X_speed=CH0-1024;?
?forward_or_back=1;
?} ?
???????else?if(CH0<1024&&CH0>=364)?????????//CH3戰車后退
?{???
?X_speed=1024-CH0;
?forward_or_back=-1;
?}
?
?if((CH2<824)||(CH2>1224))?????//YAW軸角度定義????更改區
?{?
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-01-14?19:45??51oú??ì3_?ó???é?·??×??òμ¥????×êá?\
?????目錄???????????0??2018-05-20?03:24??51oú??ì3_?ó???é?·??×??òμ¥????×êá?\麥克納姆輪最簡單控制資料\
?????文件?????1528540??2018-05-20?03:06??51oú??ì3_?ó???é?·??×??òμ¥????×êá?\麥克納姆輪最簡單控制資料\IMG_20150528_225403_LI.jpg
?????文件????????5931??2018-05-20?03:12??51oú??ì3_?ó???é?·??×??òμ¥????×êá?\麥克納姆輪最簡單控制資料\main.c
?????文件?????1020882??2015-04-14?00:46??51oú??ì3_?ó???é?·??×??òμ¥????×êá?\麥克納姆輪最簡單控制資料\Mecanum輪逆矩陣研究_劉磊.pdf
?????文件????????2051??2018-05-20?03:26??51oú??ì3_?ó???é?·??×??òμ¥????×êá?\麥克納姆輪最簡單控制資料\程序中的重要部分截取.txt
?????目錄???????????0??2018-05-20?03:24??麥克納姆輪最簡單控制資料\
?????文件?????1528540??2018-05-20?03:06??麥克納姆輪最簡單控制資料\IMG_20150528_225403_LI.jpg
?????文件????????5931??2018-05-20?03:12??麥克納姆輪最簡單控制資料\main.c
?????文件?????1020882??2015-04-14?00:46??麥克納姆輪最簡單控制資料\Mecanum輪逆矩陣研究_劉磊.pdf
?????文件????????2051??2018-05-20?03:26??麥克納姆輪最簡單控制資料\程序中的重要部分截取.txt
- 上一篇:譚浩強C程序設計第五版課件及源碼
- 下一篇:雙目相機標定結果應用——測三維坐標
評論
共有 條評論