mirror of
https://github.com/yoboujon/dumber.git
synced 2025-06-08 05:40:49 +02:00
Added battery monitoring task
This commit is contained in:
parent
ae59f19ecc
commit
9a88a66cc1
12 changed files with 238 additions and 12 deletions
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
|
||||
|
||||
|
|
|
@ -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.144:22</developmentServer>
|
||||
<platform>2</platform>
|
||||
</toolsSet>
|
||||
<dbx_gdbdebugger version="1">
|
||||
|
|
|
@ -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 @@
|
|||
#Tue Mar 26 15:23:55 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=c1711461453052
|
||||
/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=c1711463022931
|
||||
/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
|
|
@ -11,6 +11,7 @@
|
|||
<make-dep-projects/>
|
||||
<sourceRootList>
|
||||
<sourceRootElem>lib</sourceRootElem>
|
||||
<sourceRootElem>lib</sourceRootElem>
|
||||
</sourceRootList>
|
||||
<confList>
|
||||
<confElem>
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define PRIORITY_TRECEIVEFROMMON 25
|
||||
#define PRIORITY_TSTARTROBOT 20
|
||||
#define PRIORITY_TCAMERA 21
|
||||
#define PRIORITY_TBATTERY 19
|
||||
|
||||
/*
|
||||
* Some remarks:
|
||||
|
@ -123,6 +124,10 @@ void Tasks::Init() {
|
|||
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);
|
||||
}
|
||||
cout << "Tasks created successfully" << endl << flush;
|
||||
|
||||
/**************************************************************************************/
|
||||
|
@ -167,6 +172,10 @@ void Tasks::Run() {
|
|||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (err = rt_task_start(&th_battery, (void(*)(void*)) & Tasks::BatteryStatusTask, this)) {
|
||||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
cout << "Tasks launched" << endl << flush;
|
||||
}
|
||||
|
@ -264,6 +273,8 @@ void Tasks::ReceiveFromMonTask(void *arg) {
|
|||
exit(-1);
|
||||
} else if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) {
|
||||
rt_sem_v(&sem_openComRobot);
|
||||
} else if (msgRcv->CompareID(MESSAGE_ROBOT_BATTERY_GET)) {
|
||||
printf("Battery handler\n\r");
|
||||
} else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) {
|
||||
rt_sem_v(&sem_startRobot);
|
||||
} else if (msgRcv->CompareID(MESSAGE_ROBOT_GO_FORWARD) ||
|
||||
|
@ -415,3 +426,36 @@ Message *Tasks::ReadInQueue(RT_QUEUE *queue) {
|
|||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* OUR CODE */
|
||||
|
||||
void Tasks::BatteryStatusTask(void * arg) {
|
||||
// Variables
|
||||
int rs(0);
|
||||
|
||||
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 */
|
||||
rt_task_set_periodic(NULL, TM_NOW, 50000000);
|
||||
|
||||
while (1) {
|
||||
rt_task_wait_period(NULL);
|
||||
std::cout << "Periodic battery level update\n\r" << std::flush;
|
||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||
rs = robotStarted;
|
||||
rt_mutex_release(&mutex_robotStarted);
|
||||
if (rs =! 1)
|
||||
continue;
|
||||
|
||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||
Message* msg = robot.Write(new Message(MESSAGE_ROBOT_BATTERY_GET));
|
||||
std::cout << "Message Received: " << msg->ToString() << std::endl;
|
||||
|
||||
rt_mutex_release(&mutex_robot);
|
||||
cout << endl << flush;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,12 +52,12 @@ public:
|
|||
* @brief Stops tasks
|
||||
*/
|
||||
void Stop();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Suspends main thread
|
||||
*/
|
||||
void Join();
|
||||
|
||||
|
||||
private:
|
||||
/**********************************************************************/
|
||||
/* Shared data */
|
||||
|
@ -66,7 +66,8 @@ private:
|
|||
ComRobot robot;
|
||||
int robotStarted = 0;
|
||||
int move = MESSAGE_ROBOT_STOP;
|
||||
|
||||
int robotBattery = 0;
|
||||
|
||||
/**********************************************************************/
|
||||
/* Tasks */
|
||||
/**********************************************************************/
|
||||
|
@ -76,7 +77,8 @@ private:
|
|||
RT_TASK th_openComRobot;
|
||||
RT_TASK th_startRobot;
|
||||
RT_TASK th_move;
|
||||
|
||||
RT_TASK th_battery;
|
||||
|
||||
/**********************************************************************/
|
||||
/* Mutex */
|
||||
/**********************************************************************/
|
||||
|
@ -98,7 +100,7 @@ private:
|
|||
/**********************************************************************/
|
||||
int MSG_QUEUE_SIZE;
|
||||
RT_QUEUE q_messageToMon;
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Tasks' functions */
|
||||
/**********************************************************************/
|
||||
|
@ -106,17 +108,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 +128,18 @@ private:
|
|||
* @brief Thread starting the communication with the robot.
|
||||
*/
|
||||
void StartRobotTask(void *arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Thread handling control of the robot.
|
||||
*/
|
||||
void MoveTask(void *arg);
|
||||
|
||||
|
||||
|
||||
/* OUR CODE */
|
||||
|
||||
void BatteryStatusTask(void * arg);
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* Queue services */
|
||||
/**********************************************************************/
|
||||
|
@ -141,7 +149,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 +157,10 @@ private:
|
|||
*/
|
||||
Message *ReadInQueue(RT_QUEUE *queue);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // __TASKS_H__
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue