IOTON Technology / ton-bot_seguidor_parede

Dependencies:   IOTON-API QEI USBDevice mbed-ton ton-bot

Fork of ton-bot_seguidor_linha by IOTON Technology

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers controlador.h Source File

controlador.h

Go to the documentation of this file.
00001 /**
00002 ******************************************************************************
00003 * @file    controlador.h
00004 * @author  Kleber Lima da Silva (kleber@ioton.cc)
00005 * @version V0.0.1
00006 * @date    05-Julho-2017
00007 * @brief   Biblioteca para controle de velocidade usando os encoders.
00008 ******************************************************************************
00009 * @attention
00010 *
00011 * COPYRIGHT(c) 2017 IOTON Technology
00012 *
00013 * Licensed under the Apache License, Version 2.0 (the "License");
00014 * you may not use this file except in compliance with the License.
00015 * You may obtain a copy of the License at
00016 *
00017 *     http://www.apache.org/licenses/LICENSE-2.0
00018 *
00019 * Unless required by applicable law or agreed to in writing, software
00020 * distributed under the License is distributed on an "AS IS" BASIS,
00021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00022 * See the License for the specific language governing permissions and
00023 * limitations under the License.
00024 ******************************************************************************
00025 */
00026 
00027 #ifndef CONTROLADOR_H_
00028 #define CONTROLADOR_H_
00029 
00030 
00031 /* Includes ------------------------------------------------------------------*/
00032 #include "ton-bot.h"
00033 
00034 /* Constantes ----------------------------------------------------------------*/
00035 /* Parâmetros dos sensores */
00036 #define FRONTAL_TH      0.250f    // Limiar para reconhecer parede frontal ou não
00037 #define LATERAL_TH      0.200f    // Limiar para reconhecer parede lateral ou não
00038 #define CENTRO_LATERAL  0.280f    // Leitura dos sensores laterais no centro da célula
00039 #define CENTRO_FRONTAL  0.660f    // Leitura dos sensores frontais no centro da célula
00040 #define ALINHAMENTO_FRONTAL 0.400f  // Valor para habilitar o alinhamento pelos sensores frontais
00041 
00042 /* Ganho dos controladores de velocidade*/
00043 #define KP  5   // Ganho Proporcional
00044 #define KD  10  // Ganho Derivativo
00045 #define PID_TECNICA 2 // Técnica usada para o PID a partir do erro dos sensores
00046 
00047 /* Indica o tipo de movimento */
00048 #define TRANSLACIONAL 0
00049 #define ROTACIONAL    1
00050 
00051 /* Parâmetros do robô */
00052 #define ENCODER_PPR     360   // Resolução do Encoder pulsos por revolução [ppr]
00053 #define DIAMETRO_RODA   32    // Diâmetro da roda [mm]
00054 #define RODA_RODA       84    // Distância entre as rodas [mm]
00055 #define CNT_POR_1000MM  3581  // = (1000*ENCODER_PPR) / (DIAMETRO_RODA*PI)
00056 #define CNT_POR_360DEG  945   // = ((PI*RODA_RODA)*CNT_PER_1000MM)/(1000)
00057 
00058 /* Parâmetros do controlador */
00059 #define TS          10  // Período de amostragem [ms]
00060 #define K_SENSORES  400 // Constante para ajuste do peso dos sensores no controlador
00061 #define SPEED_RETA  150 // Velocidade nas retas [mm/s]
00062 #define SPEED_CURVA 150 // Velocidade nas curvas [mm/s]
00063 #define CELULA      180 // Tamanho da célula [mm]
00064 
00065 
00066 /* Macros --------------------------------------------------------------------*/
00067 #define COUNTS_TO_MM(cnt)   (((cnt) * 1000) / CNT_POR_1000MM)
00068 #define COUNTS_TO_DEG(cnt)  (((cnt) * 360) / CNT_POR_360DEG)
00069 #define DIST_TO_COUNTS(mm)  (((mm) * CNT_POR_1000MM) / 1000)
00070 #define SPEED_TO_COUNTS(speed)  ((CNT_POR_1000MM * (speed) * TS) / 1000000)
00071 #define RAD_S_TO_COUNTS(rad_s)  (SPEED_TO_COUNTS(rad_s * RODA_RODA))
00072 
00073 
00074 /* Protótipo das Funções -----------------------------------------------------*/
00075 void controleVelocidade(void);
00076 void setMovimento(int32_t raio, int32_t dist_angulo, int32_t speed);
00077 void updateEncoders(void);
00078 void controladorPID(void);
00079 void controleVelocidade(void);
00080 bool isFinalMovimento(void);
00081 void resetControlador(void);
00082 void frente(int32_t distancia);
00083 void curvaPivot(int16_t graus);
00084 void curva(int16_t graus);
00085 int16_t getErroSensores(void);
00086 
00087 
00088 /* Variáveis Externas --------------------------------------------------------*/
00089 extern int32_t distancia_mm;
00090 extern int32_t distancia_deg;
00091 
00092 
00093 #endif /* CONTROLADOR_H_ */
00094 
00095 /************************ (C) COPYRIGHT IOTON Technology **********************/
00096 /***********************************END OF FILE********************************/