mirror of
https://github.com/yoboujon/dumber.git
synced 2025-06-08 22:00:49 +02:00
Compare commits
20 commits
DUMBER-3_v
...
evoxx-dumb
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0121dc5707 | ||
![]() |
d89d36d040 | ||
![]() |
ce68e09679 | ||
![]() |
5b9656c67a | ||
fc2a05ab13 | |||
0792fc301d | |||
9df1899580 | |||
![]() |
8b39e4e099 | ||
866412162b | |||
61b7855f3c | |||
e018b5d0f4 | |||
5904a21007 | |||
![]() |
8f84e6d42e | ||
![]() |
80fa2240f8 | ||
![]() |
c67814a39b | ||
![]() |
b7fae99df4 | ||
![]() |
b75a775775 | ||
8d8dc0586f | |||
![]() |
7d8d4456aa | ||
![]() |
9a88a66cc1 |
33 changed files with 907 additions and 368 deletions
16
.gitignore
vendored
16
.gitignore
vendored
|
@ -54,19 +54,6 @@ GUI
|
|||
*.7z
|
||||
*.rar
|
||||
|
||||
# Images
|
||||
*.jpg
|
||||
*.png
|
||||
*.gif
|
||||
*.bmp
|
||||
*.jpeg
|
||||
*.tiff
|
||||
*.svg
|
||||
|
||||
# Documents
|
||||
*.pdf
|
||||
*.chm
|
||||
|
||||
# Trucs de MDK
|
||||
*.uvgui*
|
||||
*.bak
|
||||
|
@ -83,7 +70,4 @@ GUI
|
|||
/software/dumber3/Tests/
|
||||
/software/dumber3/workspace/
|
||||
|
||||
/hardware/meca/Dumber_2022/Pieces/
|
||||
/hardware/meca/Dumber_2022/OldVersions/
|
||||
|
||||
/doc/Doc\ robot/doxygen/
|
||||
|
|
18
.vscode/c_cpp_properties.json
vendored
Normal file
18
.vscode/c_cpp_properties.json
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "linux-gcc-x64",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "${default}",
|
||||
"cppStandard": "${default}",
|
||||
"intelliSenseMode": "linux-gcc-x64",
|
||||
"compilerArgs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
59
.vscode/settings.json
vendored
Normal file
59
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||
"C_Cpp_Runner.cStandard": "",
|
||||
"C_Cpp_Runner.cppStandard": "",
|
||||
"C_Cpp_Runner.msvcBatchPath": "",
|
||||
"C_Cpp_Runner.useMsvc": false,
|
||||
"C_Cpp_Runner.warnings": [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wpedantic",
|
||||
"-Wshadow",
|
||||
"-Wformat=2",
|
||||
"-Wcast-align",
|
||||
"-Wconversion",
|
||||
"-Wsign-conversion",
|
||||
"-Wnull-dereference"
|
||||
],
|
||||
"C_Cpp_Runner.msvcWarnings": [
|
||||
"/W4",
|
||||
"/permissive-",
|
||||
"/w14242",
|
||||
"/w14287",
|
||||
"/w14296",
|
||||
"/w14311",
|
||||
"/w14826",
|
||||
"/w44062",
|
||||
"/w44242",
|
||||
"/w14905",
|
||||
"/w14906",
|
||||
"/w14263",
|
||||
"/w44265",
|
||||
"/w14928"
|
||||
],
|
||||
"C_Cpp_Runner.enableWarnings": true,
|
||||
"C_Cpp_Runner.warningsAsError": false,
|
||||
"C_Cpp_Runner.compilerArgs": [],
|
||||
"C_Cpp_Runner.linkerArgs": [],
|
||||
"C_Cpp_Runner.includePaths": [],
|
||||
"C_Cpp_Runner.includeSearch": [
|
||||
"*",
|
||||
"**/*"
|
||||
],
|
||||
"C_Cpp_Runner.excludeSearch": [
|
||||
"**/build",
|
||||
"**/build/**",
|
||||
"**/.*",
|
||||
"**/.*/**",
|
||||
"**/.vscode",
|
||||
"**/.vscode/**"
|
||||
],
|
||||
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||
"C_Cpp_Runner.showCompilationTime": false,
|
||||
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
||||
}
|
|
@ -8,3 +8,6 @@ Depot du projet de temps reel 4eme année au departement GEI de l'INSA Toulouse.
|
|||
- doc: contient les sujets de TD et TP
|
||||
- aruco_markers: Script de generation des tags (aruco) utilisés sur les robots
|
||||
|
||||
|
||||
/home/xenomai/.netbeans/remote/10.105.0.144/insa-10577-Linux-x86_64/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/dist/Debug__RPI_/GNU-Linux
|
||||
|
||||
|
|
Binary file not shown.
|
@ -22,7 +22,6 @@
|
|||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1508870668" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.475855176" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.802392362" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.5 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32L071CBTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32L0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32L0xx/Include | ../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM0 || || || USE_HAL_DRIVER | STM32L010x6 || || Drivers | Core/Startup | Middlewares | Core || || || ${workspace_loc:/${ProjName}/STM32L071CBTx_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c.1064254422" name="Runtime library" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c.value.nano_c" valueType="enumerated"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1582271634" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/Dumber3}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.1329460993" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.635805233" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||
|
@ -34,7 +33,7 @@
|
|||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.620486962" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2040942504" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2040942504" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o2" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1441075970" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
|
|
|
@ -35,10 +35,6 @@
|
|||
* Robot is basically controlled by a supervisor program and move depending on commands send by supervisor.
|
||||
* Movements are controlled by a camera.
|
||||
*
|
||||
* @warning Very important information: robot is use a 2.5V power supply so
|
||||
* XBEE MODULES FROM S1 GENERATION DON'T WORK
|
||||
* Use, at least, module from S2 generation
|
||||
*
|
||||
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
|
||||
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
|
||||
*
|
||||
|
@ -70,7 +66,6 @@
|
|||
#include "battery.h"
|
||||
|
||||
#include "panic.h"
|
||||
#include "rtos_support.h"
|
||||
|
||||
/** @addtogroup Application_Software
|
||||
* @{
|
||||
|
@ -128,7 +123,7 @@ StaticTask_t xTaskApplicationMain;
|
|||
/* Buffer that the task being created will use as its stack. Note this is
|
||||
an array of StackType_t variables. The size of StackType_t is dependent on
|
||||
the RTOS port. */
|
||||
StackType_t xStackApplicationMain[ STACK_SIZE*2 ];
|
||||
StackType_t xStackApplicationMain[ STACK_SIZE ];
|
||||
TaskHandle_t xHandleApplicationMain = NULL;
|
||||
|
||||
StaticTimer_t xBufferTimerTimeout;
|
||||
|
@ -149,9 +144,6 @@ APPLICATION_Timeout systemTimeout = {0};
|
|||
* @return None
|
||||
*/
|
||||
void APPLICATION_Init(void) {
|
||||
/* Init du support RTOS (notamment le timer de run time) */
|
||||
//RTOS_SUPPORT_Init(); /* <- used for freertos run time usage */
|
||||
|
||||
/* Init des messages box */
|
||||
MESSAGE_Init();
|
||||
|
||||
|
@ -167,7 +159,7 @@ void APPLICATION_Init(void) {
|
|||
xHandleApplicationMain = xTaskCreateStatic(
|
||||
APPLICATION_Thread, /* Function that implements the task. */
|
||||
"APPLICATION Thread", /* Text name for the task. */
|
||||
STACK_SIZE*2, /* Number of indexes in the xStack array. */
|
||||
STACK_SIZE, /* Number of indexes in the xStack array. */
|
||||
NULL, /* Parameter passed into the task. */
|
||||
PriorityApplicationHandler,/* Priority at which the task is created. */
|
||||
xStackApplicationMain, /* Array to use as the task's stack. */
|
||||
|
@ -224,7 +216,6 @@ void APPLICATION_Thread(void* params) {
|
|||
case CMD_TEST:
|
||||
case CMD_DEBUG:
|
||||
cmdSendAnswer(ANS_OK);
|
||||
break;
|
||||
case CMD_POWER_OFF:
|
||||
systemInfos.powerOffRequired=1;
|
||||
cmdSendAnswer(ANS_OK);
|
||||
|
@ -414,15 +405,10 @@ void APPLICATION_StateMachine(void) {
|
|||
if (((systemInfos.cmd == CMD_MOVE) && (systemInfos.distance !=0)) ||
|
||||
((systemInfos.cmd == CMD_TURN) && (systemInfos.turns !=0))) {
|
||||
systemInfos.endOfMouvement = 0;
|
||||
cmdSendAnswer(ANS_OK);
|
||||
APPLICATION_TransitionToNewState(stateInMouvement);
|
||||
} else {
|
||||
if (((systemInfos.cmd == CMD_MOVE) && (systemInfos.distance ==0)) || // This case (M=0 or T=0) correspond to STOP
|
||||
((systemInfos.cmd == CMD_TURN) && (systemInfos.turns ==0))) {
|
||||
systemInfos.endOfMouvement = 1;
|
||||
}
|
||||
}
|
||||
cmdSendAnswer(ANS_OK);
|
||||
} else if (systemInfos.state == stateInMouvement) { // in this state, MOVE and TURN cmds are accepted only if they come with no parameter (0)
|
||||
} // if TURN and MOVE are sent without parameter, do nothing: we are still in run state
|
||||
} else if (systemInfos.state == stateInMouvement) { // in this state, MOVE and TURN cmds are accepted only if they come with no parameter
|
||||
if (((systemInfos.cmd == CMD_MOVE) && (systemInfos.distance ==0)) ||
|
||||
((systemInfos.cmd == CMD_TURN) && (systemInfos.turns ==0))) {
|
||||
systemInfos.endOfMouvement = 1;
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
#include "xbee.h"
|
||||
#include "commands.h"
|
||||
|
||||
#include "rtos_support.h"
|
||||
|
||||
#include "main.h"
|
||||
|
||||
/** @addtogroup Application_Software
|
||||
|
|
|
@ -44,11 +44,11 @@
|
|||
* Version in plain text and as a numeric value
|
||||
*/
|
||||
///@{
|
||||
#define SYSTEM_VERSION_STR "2.3"
|
||||
#define SYSTEM_VERSION 0x0203 // Upper byte: major version, lower byte: minor version
|
||||
#define SYSTEM_VERSION_STR "2.1"
|
||||
#define SYSTEM_VERSION 0x0201 // Upper byte: major version, lower byte: minor version
|
||||
///@}
|
||||
|
||||
#define STACK_SIZE 64
|
||||
#define STACK_SIZE 0x100
|
||||
|
||||
/** @name Tasks priority constants
|
||||
* Priority is based on configMAX_PRIORITIES which represent highest task priority.
|
||||
|
|
|
@ -62,12 +62,6 @@ void MESSAGE_Init(void) {
|
|||
MOTORS_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
|
||||
APPLICATION_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
|
||||
XBEE_Mailbox = xQueueCreate(QUEUE_SIZE, sizeof(MESSAGE_Typedef));
|
||||
|
||||
/* Add queues to registry in order to view them in stm32cube ide */
|
||||
vQueueAddToRegistry(LEDS_Mailbox,"LEDS Mailbox");
|
||||
vQueueAddToRegistry(MOTORS_Mailbox,"MOTORS Mailbox");
|
||||
vQueueAddToRegistry(APPLICATION_Mailbox,"APPLICATION Mailbox");
|
||||
vQueueAddToRegistry(XBEE_Mailbox,"XBEE Mailbox");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file motors.c
|
||||
* @brief motors driver body
|
||||
* @author S. DI MERCURIO (dimercur@insa-toulouse.fr)
|
||||
* @date December 2023
|
||||
*
|
||||
******************************************************************************
|
||||
* @copyright Copyright 2023 INSA-GEI, Toulouse, France. All rights reserved.
|
||||
* @copyright This project is released under the Lesser GNU Public License (LGPL-3.0-only).
|
||||
*
|
||||
* @copyright This file is part of "Dumber" project
|
||||
*
|
||||
* @copyright This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* @copyright This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
|
||||
* @copyright You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "rtos_support.h"
|
||||
|
||||
#include "stm32l0xx_ll_tim.h"
|
||||
|
||||
/** @addtogroup Application_Software
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTOS_SUPPORT
|
||||
* RTOS support module provide several functions for task run time measurement.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTOS_SUPPORT_Private Private
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint16_t RTOS_SUPPORT_counter16bitUpper=0;
|
||||
|
||||
/**
|
||||
* @brief TIM7 Initialization Function
|
||||
*/
|
||||
void RTOS_SUPPORT_Init(void) {
|
||||
TIM_ClockConfigTypeDef sClockSourceConfig = { 0 };
|
||||
TIM_HandleTypeDef htim7;
|
||||
|
||||
__HAL_RCC_TIM7_CLK_ENABLE();
|
||||
|
||||
htim7.Instance = TIM7;
|
||||
htim7.Init.Prescaler = 0;
|
||||
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim7.Init.Period = 65535;
|
||||
htim7.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||
if (HAL_TIM_ConfigClockSource(&htim7, &sClockSourceConfig) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* TIM7 interrupt Init */
|
||||
LL_TIM_EnableIT_UPDATE(TIM7);
|
||||
HAL_NVIC_SetPriority(TIM7_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(TIM7_IRQn);
|
||||
|
||||
RTOS_SUPPORT_counter16bitUpper=0;
|
||||
LL_TIM_EnableCounter(TIM7);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get 32bit emulated timer based on TIM7
|
||||
*
|
||||
* @return 32bit timer
|
||||
*/
|
||||
uint32_t RTOS_SUPPORT_GetTimer(void) {
|
||||
|
||||
uint16_t currentVal=LL_TIM_GetCounter(TIM7);
|
||||
|
||||
return (uint32_t)((((uint32_t)RTOS_SUPPORT_counter16bitUpper)<<16) + (uint32_t)currentVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles TIM7 update interrupt for 32bit
|
||||
*/
|
||||
void TIM7_IRQHandler(void) {
|
||||
LL_TIM_ClearFlag_UPDATE(TIM7);
|
||||
|
||||
RTOS_SUPPORT_counter16bitUpper++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* rtos_support.h
|
||||
*
|
||||
* Created on: Jan 12, 2024
|
||||
* Author: dimercur
|
||||
*/
|
||||
|
||||
#ifndef RTOS_SUPPORT_H_
|
||||
#define RTOS_SUPPORT_H_
|
||||
|
||||
#include "application.h"
|
||||
|
||||
/** @addtogroup Application_Software
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTOS_SUPPORT
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup RTOS_SUPPORT_Public Public
|
||||
* @{
|
||||
*/
|
||||
|
||||
void RTOS_SUPPORT_Init(void);
|
||||
uint32_t RTOS_SUPPORT_GetTimer(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* RTOS_SUPPORT_H_ */
|
|
@ -40,11 +40,6 @@
|
|||
|
||||
/** @addtogroup XBEE
|
||||
* Xbee driver handles RF communications with supervisor
|
||||
*
|
||||
* @warning Very important information: robot is use a 2.5V power supply so
|
||||
* XBEE MODULES FROM S1 GENERATION DON'T WORK
|
||||
* Use, at least, module from S2 generation
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
@ -103,6 +98,7 @@ StackType_t xStackXbeeRX[ STACK_SIZE ];
|
|||
TaskHandle_t xHandleXbeeRX = NULL;
|
||||
|
||||
uint8_t rxBuffer[XBEE_RX_BUFFER_MAX_LENGTH]={0};
|
||||
//uint8_t rxWaitForACK =0;
|
||||
uint8_t rxPhase;
|
||||
uint16_t rxCmdLength;
|
||||
uint16_t rxDataToReceive;
|
||||
|
@ -114,7 +110,9 @@ uint16_t rxIndex;
|
|||
|
||||
/****** TX part ******/
|
||||
SemaphoreHandle_t xHandleSemaphoreTX = NULL;
|
||||
//SemaphoreHandle_t xHandleSemaphoreTX_ACK = NULL;
|
||||
StaticSemaphore_t xSemaphoreTX;
|
||||
//StaticSemaphore_t xSemaphoreTX_ACK;
|
||||
|
||||
/**
|
||||
* @brief Function for initializing xbee system
|
||||
|
@ -124,14 +122,12 @@ StaticSemaphore_t xSemaphoreTX;
|
|||
*/
|
||||
void XBEE_Init(void) {
|
||||
xHandleSemaphoreTX = xSemaphoreCreateBinaryStatic( &xSemaphoreTX );
|
||||
//xHandleSemaphoreTX_ACK = xSemaphoreCreateBinaryStatic( &xSemaphoreTX_ACK );
|
||||
xSemaphoreGive(xHandleSemaphoreTX);
|
||||
//xSemaphoreTake(xHandleSemaphoreTX_ACK);
|
||||
|
||||
xHandleSemaphoreRX = xSemaphoreCreateBinaryStatic( &xSemaphoreRx );
|
||||
|
||||
/* Add semaphores to registry in order to view them in stm32cube ide */
|
||||
vQueueAddToRegistry(xHandleSemaphoreTX,"XBEE TX sem");
|
||||
vQueueAddToRegistry(xHandleSemaphoreRX,"XBEE RX sem");
|
||||
|
||||
/* Create the task without using any dynamic memory allocation. */
|
||||
xHandleXbeeRX = xTaskCreateStatic(
|
||||
XBEE_RxThread, /* Function that implements the task. */
|
||||
|
@ -208,6 +204,10 @@ int XBEE_SendData(char* data) {
|
|||
if answer is false, it means timeout appends
|
||||
We should probably reset something in "else" branch */
|
||||
|
||||
// while (LL_USART_IsEnabledIT_TXE(hlpuart1.Instance)) {
|
||||
// vTaskDelay(pdMS_TO_TICKS(1));
|
||||
// }
|
||||
|
||||
strncpy((char*)txBuffer,data,XBEE_TX_BUFFER_MAX_LENGTH-1);
|
||||
txBuffer[XBEE_TX_BUFFER_MAX_LENGTH-1]=0;
|
||||
txRemainingData = strlen((char*)txBuffer);
|
||||
|
@ -261,12 +261,6 @@ void XBEE_TX_IRQHandler(void) {
|
|||
*
|
||||
* Wait for incoming message and send them to application mailbox
|
||||
*
|
||||
* @warning Very important information: robot is use a 2.5V power supply so
|
||||
* XBEE MODULES FROM S1 GENERATION DON'T WORK
|
||||
* Use, at least, module from S2 generation
|
||||
* Behavior of using S1 generation is that you receive only two '0' chars than nothing. In
|
||||
* case of this behavior, check module generation
|
||||
*
|
||||
* @param[in] params Initial task parameters
|
||||
* @return None
|
||||
*/
|
||||
|
@ -304,12 +298,6 @@ void XBEE_RxThread(void* params) {
|
|||
* This ISR is called when USART reception register is full, containing a newly received char
|
||||
* A Semaphore is used to signal end of frame reception to \ref XBEE_RxThread function
|
||||
*
|
||||
* @warning Very important information: robot is use a 2.5V power supply so
|
||||
* XBEE MODULES FROM S1 GENERATION DON'T WORK
|
||||
* Use, at least, module from S2 generation
|
||||
* Behavior of using S1 generation is that you receive only two '0' chars than nothing. In
|
||||
* case of this behavior, check module generation
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
|
@ -318,11 +306,6 @@ void XBEE_RX_IRQHandler(void) {
|
|||
uint8_t data;
|
||||
|
||||
data = LL_USART_ReceiveData8(hlpuart1.Instance); // lecture de l'octet reçu
|
||||
/*
|
||||
* In case you only receive '0' chars (than nothing), check you XBEE module generation
|
||||
* XBEE MODULES FROM S1 GENERATION DON'T WORK because robot is 2.5V and modules need more
|
||||
* Use, at least, module from S2 generation
|
||||
*/
|
||||
|
||||
if (data != XBEE_ENDING_CHAR) { // end of command not received
|
||||
rxBuffer[rxIndex] = data;
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
extern void RTOS_SUPPORT_Init(void);
|
||||
extern uint32_t RTOS_SUPPORT_GetTimer(void);
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
|
@ -65,9 +62,9 @@ extern uint32_t RTOS_SUPPORT_GetTimer(void);
|
|||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||
#define configTICK_RATE_HZ ((TickType_t)1000)
|
||||
#define configMAX_PRIORITIES ( 12 )
|
||||
#define configMAX_PRIORITIES ( 56 )
|
||||
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
|
||||
#define configTOTAL_HEAP_SIZE ((size_t)10240)
|
||||
#define configTOTAL_HEAP_SIZE ((size_t)1024)
|
||||
#define configMAX_TASK_NAME_LEN ( 25 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
|
@ -85,13 +82,13 @@ extern uint32_t RTOS_SUPPORT_GetTimer(void);
|
|||
|
||||
/* Co-routine definitions. */
|
||||
#define configUSE_CO_ROUTINES 0
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 1 )
|
||||
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
|
||||
|
||||
/* Software timer definitions. */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY ( 1 )
|
||||
#define configTIMER_TASK_PRIORITY ( 3 )
|
||||
#define configTIMER_QUEUE_LENGTH 10
|
||||
#define configTIMER_TASK_STACK_DEPTH 64
|
||||
#define configTIMER_TASK_STACK_DEPTH 256
|
||||
|
||||
/* The following flag must be enabled only when using newlib */
|
||||
#define configUSE_NEWLIB_REENTRANT 1
|
||||
|
@ -155,8 +152,4 @@ placed into the low power state respectively. */
|
|||
#define configPOST_SLEEP_PROCESSING PostSleepProcessing
|
||||
#endif /* configUSE_TICKLESS_IDLE == 1 */
|
||||
|
||||
#define configGENERATE_RUN_TIME_STATS 1
|
||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() RTOS_SUPPORT_Init()
|
||||
#define portGET_RUN_TIME_COUNTER_VALUE() RTOS_SUPPORT_GetTimer()
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
|
|
|
@ -55,12 +55,12 @@ TIM_HandleTypeDef htim3;
|
|||
TIM_HandleTypeDef htim21;
|
||||
|
||||
/* Definitions for defaultTask */
|
||||
//osThreadId_t defaultTaskHandle;
|
||||
//const osThreadAttr_t defaultTask_attributes = {
|
||||
// .name = "defaultTask",
|
||||
// .stack_size = 128 * 4,
|
||||
// .priority = (osPriority_t) osPriorityNormal,
|
||||
//};
|
||||
osThreadId_t defaultTaskHandle;
|
||||
const osThreadAttr_t defaultTask_attributes = {
|
||||
.name = "defaultTask",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityNormal,
|
||||
};
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
@ -146,7 +146,7 @@ int main(void)
|
|||
|
||||
/* Create the thread(s) */
|
||||
/* creation of defaultTask */
|
||||
//defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
|
||||
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
|
||||
|
||||
/* USER CODE BEGIN RTOS_THREADS */
|
||||
/* add threads, ... */
|
||||
|
@ -644,9 +644,9 @@ TickType_t msToTicks(TickType_t ms) {
|
|||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_StartDefaultTask */
|
||||
//void StartDefaultTask(void *argument)
|
||||
//{
|
||||
// /* USER CODE BEGIN 5 */
|
||||
void StartDefaultTask(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
// LEDS_State state = leds_off;
|
||||
//
|
||||
// /* Infinite loop */
|
||||
|
@ -660,13 +660,8 @@ TickType_t msToTicks(TickType_t ms) {
|
|||
//
|
||||
// vTaskDelay(pdMS_TO_TICKS(5000));
|
||||
// }
|
||||
// /* USER CODE END 5 */
|
||||
//
|
||||
// while (1)
|
||||
// {
|
||||
// //vTaskDelay(pdMS_TO_TICKS(50));
|
||||
// }
|
||||
//}
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Period elapsed callback in non blocking mode
|
||||
|
|
|
@ -35,11 +35,10 @@
|
|||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="3344"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="16000000"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.CTI_ALLOW_HALT" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.CTI_SIGNAL_HALT" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.openocd.DBG_DEVICE_SHAREABLE_ALLOWED" value="false"/>
|
||||
|
@ -71,7 +70,7 @@
|
|||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="enable"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="true"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{"fVersion":1,"fItems":[{"fDisplayName":"Reset","fIsSuppressible":false,"fResetAttribute":"Software system reset","fResetStrategies":[{"fDisplayName":"Software system reset","fLaunchAttribute":"system_reset","fGdbCommands":["monitor reset\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Hardware reset","fLaunchAttribute":"hardware_reset","fGdbCommands":["monitor reset hardware\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Core reset","fLaunchAttribute":"core_reset","fGdbCommands":["monitor reset core\n"],"fCmdOptions":["-g"]},{"fDisplayName":"None","fLaunchAttribute":"no_reset","fGdbCommands":[],"fCmdOptions":["-g"]}],"fGdbCommandGroup":{"name":"Additional commands","commands":[]},"fStartApplication":true}]}"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="freertos"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
|
||||
|
@ -81,9 +80,9 @@
|
|||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.openocd"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
|
||||
|
|
|
@ -41,9 +41,21 @@
|
|||
kind="IMPORTANT_FILES_FOLDER">
|
||||
<itemPath>./Makefile</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="TestFiles"
|
||||
displayName="Test Files"
|
||||
projectFiles="false"
|
||||
kind="TEST_LOGICAL_FOLDER">
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ExternalFiles"
|
||||
displayName="Important Files"
|
||||
projectFiles="false"
|
||||
kind="IMPORTANT_FILES_FOLDER">
|
||||
<itemPath>./Makefile</itemPath>
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<sourceRootList>
|
||||
<Elem>lib</Elem>
|
||||
<Elem>lib</Elem>
|
||||
</sourceRootList>
|
||||
<projectmakefile>./Makefile</projectmakefile>
|
||||
<confs>
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
</conf>
|
||||
<conf name="Debug__RPI_" type="1">
|
||||
<toolsSet>
|
||||
<developmentServer>xenomai@10.105.1.7:22</developmentServer>
|
||||
<developmentServer>xenomai@10.105.0.146:22</developmentServer>
|
||||
<platform>2</platform>
|
||||
</toolsSet>
|
||||
<dbx_gdbdebugger version="1">
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
</data>
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||
<group/>
|
||||
<group>
|
||||
<file>file:/home/boujon/Documents/dumber/software/raspberry/superviseur-robot/tasks.cpp</file>
|
||||
<file>file:/home/boujon/Documents/dumber/software/raspberry/superviseur-robot/tasks.h</file>
|
||||
</group>
|
||||
</open-files>
|
||||
</project-private>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
#Tue Mar 26 14:16:07 CET 2024
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/main.cpp=c1711457904172
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/private/Makefile-variables.mk=c1711457904197
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__PC_.mk=c1711458297850
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/Makefile=c1711457904018
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.h=c1711457904155
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/messages.h=c1711457904169
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk=c1711458297867
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/.gitignore=c1711457904114
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__PC_.bash=c1711457904187
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.h=c1711457904245
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/README.md=c1711457904021
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.xml=c1711458720366
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-impl.mk=c1711457904182
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/superviseur.doxygen=c1711457904238
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/README.md=c1711457904124
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.cpp=c1711457904242
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp=c1711457904151
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.dep.inc=c1711458948692
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.h=c1711457904162
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/camera.h=c1711457904141
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/test.cpp=c1711457904135
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.cpp=c1711457904159
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h=c1711457904130
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/compile-and-run-test=c1711457904132
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/commonitor.h=c1711457904148
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/wrapper.c=c1711457904248
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/camera.cpp=c1711457904138
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/messages.cpp=c1711457904165
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/gdbsudo.sh=c1711457904109
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp=c1711457904127
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/LICENSE=c1711457904121
|
||||
VERSION=1.3
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp=c1711457904144
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-variables.mk=c1711457904185
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__RPI_.bash=c1711457904190
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.gitignore=c1711457904015
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.properties=c1711457904230
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/.gitignore=c1711457904118
|
|
@ -0,0 +1,39 @@
|
|||
#Thu Apr 04 18:04:54 CEST 2024
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/main.cpp=c1712238648769
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__PC_.mk=c1712238648773
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/private/Makefile-variables.mk=c1712238648790
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/Makefile=c1712238648634
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.h=c1712238648755
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/messages.h=c1712238648766
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk=c1712238648775
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/.gitignore=c1712238648721
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__PC_.bash=c1712238648782
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.h=c1712246527533
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/README.md=c1712238648637
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.xml=c1712238648826
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-impl.mk=c1712238648778
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/superviseur.doxygen=c1712238648829
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/README.md=c1712238648730
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.cpp=c1712246689680
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp=c1712238648753
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.dep.inc=c1712238648629
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.h=c1712238648760
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/camera.h=c1712238648744
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/test.cpp=c1712238648739
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.cpp=c1712238648758
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h=c1712238648735
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/compile-and-run-test=c1712238648737
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/commonitor.h=c1712238648750
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/wrapper.c=c1712238648838
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/camera.cpp=c1712238648742
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/messages.cpp=c1712238648763
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/gdbsudo.sh=c1712238648718
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp=c1712238648733
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/LICENSE=c1712238648728
|
||||
VERSION=1.3
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp=c1712238648747
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-variables.mk=c1712238648780
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__RPI_.bash=c1712238648784
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.gitignore=c1712238648632
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.properties=c1712238648823
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/.gitignore=c1712238648726
|
|
@ -0,0 +1,39 @@
|
|||
#Tue Mar 26 16:47:57 CET 2024
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/main.cpp=c1711457904172
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/private/Makefile-variables.mk=c1711457904197
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__PC_.mk=c1711458297850
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/Makefile=c1711457904018
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.h=c1711457904155
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/messages.h=c1711457904169
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk=c1711458297867
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/.gitignore=c1711457904114
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__PC_.bash=c1711457904187
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.h=c1711467801732
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/README.md=c1711457904021
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.xml=c1711458720366
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-impl.mk=c1711457904182
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/superviseur.doxygen=c1711457904238
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/README.md=c1711457904124
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.cpp=c1711468071294
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp=c1711457904151
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.h=c1711457904162
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.dep.inc=c1711458948692
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/camera.h=c1711457904141
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/test.cpp=c1711457904135
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.cpp=c1711457904159
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h=c1711457904130
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/compile-and-run-test=c1711457904132
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/commonitor.h=c1711457904148
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/wrapper.c=c1711457904248
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/camera.cpp=c1711457904138
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/messages.cpp=c1711457904165
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/gdbsudo.sh=c1711457904109
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp=c1711457904127
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/LICENSE=c1711457904121
|
||||
VERSION=1.3
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp=c1711457904144
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-variables.mk=c1711457904185
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__RPI_.bash=c1711457904190
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.gitignore=c1711457904015
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.properties=c1711457904230
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/.gitignore=c1711457904118
|
|
@ -0,0 +1,39 @@
|
|||
#Tue May 07 19:37:34 CEST 2024
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/main.cpp=c1712238648769
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__PC_.mk=c1712238648773
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/private/Makefile-variables.mk=c1712238648790
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/Makefile=c1712238648634
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.h=c1712238648755
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/messages.h=c1712238648766
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk=c1712238648775
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/.gitignore=c1712238648721
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__PC_.bash=c1712238648782
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.h=c1715102079582
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/README.md=c1712238648637
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.xml=c1712238648826
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-impl.mk=c1712238648778
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/superviseur.doxygen=c1712238648829
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/README.md=c1712238648730
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.cpp=c1715103442554
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp=c1712238648753
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.dep.inc=c1712238648629
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.h=c1712238648760
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/camera.h=c1712238648744
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/test.cpp=c1712238648739
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.cpp=c1712238648758
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h=c1712238648735
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/compile-and-run-test=c1712238648737
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/commonitor.h=c1712238648750
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/wrapper.c=c1712238648838
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/camera.cpp=c1712238648742
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/messages.cpp=c1712238648763
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/gdbsudo.sh=c1712238648718
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp=c1712238648733
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/LICENSE=c1712238648728
|
||||
VERSION=1.3
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp=c1712238648747
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-variables.mk=c1712238648780
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__RPI_.bash=c1712238648784
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.gitignore=c1712238648632
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.properties=c1712238648823
|
||||
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/.gitignore=c1712238648726
|
|
@ -1,2 +1,2 @@
|
|||
#Tue Nov 13 11:04:27 CET 2018
|
||||
#Tue May 14 13:44:12 CEST 2024
|
||||
project.license=gpl30
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<make-dep-projects/>
|
||||
<sourceRootList>
|
||||
<sourceRootElem>lib</sourceRootElem>
|
||||
<sourceRootElem>lib</sourceRootElem>
|
||||
</sourceRootList>
|
||||
<confList>
|
||||
<confElem>
|
||||
|
|
|
@ -17,15 +17,26 @@
|
|||
|
||||
#include "tasks.h"
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
||||
// Déclaration des priorités des taches
|
||||
// Task priority: higher has the best priority
|
||||
#define PRIORITY_TSERVER 30
|
||||
#define PRIORITY_TOPENCOMROBOT 20
|
||||
#define PRIORITY_TMOVE 20
|
||||
#define PRIORITY_TSENDTOMON 22
|
||||
#define PRIORITY_TRECEIVEFROMMON 25
|
||||
#define PRIORITY_TSTARTROBOT 20
|
||||
|
||||
// Added Priorities
|
||||
// Camera is the most important as it has the most demanding timing request (10ms)
|
||||
#define PRIORITY_TCAMERA 21
|
||||
// Battery has a timing request of 500ms which is not important
|
||||
#define PRIORITY_TBATTERY 19
|
||||
// These priorities are for "Semaphored" tasks, not periodic.
|
||||
// Their priority is lower.
|
||||
#define PRIORITY_TSETCAMERA 18
|
||||
#define PRIOTITY_TARENA 17
|
||||
#define PRIOTITY_TPOSITION 16
|
||||
|
||||
/*
|
||||
* Some remarks:
|
||||
|
@ -37,7 +48,7 @@
|
|||
* 3- Data flow is probably not optimal
|
||||
*
|
||||
* 4- Take into account that ComRobot::Write will block your task when serial buffer is full,
|
||||
* time for internal buffer to flush
|
||||
* time for interponal buffer to flush
|
||||
*
|
||||
* 5- Same behavior existe for ComMonitor::Write !
|
||||
*
|
||||
|
@ -73,6 +84,28 @@ void Tasks::Init() {
|
|||
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Added Mutexes
|
||||
if (err = rt_mutex_create(&mutex_batteryGet, NULL)) {
|
||||
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_mutex_create(&mutex_cameraStatus, NULL)) {
|
||||
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_mutex_create(&mutex_camera, NULL)) {
|
||||
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_mutex_create(&mutex_arena, NULL)) {
|
||||
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_mutex_create(&mutex_arenaStatus, NULL)) {
|
||||
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
cout << "Mutexes created successfully" << endl << flush;
|
||||
|
||||
/**************************************************************************************/
|
||||
|
@ -94,6 +127,20 @@ void Tasks::Init() {
|
|||
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Added Semaphores
|
||||
if (err = rt_sem_create(&sem_instantBattery, NULL, 0, S_FIFO)) {
|
||||
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_sem_create(&sem_manageCamera, NULL, 0, S_FIFO)) {
|
||||
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_sem_create(&sem_arenaChoice, NULL, 0, S_FIFO)) {
|
||||
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
cout << "Semaphores created successfully" << endl << flush;
|
||||
|
||||
/**************************************************************************************/
|
||||
|
@ -123,6 +170,28 @@ void Tasks::Init() {
|
|||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Added tasks
|
||||
if (err = rt_task_create(&th_batteryPeriodic, "th_batteryPeriodic", 0, PRIORITY_TBATTERY, 0)) {
|
||||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_create(&th_battery, "th_battery", 0, PRIORITY_TBATTERY, 0)) {
|
||||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_create(&th_cameraManage, "th_cameraManage", 0, PRIORITY_TSETCAMERA, 0)) {
|
||||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_create(&th_cameraImage, "th_cameraImage", 0, PRIORITY_TCAMERA, 0)) {
|
||||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_create(&th_arenaChoice, "th_arenaChoice", 0, PRIOTITY_TARENA, 0)) {
|
||||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cout << "Tasks created successfully" << endl << flush;
|
||||
|
||||
/**************************************************************************************/
|
||||
|
@ -167,6 +236,28 @@ void Tasks::Run() {
|
|||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Added Tasks
|
||||
if (err = rt_task_start(&th_batteryPeriodic, (void(*)(void*)) & Tasks::BatteryPeriodicTask, this)) {
|
||||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_start(&th_battery, (void(*)(void*)) & Tasks::BatteryTask, this)) {
|
||||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_start(&th_cameraManage, (void(*)(void*)) & Tasks::ManageCameraTask, this)) {
|
||||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_start(&th_cameraImage, (void(*)(void*)) & Tasks::ImageCameraTask, this)) {
|
||||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_start(&th_arenaChoice, (void(*)(void*)) & Tasks::ArenaChoiceTask, this)) {
|
||||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cout << "Tasks launched" << endl << flush;
|
||||
}
|
||||
|
@ -192,7 +283,7 @@ void Tasks::Join() {
|
|||
*/
|
||||
void Tasks::ServerTask(void *arg) {
|
||||
int status;
|
||||
|
||||
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are started)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
@ -219,7 +310,7 @@ void Tasks::ServerTask(void *arg) {
|
|||
*/
|
||||
void Tasks::SendToMonTask(void* arg) {
|
||||
Message *msg;
|
||||
|
||||
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are starting)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
@ -244,11 +335,11 @@ void Tasks::SendToMonTask(void* arg) {
|
|||
*/
|
||||
void Tasks::ReceiveFromMonTask(void *arg) {
|
||||
Message *msgRcv;
|
||||
|
||||
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are starting)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
|
||||
/**************************************************************************************/
|
||||
/* The task receiveFromMon starts here */
|
||||
/**************************************************************************************/
|
||||
|
@ -276,6 +367,77 @@ void Tasks::ReceiveFromMonTask(void *arg) {
|
|||
move = msgRcv->GetID();
|
||||
rt_mutex_release(&mutex_move);
|
||||
}
|
||||
|
||||
// Added messages
|
||||
// Battery
|
||||
else if (msgRcv->CompareID(MESSAGE_ROBOT_BATTERY_GET)) {
|
||||
rt_mutex_acquire(&mutex_batteryGet, TM_INFINITE);
|
||||
batteryEnabled = true;
|
||||
rt_mutex_release(&mutex_batteryGet);
|
||||
|
||||
// Calling BatteryTask, unblocking the thread.
|
||||
rt_sem_v(&sem_instantBattery);
|
||||
}
|
||||
// Camera
|
||||
else if (msgRcv->CompareID(MESSAGE_CAM_OPEN)) {
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
if(CameraStatusEnum::CLOSED == cameraStatus)
|
||||
cameraStatus = CameraStatusEnum::OPENING;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
|
||||
// Calling manageCamera, unblocking the thread.
|
||||
rt_sem_v(&sem_manageCamera);
|
||||
}
|
||||
else if (msgRcv->CompareID(MESSAGE_CAM_CLOSE)) {
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
if(CameraStatusEnum::OPENED == cameraStatus)
|
||||
cameraStatus = CameraStatusEnum::CLOSING;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
|
||||
// Calling manageCamera, unblocking the thread.
|
||||
rt_sem_v(&sem_manageCamera);
|
||||
}
|
||||
// Arena
|
||||
else if (msgRcv->CompareID(MESSAGE_CAM_ASK_ARENA)) {
|
||||
rt_mutex_acquire(&mutex_arenaStatus, TM_INFINITE);
|
||||
if(ArenaStatusEnum::NONE == arenaStatus)
|
||||
arenaStatus = ArenaStatusEnum::SEARCHING;
|
||||
rt_mutex_release(&mutex_arenaStatus);
|
||||
|
||||
// Calling arenaChoice, unblocking the thread.
|
||||
rt_sem_v(&sem_arenaChoice);
|
||||
}
|
||||
else if (msgRcv->CompareID(MESSAGE_CAM_ARENA_CONFIRM)) {
|
||||
rt_mutex_acquire(&mutex_arenaStatus, TM_INFINITE);
|
||||
if(ArenaStatusEnum::SEARCHED == arenaStatus)
|
||||
arenaStatus = ArenaStatusEnum::CONFIRM;
|
||||
rt_mutex_release(&mutex_arenaStatus);
|
||||
|
||||
// Calling arenaChoice, unblocking the thread.
|
||||
rt_sem_v(&sem_arenaChoice);
|
||||
}
|
||||
else if (msgRcv->CompareID(MESSAGE_CAM_ARENA_INFIRM)) {
|
||||
rt_mutex_acquire(&mutex_arenaStatus, TM_INFINITE);
|
||||
if(ArenaStatusEnum::SEARCHED == arenaStatus)
|
||||
arenaStatus = ArenaStatusEnum::INFIRM;
|
||||
rt_mutex_release(&mutex_arenaStatus);
|
||||
|
||||
// Calling arenaChoice, unblocking the thread.
|
||||
rt_sem_v(&sem_arenaChoice);
|
||||
}
|
||||
else if (msgRcv->CompareID(MESSAGE_CAM_POSITION_COMPUTE_START)){
|
||||
rt_mutex_acquire(&mutex_positionEnabled, TM_INFINITE);
|
||||
positionEnabled = true;
|
||||
rt_mutex_release(&mutex_positionEnabled);
|
||||
}
|
||||
else if (msgRcv->CompareID(MESSAGE_CAM_POSITION_COMPUTE_STOP)){
|
||||
rt_mutex_acquire(&mutex_positionEnabled, TM_INFINITE);
|
||||
positionEnabled = false;
|
||||
rt_mutex_release(&mutex_positionEnabled);
|
||||
}
|
||||
else if (msgRcv->CompareID(MESSAGE_CAM_IMAGE)) {
|
||||
//?
|
||||
}
|
||||
delete(msgRcv); // mus be deleted manually, no consumer
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +452,7 @@ void Tasks::OpenComRobot(void *arg) {
|
|||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are starting)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
|
||||
/**************************************************************************************/
|
||||
/* The task openComRobot starts here */
|
||||
/**************************************************************************************/
|
||||
|
@ -320,7 +482,7 @@ void Tasks::StartRobotTask(void *arg) {
|
|||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are starting)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
|
||||
/**************************************************************************************/
|
||||
/* The task startRobot starts here */
|
||||
/**************************************************************************************/
|
||||
|
@ -336,7 +498,7 @@ void Tasks::StartRobotTask(void *arg) {
|
|||
cout << ")" << endl;
|
||||
|
||||
cout << "Movement answer: " << msgSend->ToString() << endl << flush;
|
||||
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
|
||||
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
|
||||
|
||||
if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
|
||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||
|
@ -352,11 +514,11 @@ void Tasks::StartRobotTask(void *arg) {
|
|||
void Tasks::MoveTask(void *arg) {
|
||||
int rs;
|
||||
int cpMove;
|
||||
|
||||
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are starting)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
|
||||
/**************************************************************************************/
|
||||
/* The task starts here */
|
||||
/**************************************************************************************/
|
||||
|
@ -364,7 +526,7 @@ void Tasks::MoveTask(void *arg) {
|
|||
|
||||
while (1) {
|
||||
rt_task_wait_period(NULL);
|
||||
cout << "Periodic movement update";
|
||||
//cout << "Periodic movement update";
|
||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||
rs = robotStarted;
|
||||
rt_mutex_release(&mutex_robotStarted);
|
||||
|
@ -372,14 +534,14 @@ void Tasks::MoveTask(void *arg) {
|
|||
rt_mutex_acquire(&mutex_move, TM_INFINITE);
|
||||
cpMove = move;
|
||||
rt_mutex_release(&mutex_move);
|
||||
|
||||
|
||||
cout << " move: " << cpMove;
|
||||
|
||||
|
||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||
robot.Write(new Message((MessageID)cpMove));
|
||||
robot.Write(new Message((MessageID) cpMove));
|
||||
rt_mutex_release(&mutex_robot);
|
||||
}
|
||||
cout << endl << flush;
|
||||
//cout << endl << flush;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,3 +577,298 @@ Message *Tasks::ReadInQueue(RT_QUEUE *queue) {
|
|||
return msg;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* Added Tasks */
|
||||
/************************************************************************/
|
||||
|
||||
void Tasks::BatteryPeriodicTask(void * arg) {
|
||||
// Variables
|
||||
int rs(0);
|
||||
bool be(false);
|
||||
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are starting)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
|
||||
// Periodic task set to 500ms
|
||||
rt_task_set_periodic(NULL, TM_NOW, 500000000);
|
||||
|
||||
while (1) {
|
||||
rt_task_wait_period(NULL);
|
||||
this->SendBattery(rs,be);
|
||||
}
|
||||
}
|
||||
|
||||
void Tasks::BatteryTask(void * arg) {
|
||||
// Variables
|
||||
int rs(0);
|
||||
bool be(false);
|
||||
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are starting)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
// Called when semaphore arenChoice incremented
|
||||
rt_sem_p(&sem_instantBattery, TM_INFINITE);
|
||||
this->SendBattery(rs,be);
|
||||
}
|
||||
}
|
||||
|
||||
void Tasks::ManageCameraTask(void * arg)
|
||||
{
|
||||
// Variables
|
||||
int rs(0);
|
||||
CameraStatusEnum cs(CameraStatusEnum::CLOSED);
|
||||
|
||||
// Checking if all tasks started
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
// Called when semaphore manageCamera incremented
|
||||
rt_sem_p(&sem_manageCamera, TM_INFINITE);
|
||||
|
||||
// Check the status of the camera and store it in a local variable
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
cs = cameraStatus;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
|
||||
// Opening the camera
|
||||
if(CameraStatusEnum::OPENING == cs)
|
||||
{
|
||||
const MessageID tempMessage = this->OpenCamera();
|
||||
WriteInQueue(&q_messageToMon, new Message(tempMessage));
|
||||
}
|
||||
// Closing the camera
|
||||
if(CameraStatusEnum::CLOSING == cs)
|
||||
{
|
||||
this->CloseCamera();
|
||||
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_ACK));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tasks::ImageCameraTask(void * arg)
|
||||
{
|
||||
// Variables
|
||||
CameraStatusEnum cs = CameraStatusEnum::CLOSED;
|
||||
Arena a = Arena();
|
||||
std::vector<MessagePosition*> msgPos = {};
|
||||
MessageImg *msgImg = nullptr;
|
||||
bool pe = false;
|
||||
std::list<Position> listPos = {};
|
||||
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Synchronization barrier (waiting that all tasks are starting)
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
// Periodic task set to 10ms
|
||||
rt_task_set_periodic(NULL, TM_NOW, 100000000);
|
||||
|
||||
while(1)
|
||||
{
|
||||
rt_task_wait_period(NULL);
|
||||
|
||||
// Check the status of the camera
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
const CameraStatusEnum cs = cameraStatus;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
|
||||
// Gathering arena
|
||||
rt_mutex_acquire(&mutex_arena, TM_INFINITE);
|
||||
a = arena;
|
||||
rt_mutex_release(&mutex_arena);
|
||||
|
||||
rt_mutex_acquire(&mutex_positionEnabled, TM_INFINITE);
|
||||
pe = positionEnabled;
|
||||
rt_mutex_release(&mutex_positionEnabled);
|
||||
|
||||
// Only gather image if opened
|
||||
if(CameraStatusEnum::OPENED == cs)
|
||||
{
|
||||
// Gathering an image from the camera
|
||||
rt_mutex_acquire(&mutex_camera, TM_INFINITE);
|
||||
Img * img = new Img(cam->Grab());
|
||||
rt_mutex_release(&mutex_camera);
|
||||
|
||||
// If arena has been found, draw overlay
|
||||
if(!a.IsEmpty())
|
||||
img->DrawArena(a);
|
||||
|
||||
// Gathering position
|
||||
if(pe)
|
||||
{
|
||||
// Gather every robot available
|
||||
listPos = img->SearchRobot(a);
|
||||
// For every position, draw the robot and send the message
|
||||
for(auto l : listPos)
|
||||
{
|
||||
img->DrawRobot(l);
|
||||
msgPos.emplace_back(new MessagePosition(MESSAGE_CAM_POSITION, l));
|
||||
}
|
||||
}
|
||||
|
||||
msgImg= new MessageImg(MESSAGE_CAM_IMAGE, img);
|
||||
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
||||
// Writing every message position
|
||||
for(auto mp : msgPos)
|
||||
monitor.Write(mp);
|
||||
// Writing every message image
|
||||
monitor.Write(msgImg);
|
||||
rt_mutex_release(&mutex_monitor);
|
||||
|
||||
// clearing the vector because all its values are unassigned
|
||||
msgPos.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tasks::ArenaChoiceTask(void * arg)
|
||||
{
|
||||
// Variables
|
||||
Img* img = nullptr;
|
||||
Arena a;
|
||||
ArenaStatusEnum as(ArenaStatusEnum::NONE);
|
||||
|
||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
// Called when semaphore arenChoice incremented
|
||||
rt_sem_p(&sem_arenaChoice, TM_INFINITE);
|
||||
|
||||
// Check the status of the arena
|
||||
rt_mutex_acquire(&mutex_arenaStatus, TM_INFINITE);
|
||||
as = arenaStatus;
|
||||
rt_mutex_release(&mutex_arenaStatus);
|
||||
|
||||
// ASK_ARENA
|
||||
if(as == ArenaStatusEnum::SEARCHING)
|
||||
{
|
||||
// Change status for next command
|
||||
rt_mutex_acquire(&mutex_arenaStatus, TM_INFINITE);
|
||||
arenaStatus = ArenaStatusEnum::SEARCHED;
|
||||
rt_mutex_release(&mutex_arenaStatus);
|
||||
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
const CameraStatusEnum cs = cameraStatus;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
|
||||
// Only search if camera is already opened
|
||||
if(CameraStatusEnum::OPENED == cs)
|
||||
{
|
||||
// Prepare to close the camera
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
cameraStatus = CameraStatusEnum::CLOSING;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
|
||||
// Gathering last image
|
||||
rt_mutex_acquire(&mutex_camera, TM_INFINITE);
|
||||
img = new Img(cam->Grab());
|
||||
rt_mutex_release(&mutex_camera);
|
||||
// Closing camera when prompted
|
||||
this->CloseCamera();
|
||||
// Putting the arena overlay if found
|
||||
a = img->SearchArena();
|
||||
}
|
||||
|
||||
if(a.IsEmpty())
|
||||
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_NACK));
|
||||
// If arena is not empty show the arena
|
||||
else {
|
||||
// Adding overlay on the image
|
||||
img->DrawArena(a);
|
||||
// Sending it to the writing queue
|
||||
MessageImg *msgImg = new MessageImg(MESSAGE_CAM_IMAGE, img);
|
||||
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
||||
monitor.Write(msgImg);
|
||||
rt_mutex_release(&mutex_monitor);
|
||||
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_ACK));
|
||||
}
|
||||
}
|
||||
|
||||
// ARENA_CONFIRM / INFIRM
|
||||
if((ArenaStatusEnum::CONFIRM == as) || (ArenaStatusEnum::INFIRM == as))
|
||||
{
|
||||
rt_mutex_acquire(&mutex_arena, TM_INFINITE);
|
||||
arena = a;
|
||||
rt_mutex_release(&mutex_arena);
|
||||
|
||||
// empty the temporary arena
|
||||
a = Arena();
|
||||
// Re-open the camera (showing overlay if arena is stored)
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
cameraStatus = CameraStatusEnum::OPENING;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
this->OpenCamera();
|
||||
|
||||
// Change the status of the arena to default value
|
||||
rt_mutex_acquire(&mutex_arenaStatus, TM_INFINITE);
|
||||
arenaStatus = ArenaStatusEnum::NONE;
|
||||
rt_mutex_release(&mutex_arenaStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* Added functions */
|
||||
/************************************************************************/
|
||||
|
||||
void Tasks::SendBattery(int& rs, bool& be)
|
||||
{
|
||||
// Verify that the robot has started
|
||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||
rs = robotStarted;
|
||||
rt_mutex_release(&mutex_robotStarted);
|
||||
|
||||
// Checking if battery should be gathered
|
||||
rt_mutex_acquire(&mutex_batteryGet, TM_INFINITE);
|
||||
be = batteryEnabled;
|
||||
rt_mutex_release(&mutex_batteryGet);
|
||||
|
||||
if ((rs != 0) && be) {
|
||||
// Acquire the battery level and send it to the message queue
|
||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||
Message* msg = robot.Write(new Message(MESSAGE_ROBOT_BATTERY_GET));
|
||||
rt_mutex_release(&mutex_robot);
|
||||
WriteInQueue(&q_messageToMon, msg);
|
||||
}
|
||||
}
|
||||
|
||||
MessageID Tasks::OpenCamera()
|
||||
{
|
||||
cout << "Called " << __PRETTY_FUNCTION__ << endl << flush;
|
||||
// Opening camera
|
||||
rt_mutex_acquire(&mutex_camera, TM_INFINITE);
|
||||
const bool isOpened = cam->Open();
|
||||
rt_mutex_release(&mutex_camera);
|
||||
|
||||
// Changing status if succeeded
|
||||
if(isOpened)
|
||||
{
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
cameraStatus = CameraStatusEnum::OPENED;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
}
|
||||
return (isOpened ? MESSAGE_ANSWER_ACK : MESSAGE_ANSWER_NACK);
|
||||
}
|
||||
|
||||
void Tasks::CloseCamera()
|
||||
{
|
||||
cout << "\n\nCalled " << __PRETTY_FUNCTION__ << "\n\n" << flush;
|
||||
// Closing Camera
|
||||
rt_mutex_acquire(&mutex_camera, TM_INFINITE);
|
||||
cam->Close();
|
||||
rt_mutex_release(&mutex_camera);
|
||||
|
||||
// Changing Status
|
||||
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
|
||||
cameraStatus = CameraStatusEnum::CLOSED;
|
||||
rt_mutex_release(&mutex_cameraStatus);
|
||||
}
|
|
@ -36,6 +36,33 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @brief The monitor can change the shared data 'cameraStatus' to
|
||||
* either 'OPENING' or 'CLOSING'. ManageCamera() will be awake afterwards.
|
||||
* Then the variable can switch state to open or close the camera.
|
||||
* Default value should be 'CLOSED'.
|
||||
*/
|
||||
enum class CameraStatusEnum {
|
||||
CLOSED,
|
||||
OPENING,
|
||||
OPENED,
|
||||
CLOSING
|
||||
};
|
||||
|
||||
/**
|
||||
* @ref CameraStatusEnum "Same principle"
|
||||
* @brief The arena can change the shared data 'arenaStatus' to
|
||||
* either 'SEARCHING', 'CONFIRM' or 'INFIRM'. The other status will be
|
||||
* changed by the task ArenaChoice().
|
||||
*/
|
||||
enum class ArenaStatusEnum {
|
||||
NONE,
|
||||
SEARCHING,
|
||||
SEARCHED,
|
||||
CONFIRM,
|
||||
INFIRM
|
||||
};
|
||||
|
||||
class Tasks {
|
||||
public:
|
||||
/**
|
||||
|
@ -52,12 +79,12 @@ public:
|
|||
* @brief Stops tasks
|
||||
*/
|
||||
void Stop();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Suspends main thread
|
||||
*/
|
||||
void Join();
|
||||
|
||||
|
||||
private:
|
||||
/**********************************************************************/
|
||||
/* Shared data */
|
||||
|
@ -66,7 +93,24 @@ private:
|
|||
ComRobot robot;
|
||||
int robotStarted = 0;
|
||||
int move = MESSAGE_ROBOT_STOP;
|
||||
|
||||
/************************************************************************/
|
||||
/* Added variables */
|
||||
/************************************************************************/
|
||||
|
||||
// when gathering battery, set to true
|
||||
bool batteryEnabled = false;
|
||||
// current status of the camera
|
||||
CameraStatusEnum cameraStatus = CameraStatusEnum::CLOSED;
|
||||
// camera object
|
||||
Camera* cam = new Camera(sm, 10);
|
||||
// current status of the arena
|
||||
ArenaStatusEnum arenaStatus = ArenaStatusEnum::NONE;
|
||||
// arena object (overlay of the arena on the img)
|
||||
Arena arena;
|
||||
// when gathering position, set to true
|
||||
bool positionEnabled = false;
|
||||
|
||||
/**********************************************************************/
|
||||
/* Tasks */
|
||||
/**********************************************************************/
|
||||
|
@ -77,6 +121,12 @@ private:
|
|||
RT_TASK th_startRobot;
|
||||
RT_TASK th_move;
|
||||
|
||||
RT_TASK th_batteryPeriodic;
|
||||
RT_TASK th_battery;
|
||||
RT_TASK th_cameraManage;
|
||||
RT_TASK th_cameraImage;
|
||||
RT_TASK th_arenaChoice;
|
||||
|
||||
/**********************************************************************/
|
||||
/* Mutex */
|
||||
/**********************************************************************/
|
||||
|
@ -85,6 +135,21 @@ private:
|
|||
RT_MUTEX mutex_robotStarted;
|
||||
RT_MUTEX mutex_move;
|
||||
|
||||
// Added mutexes
|
||||
|
||||
// Locking the variable 'robotBatteryGet'
|
||||
RT_MUTEX mutex_batteryGet;
|
||||
// Locking the variable 'cameraStatus'
|
||||
RT_MUTEX mutex_cameraStatus;
|
||||
// Locking the variable 'cam'
|
||||
RT_MUTEX mutex_camera;
|
||||
// Locking the variable 'arena'
|
||||
RT_MUTEX mutex_arena;
|
||||
// Locking the variable 'arenaStatus'
|
||||
RT_MUTEX mutex_arenaStatus;
|
||||
// Locking the variable 'positionEnabled'
|
||||
RT_MUTEX mutex_positionEnabled;
|
||||
|
||||
/**********************************************************************/
|
||||
/* Semaphores */
|
||||
/**********************************************************************/
|
||||
|
@ -93,12 +158,21 @@ private:
|
|||
RT_SEM sem_serverOk;
|
||||
RT_SEM sem_startRobot;
|
||||
|
||||
// Added semaphores
|
||||
|
||||
// Used when we want to show the battery once.
|
||||
RT_SEM sem_instantBattery;
|
||||
// Used to call ManageCameraTask (non-periodic)
|
||||
RT_SEM sem_manageCamera;
|
||||
// Used to call ArenaChoiceTask (non-periodic)
|
||||
RT_SEM sem_arenaChoice;
|
||||
|
||||
/**********************************************************************/
|
||||
/* Message queues */
|
||||
/**********************************************************************/
|
||||
int MSG_QUEUE_SIZE;
|
||||
RT_QUEUE q_messageToMon;
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Tasks' functions */
|
||||
/**********************************************************************/
|
||||
|
@ -106,17 +180,17 @@ private:
|
|||
* @brief Thread handling server communication with the monitor.
|
||||
*/
|
||||
void ServerTask(void *arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Thread sending data to monitor.
|
||||
*/
|
||||
void SendToMonTask(void *arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Thread receiving data from monitor.
|
||||
*/
|
||||
void ReceiveFromMonTask(void *arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Thread opening communication with the robot.
|
||||
*/
|
||||
|
@ -126,12 +200,67 @@ private:
|
|||
* @brief Thread starting the communication with the robot.
|
||||
*/
|
||||
void StartRobotTask(void *arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Thread handling control of the robot.
|
||||
*/
|
||||
void MoveTask(void *arg);
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* Added Tasks */
|
||||
/************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief [periodic: 500ms]
|
||||
* Task managing the battery. When prompted will get the battery
|
||||
* from the robot and resend it to the monitor.
|
||||
*/
|
||||
void BatteryPeriodicTask(void * arg);
|
||||
void BatteryTask(void * arg);
|
||||
|
||||
/**
|
||||
* @brief Task managing the camera opening and closing. Will check what
|
||||
* state the camera has and change depending on what the monitor asks.
|
||||
*/
|
||||
void ManageCameraTask(void * arg);
|
||||
|
||||
/**
|
||||
* @brief [periodic: 10ms]
|
||||
* Task Managing the image received by the camera. Will send each frame
|
||||
* if camera's state is opened.
|
||||
*/
|
||||
void ImageCameraTask(void * arg);
|
||||
|
||||
/**
|
||||
* @brief Task managing the Arena.
|
||||
* Will search for a camera and overlay if found.
|
||||
* Will store the arena and then show it afterwards.
|
||||
*/
|
||||
void ArenaChoiceTask(void * arg);
|
||||
|
||||
|
||||
void FindPositionTask(void * arg);
|
||||
|
||||
/************************************************************************/
|
||||
/* Added functions */
|
||||
/************************************************************************/
|
||||
|
||||
void SendBattery(int& rs, bool& be);
|
||||
|
||||
/**
|
||||
* @brief Thread safe. Will open the camera and change the status if succeeded.
|
||||
*
|
||||
* @return MessageID returns MESSAGE_ANSWER_ACK if successful, NACK if not.
|
||||
*/
|
||||
MessageID OpenCamera();
|
||||
|
||||
/**
|
||||
* @brief Thread safe. Will close the camera and change the status.
|
||||
*/
|
||||
void CloseCamera();
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Queue services */
|
||||
/**********************************************************************/
|
||||
|
@ -141,7 +270,7 @@ private:
|
|||
* @param msg Message to be stored
|
||||
*/
|
||||
void WriteInQueue(RT_QUEUE *queue, Message *msg);
|
||||
|
||||
|
||||
/**
|
||||
* Read a message from a given queue, block if empty
|
||||
* @param queue Queue identifier
|
||||
|
@ -149,7 +278,10 @@ private:
|
|||
*/
|
||||
Message *ReadInQueue(RT_QUEUE *queue);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __TASKS_H__
|
||||
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="com.st.stm32cube.ide.mcu.debug.launch.launchConfigurationType">
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.access_port_id" value="0"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.cubeprog_external_loaders" value="[]"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_live_expr" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.enable_swv" value="false"/>
|
||||
<intAttribute key="com.st.stm32cube.ide.mcu.debug.launch.formatVersion" value="2"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.ip_address_local" value="localhost"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.enabled" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.limit_swo_clock.value" value=""/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.loadList" value="{"fItems":[{"fIsFromMainTab":true,"fPath":"Debug/robot.elf","fProjectName":"robot","fPerformBuild":true,"fDownload":true,"fLoadSymbols":true}]}"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.override_start_address_mode" value="default"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.remoteCommand" value="target remote"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startServer" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.divby0" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.exception.unaligned" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.startuptab.haltonexception" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swd_mode" value="true"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_port" value="61235"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.swv_trace_hclk" value="16000000"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.launch.vector_table" value=""/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.launch.verify_flash_download" value="true"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_allow_halt" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.cti_signal_halt" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_logging" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_max_halt_delay" value="false"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.enable_shared_stlink" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.frequency" value="0"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.halt_all_on_reset" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.log_file" value="/home/dimercur/Travail/git/dumber/software/robot/Release/st-link_gdbserver_log.txt"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.low_power_debug" value="enable"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.max_halt_delay" value="2"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.reset_strategy" value="connect_under_reset"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_check_serial_number" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{"fVersion":1,"fItems":[{"fDisplayName":"Reset","fIsSuppressible":false,"fResetAttribute":"Software system reset","fResetStrategies":[{"fDisplayName":"Software system reset","fLaunchAttribute":"system_reset","fGdbCommands":["monitor reset\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Hardware reset","fLaunchAttribute":"hardware_reset","fGdbCommands":["monitor reset hardware\n"],"fCmdOptions":["-g"]},{"fDisplayName":"Core reset","fLaunchAttribute":"core_reset","fGdbCommands":["monitor reset core\n"],"fCmdOptions":["-g"]},{"fDisplayName":"None","fLaunchAttribute":"no_reset","fGdbCommands":[],"fCmdOptions":["-g"]}],"fGdbCommandGroup":{"name":"Additional commands","commands":[]},"fStartApplication":true}]}"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
|
||||
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverAuto" value="false"/>
|
||||
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriverPort" value="cortex_m0"/>
|
||||
<intAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyPort" value="60000"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="com.st.stm32cube.ide.mcu.debug.stlink"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="61234"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/robot.elf"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="robot"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.412926795"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/robot"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||
</launchConfiguration>
|
Loading…
Add table
Reference in a new issue