Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 4thcomp 6th33222_copy
Fork of Locate by
locate.h
00001 #ifndef Locate_H 00002 #define Locate_H 00003 00004 #include <math.h> 00005 #include "Encoder.h" 00006 00007 00008 //Serial pc(SERIAL_TX, SERIAL_RX); 00009 /****************定数定義***************************/ 00010 00011 #define OUTERRING_D 140 //外輪間距離(mm) 00012 #define INNERRING_D 136 //内輪間距離(mm) 00013 #define PI 3.14159 //π 00014 #define RESOLUSION 200 //P/R(分解能) 00015 #define DIAMETER 32.05 //タイヤの直径(mm) 00016 #define ROUND_HOSEI 1.0367 //角度のズレを補正.038 00017 #define HOSEI 1.00 00018 // エンコーダの1ステップあたりの距離;(mm) 00019 #define LOCATE_STEP (DIAMETER*PI / RESOLUSION * HOSEI) 00020 //タイヤ間距離(mm) 00021 #define TIRE_DISTANCE ((OUTERRING_D + INNERRING_D) / 2) 00022 //機体が1回転するために必要なステップ数の”逆数” 00023 #define ROUND ((PI * DIAMETER / (RESOLUSION * TIRE_DISTANCE)) * ROUND_HOSEI) 00024 00025 /****************************************************************/ 00026 00027 00028 00029 00030 /********以下関数宣言*****************/ 00031 00032 //最初に一回だけ行う 00033 void setup(int team); 00034 00035 //setupの初期位置指定版 00036 void setup(int tx, int ty); 00037 00038 //位置情報を更新する。r,lはエンコーダから 00039 void update(); 00040 00041 //update()のprintfなし版 00042 void update_np(); 00043 00044 //xをmm換算して整数値として返す 00045 int coordinateX(); 00046 00047 //yをmm換算して整数値として返す 00048 int coordinateY(); 00049 00050 //thetaを返す 00051 float coordinateTheta(); 00052 00053 //encorderの値を回転数に変換。update内部で使われる 00054 int convert_enc_count(int16_t pulse, int8_t direction); 00055 00056 //x, y, thetaを0にする 00057 void erase(); 00058 00059 //仮想 00060 void virtual_setup(); 00061 00062 void virtual_update(); 00063 00064 int virtual_coordinateX(); 00065 00066 int virtual_coordinateY(); 00067 00068 float virtual_coordinateTheta(); 00069 /**********************************/ 00070 #endif 00071 00072 00073 00074 00075 00076 /**************Encoderライブラリで使う定義**************************/ 00077 00078 #ifdef TARGET_STM32F3 00079 #define __HAL_TIM_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNT) 00080 #define __HAL_TIM_IS_TIM_COUNTING_DOWN(__HANDLE__) (((__HANDLE__)->Instance->CR1 &(TIM_CR1_DIR)) == (TIM_CR1_DIR)) 00081 #endif 00082 00083 /***************************************************************/ 00084
Generated on Wed Jul 20 2022 23:12:48 by
1.7.2
