Compare commits

..

58 commits

Author SHA1 Message Date
32f9817f39 add plantUML for th_searchArena 2021-04-06 14:49:42 +02:00
bb60fd8be1 Mettre à jour 'conception/th_sendImageAndPosition.txt' 2021-04-06 14:44:39 +02:00
0017802e4d Ajout envoi position 2021-04-06 14:43:54 +02:00
445627ec03 Mettre à jour 'conception/th_sendImageAndPosition.txt' 2021-04-06 14:35:56 +02:00
721ecb61f5 Merge branch 'cmake' of https://git.etud.insa-toulouse.fr/vergnet/very-dumb into cmake 2021-04-06 14:25:59 +02:00
74a610db33 add manageCamera plantUML 2021-04-06 14:25:44 +02:00
ef535ba57f Ajout th_computePosition.txt 2021-04-06 14:20:55 +02:00
f78ec42f7b separate com and robot management 2021-03-17 10:30:02 +01:00
636f009274 Merge remote-tracking branch 'origin/cmake' into cmake 2021-03-17 09:44:18 +01:00
45ce856660 add back open com robot semaphore 2021-03-17 09:43:56 +01:00
9f2301699b Mettre à jour 'conception/th_manageRobot.txt' 2021-03-15 12:09:11 +01:00
ebe5dc44de Merge remote-tracking branch 'origin/cmake' into cmake 2021-03-15 11:55:02 +01:00
8f4c8ef661 Add manage robot task 2021-03-15 11:54:44 +01:00
e5053429c3 Mettre à jour 'conception/th_receiveFromMon.txt' 2021-03-15 11:41:45 +01:00
cb2975cef5 Mettre à jour 'conception/th_manageRobot.txt' 2021-03-15 11:36:06 +01:00
1fc68cb1b8 Fusion avec manageRobot 2021-03-15 10:56:40 +01:00
3a6ae4db19 Improve receiveFromMon and serverTask 2021-03-15 10:51:03 +01:00
7fcc183012 Mettre à jour 'conception/th_manageRobot.txt' 2021-03-15 10:44:36 +01:00
1b216e0cf5 Mettre à jour 'conception/th_manageRobot.txt' 2021-03-15 10:44:01 +01:00
63257cb656 Implement ReceiveFromMonTask 2021-03-12 15:30:47 +01:00
53f4f7a176 support stopServer message 2021-03-12 15:17:34 +01:00
9f2bbe5bdf Merge remote-tracking branch 'origin/cmake' into cmake 2021-03-12 15:09:55 +01:00
c3555e26ba Add move watchdog 2021-03-12 15:09:42 +01:00
c2c23e912c add missing closeComRobot 2021-03-12 14:55:05 +01:00
a11dc90427 Mettre à jour 'conception/th_move.txt' 2021-03-12 14:51:15 +01:00
c1ce48a19e Add comRobot thread to activity diagrams 2021-03-12 14:47:05 +01:00
7d3372a443 More reformatting 2021-03-12 14:28:29 +01:00
2673651834 Merge remote-tracking branch 'origin/cmake' into cmake 2021-03-12 13:50:58 +01:00
be3d1a588f add activity diagrams 2021-03-12 13:50:16 +01:00
66d4c6f94d Reformat file 2021-03-12 13:35:49 +01:00
c2662209c4 Add missing code in previous commit 2021-03-12 13:30:23 +01:00
7f993019bc Add sendBatteryLevel task 2021-03-12 13:25:52 +01:00
a39a47bb97 Improve CMakeLists to remove 3.13 version requirement 2021-03-03 10:34:30 +01:00
5f1456bb0f Suppression des flush et amélioration des commentaires
endl fait déjà un flush
2021-03-03 08:54:14 +01:00
873eafb77f Conversion en commentaires non doc
Permet de réduire les conflits à la génération de la doc auto
2021-03-03 08:40:57 +01:00
d4e6ba4042 Changement format commentaires 2021-03-03 08:34:12 +01:00
cff9e149b6 Conversion vers syntaxe cpp 2021-03-03 08:29:43 +01:00
d18621f6eb Possibilité de désactiver opencv4 avec cmake 2021-03-03 08:13:05 +01:00
5f99ea9f0e Migration vers OpenCV4 2021-03-02 19:09:24 +01:00
34c4234942 Uncomment raspicam related lines 2021-03-02 18:46:35 +01:00
1bdadaa50f Add preprocessor definition for simulation 2021-03-02 18:39:32 +01:00
188683847a update min cmake version 2021-03-02 18:04:27 +01:00
ee82ecf59c config xenomai shared libraries folder in cmake 2021-03-02 18:02:04 +01:00
dd4f0b418c fix typo in INCLUDE_DIRS 2021-03-02 17:43:01 +01:00
7c3c63e032 Correction du cmake et tentative de build
Toujours impossible de trouver alchemy depuis tasks.h
2021-03-02 11:39:35 +01:00
f9ad5f6562 Merge branch 'cmake' into simulation-cmake 2021-03-02 10:05:49 +01:00
463c7d3fa9 modification du makefile pour utiliser opencv4 2021-03-02 10:00:24 +01:00
b74dff66fc Switch to cmake build system 2021-03-01 17:48:42 +01:00
pehladik
588ba2ecc9 localhost by default, reconnexion ok, panel control ok 2020-04-17 14:54:27 +02:00
pehladik
57158cfaa7 Revert "localhost by default, reconnexion available, the panel control is not activated if the robot is not start"
This reverts commit f98343aca4.
2020-04-17 14:30:48 +02:00
pehladik
f98343aca4 localhost by default, reconnexion available, the panel control is not activated if the robot is not start 2020-04-17 14:25:19 +02:00
pehladik
1d2df7017d add open(string host, int port) 2020-04-06 17:42:28 +02:00
pehladik
de1629c147 add carriage return for robot communication with the simulator 2020-04-05 16:03:16 +02:00
pehladik
1c73c39715 fix close 2020-03-30 17:10:56 +02:00
pehladik
a87b0ffc69 keep supervisor alive if robot is killed 2020-03-30 15:37:42 +02:00
pehladik
89a2bae5c0 update simulator with watchdog, ping, reset, poweroff and relaod commands 2020-03-19 15:27:25 +01:00
pehladik
7f0a9955db simulateur: ajout temps de réponse et erreur, comrobot : ajout msgAnswer adequat a la reponse 2020-03-14 23:41:27 +01:00
pehladik
a7eaa150df add robot simulator 2020-03-14 02:49:03 +01:00
59 changed files with 2536 additions and 690 deletions

4
.gitignore vendored
View file

@ -64,4 +64,6 @@ GUI
/software/raspberry/superviseur-robot/superviseur/dist/
/software/raspberry/testeur/testeur/build/
/software/raspberry/testeur/testeur/dist/
/software/raspberry/testeur/testeur/dist/
/software/simulateur/build/
/software/simulateur/dist/

View file

@ -0,0 +1,12 @@
@startuml
skinparam monochrome true
start
while ()
:startPosition?;
:shouldComputePosition = true;
:stopPosition?;
:shouldComputePosition = true;
endwhile
stop
@enduml

View file

@ -0,0 +1,19 @@
@startuml
skinparam monochrome true
start
while ()
:startCamera?;
:bool success = camera.start();
if (success) then (false)
:msg = new Message(MESSAGE_ANSWER_NACK);
:messageToMonitor!msg;
else (true)
:shouldSendImage = true;
:stopCamera?;
:shouldSendImage = false;
:camera.Stop();
endif;
end while;
stop
@enduml

View file

@ -0,0 +1,32 @@
@startuml
skinparam monochrome true
start
while ()
:openComRobot?;
:err = robot.Open();
if (err) then (robot_ok)
:msgSend = new Message(MESSAGE_ANSWER_ACK);
:messageToMon!msgSend;
:startRobot?;
if (watchdogMode) then (WITH_WATCHDOG)
:msgSend = robot.Write(new Message(MESSAGE_ROBOT_START_WITH_WD));
else (WITHOUT_WATCHDOG)
:msgSend = robot.Write(new Message(MESSAGE_ROBOT_START_WITHOUT_WD));
endif
:messageToMon!msgSend;
if (msgSend->getId()) then (MESSAGE_ANSWER_ACK)
:robotStarted = true;
:stopRobot?;
:robot.Write(new Message(MESSAGE_ROBOT_STOP));
:robot.Close();
:robotStarted = false;
endif
else
:msgSend = new Message(MESSAGE_ANSWER_NACK);
:messageToMon!msgSend;
endif
endwhile
stop
@enduml

24
conception/th_move.txt Normal file
View file

@ -0,0 +1,24 @@
@startuml
skinparam monochrome true
start
:counter = 0;
:start_period(100 ms);
while ()
:wait_next_period();
if (robotStarted) then (true)
:msgSend = robot.Write(new Message(move));
if (msgSend->getId()) then (MESSAGE_ANSWER_ACK)
:counter = 0;
else (MESSAGE_ANSWER_ROBOT_TIMEOUT || \nMESSAGE_ANSWER_ROBOT_UNKNOWN_COMMAND || \nMESSAGE_ANSWER_ROBOT_ERROR)
:counter++;
if (counter) then (3)
:stopRobot!;
:closeComRobot!;
:monitor.write(Message(MESSAGE_ANSWER_COM_ERROR));
else ()
endif
endif
endif
endwhile
stop
@enduml

View file

@ -0,0 +1,57 @@
@startuml
skinparam monochrome true
start
:serverOk?;
while ()
:msgRcv = monitor.Read();
if (msgRcv.CompareID(MESSAGE_MONITOR_LOST)) then (true)
:printf("Connection avec le moniteur perdue");
:stopCamera!;
:stopRobot!;
:stopServer!;
endif
if (msgRcv.CompareID(MESSAGE_ROBOT_COM_OPEN)) then (true)
:openComRobot!;
endif
if (msgRcv.CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) then (true)
:watchdogMode = WITHOUT_WATCHDOG;
:startRobot!;
endif
if (msgRcv.CompareID(MESSAGE_ROBOT_START_WITH_WD)) then (true)
:watchdogMode = WITH_WATCHDOG;
:startRobot!;
endif
if (msgRcv.CompareID(MESSAGE_ROBOT_RESET)) then (true)
:stopRobot!;
endif
if (msgRcv.CompareID(MESSAGE_ROBOT_GO_FORWARD
|| msgRcv.CompareID(MESSAGE_ROBOT_GO_BACKWARD
|| msgRcv.CompareID(MESSAGE_ROBOT_GO_LEFT
|| msgRcv.CompareID(MESSAGE_ROBOT_GO_RIGHT
|| msgRcv.CompareID(MESSAGE_ROBOT_STOP)) then (true)
:move = msg.GetId();
endif
if (msgRcv.CompareID(MESSAGE_CAM_OPEN)) then (true)
:startCamera!;
endif
if (msgRcv.CompareID(MESSAGE_CAM_CLOSE)) then (true)
:stopCamera!;
endif
if (msgRcv.CompareID(MESSAGE_CAM_ASK_ARENA)) then (true)
:searchArena!;
endif
if (msgRcv.CompareID(MESSAGE_CAM_ARENA_CONFIRM)) then (true)
:validateArena!;
endif
if (msgRcv.CompareID(MESSAGE_CAM_ARENA_INFIRM)) then (true)
:cancelArena!;
endif
if (msgRcv.CompareID(MESSAGE_CAM_POSITION_COMPUTE_START)) then (true)
:startPosition!;
endif
if (msgRcv.CompareID(MESSAGE_CAM_POSITION_COMPUTE_STOP)) then (true)
:stopPosition!;
endif
endwhile
stop
@enduml

View file

@ -0,0 +1,25 @@
@startuml
skinparam monochrome true
start
while ()
:searchArena?;
:shouldSendImage = false;
:Img img = camera.Grab();
:arena = img.SearchArena();
if (arena) then (nullptr)
:msg = new Message(MESSAGE_ANSWER_NACK);
:messageToMonitor!msg;
else ()
:img = img.DrawArena(arena);
:msg = new MessageImg(MESSAGE_CAM_IMAGE, img);
:messageToMon!msg;
:validateArena?arenaOk;
if (arenaOk) then (false)
:arena = nullptr;
else (true)
endif;
endif;
:shouldSendImg = true;
end while;
stop
@enduml

View file

@ -0,0 +1,15 @@
@startuml
skinparam monochrome true
start
:start_period(500 ms);
while ()
:wait_next_period();
if(robotStarted)then(true)
:msgSend=robot.Write(robot.getBattery());
:messageToMon!msgSend;
endif
endwhile
stop
@enduml

View file

@ -0,0 +1,24 @@
@startuml
skinparam monochrome true
start
:start_period(100 ms);
while ()
:wait_next_period();
if(shouldSendImage)then(true)
:Img image=camera.Grab();
if (shouldComputePosition)then(true)
:Position position=image.SearchRobot();
:image.DrawRobot(position);
:MessagePosition msgToSend=new MessagePosition(MESSAGE_CAM_POSITION,position);
:messageToMon!msgToSend;
endif
if (arena)then(nullptr)
else
:image.DrawArena(arena);
endif
:MessageImg msgToSend=new MessageImg(MESSAGE_CAM_IMAGE,&image);
:messageToMon!msgToSend;
endif
endwhile
stop
@enduml

View file

@ -0,0 +1,10 @@
@startuml
skinparam monochrome true
start
:serverOK?;
while ()
:messageToMon?msg;
:monitor.Write(msg);
endwhile
stop
@enduml

18
conception/th_server.txt Normal file
View file

@ -0,0 +1,18 @@
@startuml
skinparam monochrome true
start
while ()
:status = monitor.Open();
if (status) then (failed)
:print("Unable to start server");
stop
else (succeed)
:monitor.AcceptClient();
:serverOk!;
:stopServer?;
:monitor.Close();
endif
endwhile
stop
@enduml

View file

@ -35,7 +35,7 @@ namespace monitor
/// <summary>
/// Default server name
/// </summary>
public const string defaultIP = "10.105.1.13";
public const string defaultIP = "localhost";
/// <summary>
/// Default server port number

View file

@ -180,11 +180,16 @@ namespace monitor
isBusy = true;
// Send command to server
if (timeout > 0) // Command request an acknowledge
{
waitForAcknowledge = true; // Flag used in OnMessageReception callback to avoid
// sending acknowledge message to upper level
}
Client.Write(cmd);
if (timeout > 0) // Command request an acknowledge
{
{
waitForAcknowledge = true; // Flag used in OnMessageReception callback to avoid
// sending acknowledge message to upper level
waitTimer.Interval = timeout;

View file

@ -111,7 +111,8 @@ namespace monitor
InvalidAnswer,
Busy,
CommunicationLostWithRobot,
CommunicationLostWithServer
CommunicationLostWithServer,
CommunicationError
}
public struct Point {
@ -259,6 +260,8 @@ namespace monitor
if (answer.ToUpper().Contains(DestijlCommandList.ANSWER_NACK)) status = CommandStatus.Rejected;
// if communication is lost with robot, return CommunicationLostWithRobot
else if (answer.ToUpper().Contains(DestijlCommandList.ANSWER_TIMEOUT)) status = CommandStatus.CommunicationLostWithRobot;
else if (answer.ToUpper().Contains(DestijlCommandList.ANSWER_COM_ERROR)) status = CommandStatus.CommunicationError;
// if answer is empty, communication with robot is lost
else if (answer.Length == 0) status = CommandStatus.CommunicationLostWithServer;
//else status = CommandStatus.InvalidAnswer;

Binary file not shown.

View file

@ -1,10 +1,9 @@
build/
src.sav/
cmake-build-debug/
cmake-build-*/
futur/
CMakeFiles/
*.cmake
CMakeCache.txt
docs/
@ -13,5 +12,3 @@ doc/
workspace/
dist/
not_for_students/

View file

@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.0)
project(superviseur)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Import modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules)
# Compile libraries
# Base64
add_library(base64
lib/base64/base64.cpp
lib/base64/base64.h
)
target_include_directories(base64 PUBLIC lib/base64)
set_property(TARGET base64 PROPERTY CXX_STANDARD 11)
# lib
add_library(lib
lib/camera.cpp
lib/camera.h
lib/commonitor.cpp
lib/commonitor.h
lib/comrobot.cpp
lib/comrobot.h
lib/img.cpp
lib/img.h
lib/messages.cpp
lib/messages.h
)
target_include_directories(lib PUBLIC lib)
target_link_libraries(lib base64)
target_compile_definitions(lib PUBLIC __FOR_PC__ __SIMULATION__ __WITH_ARUCO__ __WITH_OPENCV4__)
set_property(TARGET lib PROPERTY CXX_STANDARD 11)
# Compile main executable
add_executable(main main.cpp tasks.cpp tasks.h)
target_link_libraries(main lib)
set_property(TARGET main PROPERTY CXX_STANDARD 11)
# OpenCV
#set (OpenCV_DIR /path/to/opencv) # Optiona: hint for OpenCV root folder
find_package(OpenCV REQUIRED)
target_link_libraries(lib ${OpenCV_LIBS})
# Raspicam_CV
#find_package(raspicam REQUIRED)
#target_link_libraries(lib ${raspicam_CV_LIBS})
# Xenomai
set(Xenomai_ROOT_DIR /usr/xenomai) # Optional: hint for Xenomai root folder
set(Xenomai_libs ALCHEMY) # List of Xenomai libraries to link
find_package(Xenomai 3.0 REQUIRED ${Xenomai_libs})
if (Xenomai_FOUND)
message(STATUS "Xenomai found with theses skins: ${Xenomai_SKINS}")
else ()
message(FATAL_ERROR "Xenomai not found")
endif ()
foreach (lib IN LISTS Xenomai_libs)
string(SUBSTRING ${Xenomai_${lib}_LIBRARY_DIRS} 2 -1 Xenomai_${lib}_LIBRARY_DIRS) # remove -L prefix
target_include_directories(main PRIVATE ${Xenomai_${lib}_INCLUDE_DIRS})
target_link_directories(main PRIVATE ${Xenomai_${lib}_LIBRARY_DIRS})
target_link_libraries(main ${Xenomai_${lib}_LIBRARIES})
set_target_properties(main PROPERTIES LINK_FLAGS ${Xenomai_${lib}_LDFLAGS})
target_compile_definitions(main PRIVATE ${Xenomai_${lib}_DEFINITIONS})
endforeach ()

View file

@ -0,0 +1,58 @@
############################################################
# Returns the definitions and includes from a cflags output
#
# _list cflags var
# _includes return var with the Includes
# _definitions return var with the Definitions
function(PARSE_CFLAGS _list _includes _definitions)
separate_arguments(${_list})
foreach (_item ${${_list}})
if ("${_item}" MATCHES "^-I")
string(SUBSTRING ${_item} 2 -1 _item_t)
set(_includes_t ${_includes_t} ${_item_t})
else ("${_item}" MATCHES "^-I")
set(_definitions_t ${_definitions_t} ${_item})
endif ("${_item}" MATCHES "^-I")
endforeach (_item)
string(REPLACE ";" " " _definitions_k "${_definitions_t}")
set(${_includes} ${_includes_t} PARENT_SCOPE)
set(${_definitions} ${_definitions_k} PARENT_SCOPE)
#message(STATUS "Calling Macro ${${_list}} and returning ${_includes_k} and ${_definitions_k}")
endfunction(PARSE_CFLAGS)
###############################################################################
###############################################################################
# Retrieve information from a ldflags output
#
# _list ldflags var
# _libraries return var with the libraries
# _ldflags return var with the ldflags value
# _libdir return var with the libdir value
function(PARSE_LDFLAGS _list _libraries _ldflags _libdir)
separate_arguments(${_list})
foreach (_item ${${_list}})
if ("${_item}" MATCHES "^-l")
string(SUBSTRING ${_item} 2 -1 _item_t)
set(_libraries_t ${_libraries_t} ${_item_t})
elseif ("${_item}" MATCHES "^-L")
set(_libdir_t ${_libdir_t} ${_item})
else ("${_item}" MATCHES "^-L")
set(_ldflags_t ${_ldflags_t} ${_item})
endif ("${_item}" MATCHES "^-l")
endforeach (_item ${${_list}})
string(REPLACE ";" " " _ldflags_k "${_ldflags_t}")
string(REPLACE ";" " " _libdir_k "${_libdir_t}")
set(${_libraries} ${_libraries_t} PARENT_SCOPE)
set(${_ldflags} ${_ldflags_k} PARENT_SCOPE)
set(${_libdir} ${_libdir_k} PARENT_SCOPE)
#message(STATUS "Calling Macro ${${_list}} and returning ${_libraries_k} ${_ldflags_k} ${_libdir_k}")
endfunction(PARSE_LDFLAGS)

View file

@ -0,0 +1,28 @@
# Find the kernel release
execute_process(
COMMAND uname -r
OUTPUT_VARIABLE KERNEL_RELEASE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Find the headers
find_path(KERNELHEADERS_DIR
include/linux/user.h
PATHS /usr/src/linux-headers-${KERNEL_RELEASE}
)
message(STATUS "Kernel release: ${KERNEL_RELEASE}")
message(STATUS "Kernel headers: ${KERNELHEADERS_DIR}")
if (KERNELHEADERS_DIR)
set(KERNELHEADERS_INCLUDE_DIRS
${KERNELHEADERS_DIR}/include
${KERNELHEADERS_DIR}/arch/x86/include
CACHE PATH "Kernel headers include dirs"
)
set(KERNELHEADERS_FOUND 1 CACHE STRING "Set to 1 if kernel headers were found")
else (KERNELHEADERS_DIR)
set(KERNELHEADERS_FOUND 0 CACHE STRING "Set to 1 if kernel headers were found")
endif (KERNELHEADERS_DIR)
mark_as_advanced(KERNELHEADERS_FOUND)

View file

@ -0,0 +1,253 @@
###############################################################################
#
# CMake script for finding the Xenomai Libraries and skins
#
# Copyright 2015-2018 Leopold Palomo-Avellaneda <leopold.palomo@upc.edu>
# Copyright 2016-2018 Institute of Industrial and Control Engineering (IOC)
# Universitat Politecnica de Catalunya
# BarcelonaTech
# Redistribution and use is allowed according to the terms of the 3-clause BSD
# license.
#
#
# Input variables:
#
# Cache variables (not intended to be used in CMakeLists.txt files)
# Input variables:
#
# - ${Xenomai_ROOT_DIR} (optional): Used as a hint to find the Xenomai root dir
# - $ENV{XENOMAI_ROOT_DIR} (optional): Used as a hint to find the Xenomai root dir
#
# Output Variables:
#
# - Xenomai_FOUND: Boolean that indicates if the package was found. Default is Native
# - Xenomai_SKINS: List of the available skins.
# The availabe skins are for 2.6: NATIVE POSIX PSOS RTDM UITRON VRTX VXWORKS
# The availabe skins are for 3.x: POSIX ALCHEMY RTDM PSOS VXWORKS SMOKEY COBALT NATIVE
# NATIVE for compatibility purpose
# - Xenomai_*_FOUND variables below for individual skins.
# - Xenomai_VERSION: major.minor.patch Xenomai version string
# - Xenomai_XENO_CONFIG: Path to xeno-config program
#
# For each available skin, theses Var are set:
# - Xenomai_${SKIN}_FOUND: Boolean that indicates if the skin was found
# - Xenomai_${SKIN}_DEFINITIONS
# - Xenomai_${SKIN}_INCLUDE_DIRS
# - Xenomai_${SKIN}_LIBRARY_DIRS
# - Xenomai_${SKIN}_LIBRARIES
# - Xenomai_${SKIN}_LDFLAGS
# - Xenomai_${SKIN}_DL_FLAGS # Direct Linker Flags
# From Xenomai 3.0.2. If you want to build a shared library
# - Xenomai_${SKIN}_LDFLAGS_LIBRARIES
# - Xenomai_${SKIN}_DL_FLAGS_LIBRARIES
#
# Specific var for compatibility with Johns Hopkins University (JHU) FindXenomai
#
# - Individual library variables:
# - Xenomai_LIBRARY_XENOMAI
# - Xenomai_LIBRARY_NATIVE
# - Xenomai_LIBRARY_PTHREAD_RT
# - Xenomai_LIBRARY_RTDM
# - Xenomai_LIBRARY_RTDK ( this will be empty, deprecated after Xenomai 2.6.0)
#
#
#
# Example usage:
#
# find_package(Xenomai 2.6.4 REQUIRED POSIX)
# message(STATUS "Xenomai found with theses skins: ${Xenomai_SKINS}")
# # You have some sources xeno-example ${XENO_EXAMPLE_SRC}
#
# include_directories(${Xenomai_POSIX_INCLUDE_DIR})
# add_executable(demo_xeno ${XENO_EXAMPLE_SRC})
# target_link_libraries(demo_xeno ${Xenomai_POSIX_LIBRARY_DIRS} ${Xenomai_POSIX_LIBRARIES})
# set_target_properties(demo_xeno PROPERTIES
# LINK_FLAGS ${Xenomai_POSIX_LDFLAGS})
# target_compile_definitions(demo_xeno PUBLIC ${Xenomai_POSIX_DEFINITIONS})
###############################################################################
# Returns the definitions and includes from a cflags output
#
# _list cflags var
# _includes return var with the Includes
# _definitions return var with the Definitions
function(PARSE_CFLAGS _list _includes _definitions)
separate_arguments(${_list})
foreach (_item ${${_list}})
if ("${_item}" MATCHES "^-I")
string(SUBSTRING ${_item} 2 -1 _item_t)
set(_includes_t ${_includes_t} ${_item_t})
else ("${_item}" MATCHES "^-I")
set(_definitions_t ${_definitions_t} ${_item})
endif ("${_item}" MATCHES "^-I")
endforeach (_item)
string(REPLACE ";" " " _definitions_k "${_definitions_t}")
set(${_includes} ${_includes_t} PARENT_SCOPE)
set(${_definitions} ${_definitions_k} PARENT_SCOPE)
#message(STATUS "Calling Macro ${${_list}} and returning ${_includes_k} and ${_definitions_k}")
endfunction(PARSE_CFLAGS)
###############################################################################
###############################################################################
# Retrieve information from a ldflags output
#
# _list ldflags var
# _libraries return var with the libraries
# _ldflags return var with the ldflags value
# _libdir return var with the libdir value
# _dlflags return var with the direct output
function(PARSE_LDFLAGS _list _libraries _ldflags _libdir _dlflags)
separate_arguments(${_list})
foreach (_item ${${_list}})
if ("${_item}" MATCHES "^-l")
string(SUBSTRING ${_item} 2 -1 _item_t)
set(_libraries_t ${_libraries_t} ${_item_t})
elseif ("${_item}" MATCHES "^-L")
set(_libdir_t ${_libdir_t} ${_item})
else ("${_item}" MATCHES "^-L")
set(_ldflags_t ${_ldflags_t} ${_item})
endif ("${_item}" MATCHES "^-l")
endforeach (_item ${${_list}})
string(REPLACE ";" " " _ldflags_k "${_ldflags_t}")
string(REPLACE ";" " " _libdir_k "${_libdir_t}")
string(REPLACE ";" " " _dlflags_t "${${_list}}")
set(${_libraries} ${_libraries_t} PARENT_SCOPE)
set(${_ldflags} ${_ldflags_k} PARENT_SCOPE)
set(${_libdir} ${_libdir_k} PARENT_SCOPE)
set(${_dlflags} ${_dlflags_t} PARENT_SCOPE)
#message(STATUS "Calling Macro ${${_list}} and returning ${_libraries_k} ${_ldflags_k} ${_libdir_k}")
endfunction(PARSE_LDFLAGS)
###############################################################################
include(FindPackageHandleStandardArgs)
if (Xenomai_FIND_COMPONENTS)
# if components specified in find_package(), make sure each of those pieces were found
set(_XENOMAI_FOUND_REQUIRED_VARS)
foreach (component ${Xenomai_FIND_COMPONENTS})
string(TOUPPER ${component} _COMPONENT)
set(_XENOMAI_FOUND_REQUIRED_VARS ${_XENOMAI_FOUND_REQUIRED_VARS} Xenomai_${_COMPONENT}_INCLUDE_DIRS Xenomai_${_COMPONENT}_LIBRARIES)
endforeach ()
else ()
# if no components specified, we'll make a default set of required variables to say Qt is found
set(_XENOMAI_FOUND_REQUIRED_VARS Xenomai_XENO_CONFIG Xenomai_VERSION Xenomai_NATIVE_INCLUDE_DIRS Xenomai_NATIVE_LIBRARIES)
endif ()
# Get hint from environment variable (if any)
if (NOT $ENV{XENOMAI_ROOT_DIR} STREQUAL "")
set(XENOMAI_ROOT_DIR $ENV{XENOMAI_ROOT_DIR} CACHE PATH "Xenomai base directory location (optional, used for nonstandard installation paths)" FORCE)
mark_as_advanced(XENOMAI_ROOT_DIR)
endif ()
if (DEFINED ENV{SDKTARGETSYSROOT} AND NOT DEFINED Xenomai_ROOT_DIR)
message("Found $SDKTARGETSYSROOT = $ENV{SDKTARGETSYSROOT}, using as Xenomai_ROOT_DIR and settings DESTDIR")
set(Xenomai_ROOT_DIR "$ENV{SDKTARGETSYSROOT}")
SET(ENV{DESTDIR} $ENV{SDKTARGETSYSROOT})
endif ()
# set the search paths
set(Xenomai_SEARCH_PATH ${Xenomai_ROOT_DIR})
# searching kernel headers
# Find kernel headers
find_package(KernelHeaders)
find_path(Xenomai_KERNEL_INCLUDE_DIR version.h
PATHS ${KERNELHEADERS_DIR}/include/xenomai/)
if (Xenomai_KERNEL_INCLUDE_DIR)
message(STATUS "Xenomai Kernel Headers located in ${Xenomai_KERNEL_INCLUDE_DIR}")
endif ()
# Find xeno-config
# Always finds /usr/bin/xeno-config for some reason
# find_program(Xenomai_XENO_CONFIG NAMES xeno-config PATHS ${Xenomai_SEARCH_PATH}/bin NO_DEFAULT_PATH)
set(Xenomai_XENO_CONFIG ${Xenomai_SEARCH_PATH}/bin/xeno-config)
if (Xenomai_XENO_CONFIG)
set(Xenomai_FOUND ${Xenomai_XENO_CONFIG})
execute_process(COMMAND ${Xenomai_XENO_CONFIG} --version OUTPUT_VARIABLE Xenomai_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "xeno-config is found at ${Xenomai_XENO_CONFIG}. Xenomai should be ok and version found is ${Xenomai_VERSION}")
if (${Xenomai_VERSION} VERSION_GREATER "3.0.2")
message(STATUS "xeno-config has the --auto-init-solib option")
endif ()
if (${Xenomai_VERSION} VERSION_LESS "3.0.0")
set(SKINS native posix psos rtdm uitron vrtx vxworks)
else (${Xenomai_VERSION} VERSION_LESS "3.0.0")
set(SKINS posix vxworks psos alchemy rtdm smokey cobalt native)
# From xeno-config manual
# --native and --skin=native are accepted for backward compatibility purpose. They are stricly equivalent to passing --alchemy --compat.
# Likewise, passing --rtdm or --skin=rtdm is stricly equivalent to passing --posix, enabling POSIX I/O routines to be wrapped to their
# respective Xenomai implementation.
endif ()
foreach (_skin ${SKINS})
#message(STATUS "Processing skin ${_skin} ........")
string(TOUPPER ${_skin} SKINU)
execute_process(COMMAND ${Xenomai_XENO_CONFIG} --skin "${_skin}" --cflags OUTPUT_VARIABLE XENO_${SKINU}_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
PARSE_CFLAGS("XENO_${SKINU}_CFLAGS" "Xenomai_${SKINU}_INCLUDE_DIRS" "Xenomai_${SKINU}_DEFINITIONS")
#message(STATUS "Xenomai_${SKINU}_INCLUDE_DIRS = ${Xenomai_${SKINU}_INCLUDE_DIRS}")
#message(STATUS "Xenomai_${SKINU}_DEFINITIONS = ${Xenomai_${SKINU}_DEFINITIONS}")
execute_process(COMMAND ${Xenomai_XENO_CONFIG} --skin ${_skin} --ldflags OUTPUT_VARIABLE XENO_${SKINU}_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
PARSE_LDFLAGS("XENO_${SKINU}_LDFLAGS" "Xenomai_${SKINU}_LIBRARIES" "Xenomai_${SKINU}_LDFLAGS" "Xenomai_${SKINU}_LIBRARY_DIRS" "Xenomai_${SKINU}_DL_FLAGS")
#message(STATUS "Xenomai_${SKINU}_LIBRARIES = ${Xenomai_${SKINU}_LIBRARIES}")
#message(STATUS "Xenomai_${SKINU}_DIRS = ${Xenomai_${SKINU}_LIBRARY_DIRS}")
#message(STATUS "Xenomai_${SKINU}_LDFLAGS = ${Xenomai_${SKINU}_LDFLAGS}")
if (${Xenomai_VERSION} VERSION_GREATER "3.0.2")
#message(STATUS "xeno-config has the --auto-init-solib option")
execute_process(COMMAND ${Xenomai_XENO_CONFIG} --skin ${_skin} --auto-init-solib --ldflags OUTPUT_VARIABLE XENO_${SKINU}_LDFLAGS_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
PARSE_LDFLAGS("XENO_${SKINU}_LDFLAGS_LIBRARIES" "Xenomai_${SKINU}_LIBRARIES" "Xenomai_${SKINU}_LDFLAGS_LIBRARIES" "Xenomai_${SKINU}_LIBRARY_DIRS" "Xenomai_${SKINU}_DL_FLAGS_LIBRARIES")
endif ()
if (Xenomai_${SKINU}_LIBRARIES AND Xenomai_${SKINU}_INCLUDE_DIRS)
set(Xenomai_${SKINU}_FOUND TRUE)
set(Xenomai_SKINS ${Xenomai_SKINS} ${_skin})
#message(STATUS "Xenomai ${_skin} skin found")
set(Xenomai_${SKINU}_FOUND ${Xenomai_${SKINU}_FOUND} CACHE STRING "Xenomai ${SKINU} Found" FORCE)
set(Xenomai_${SKINU}_DEFINITIONS ${Xenomai_${SKINU}_DEFINITIONS} CACHE STRING "Xenomai ${SKINU} skin definitions" FORCE)
set(Xenomai_${SKINU}_INCLUDE_DIRS ${Xenomai_${SKINU}_INCLUDE_DIRS} CACHE STRING "Xenomai ${SKINU} include directories" FORCE)
set(Xenomai_${SKINU}_LIBRARY_DIRS ${Xenomai_${SKINU}_LIBRARY_DIRS} CACHE STRING "Xenomai ${SKINU} library directories" FORCE)
set(Xenomai_${SKINU}_LIBRARIES ${Xenomai_${SKINU}_LIBRARIES} CACHE STRING "Xenomai ${SKINU} libraries" FORCE)
set(Xenomai_${SKINU}_LDFLAGS ${Xenomai_${SKINU}_LDFLAGS} CACHE STRING "Xenomai ${SKINU} ldflags" FORCE)
set(Xenomai_${SKINU}_DL_FLAGS ${Xenomai_${SKINU}_DL_FLAGS} CACHE STRING "Xenomai ${SKINU} Direct linker flags" FORCE)
if (${Xenomai_VERSION} VERSION_GREATER "3.0.2")
set(Xenomai_${SKINU}_LDFLAGS_LIBRARIES ${Xenomai_${SKINU}_LDFLAGS_LIBRARIES} CACHE STRING "Xenomai ${SKINU} ldflags for libraries" FORCE)
set(Xenomai_${SKINU}_DL_FLAGS_LIBRARIES ${Xenomai_${SKINU}_DL_FLAGS_LIBRARIES} CACHE STRING "Xenomai ${SKINU} Direct linker flags for libraries" FORCE)
endif ()
endif ()
endforeach (_skin ${SKINS})
set(Xenomai_KERNEL_INCLUDE_DIR ${Xenomai_KERNEL_INCLUDE_DIR} CACHE STRING "Xenomai Kernel Headers directory " FORCE)
find_library(Xenomai_LIBRARY_NATIVE native ${Xenomai_ROOT_DIR}/lib)
find_library(Xenomai_LIBRARY_XENOMAI xenomai ${Xenomai_ROOT_DIR}/lib)
find_library(Xenomai_LIBRARY_PTHREAD_RT pthread_rt ${Xenomai_ROOT_DIR}/lib)
find_library(Xenomai_LIBRARY_RTDM rtdm ${Xenomai_ROOT_DIR}/lib)
# In 2.6.0 RTDK was merged into the main xenomai library
if (Xenomai_VERSION VERSION_GREATER 2.6.0)
set(Xenomai_LIBRARY_RTDK_FOUND ${Xenomai_LIBRARY_XENOMAI_FOUND})
set(Xenomai_LIBRARY_RTDK ${Xenomai_LIBRARY_XENOMAI})
else ()
find_library(Xenomai_LIBRARY_RTDK rtdk ${Xenomai_ROOT_DIR}/lib)
endif ()
find_package_handle_standard_args(Xenomai REQUIRED_VARS ${_XENOMAI_FOUND_REQUIRED_VARS}
VERSION_VAR Xenomai_VERSION
HANDLE_COMPONENTS)
else (Xenomai_XENO_CONFIG)
message(FATAL_ERROR "This program needs xeno-config")
endif ()

View file

@ -34,12 +34,12 @@ Camera::Camera():Camera(sm, 10){
* @param fps speed of sampling
*/
Camera::Camera(int size, int fps) {
this->SetSize(size);
this->SetSize(size);
#ifndef __FOR_PC__
this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
this->cap.set(CV_CAP_PROP_FRAME_WIDTH, width);
this->cap.set(CV_CAP_PROP_FRAME_HEIGHT, height);
this->cap.set(CV_CAP_PROP_FPS, fps);
this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
this->cap.set(CV_CAP_PROP_FRAME_WIDTH, width);
this->cap.set(CV_CAP_PROP_FRAME_HEIGHT, height);
this->cap.set(CV_CAP_PROP_FPS, fps);
#endif /* __FOR_PC__ */
}
@ -48,34 +48,39 @@ Camera::Camera(int size, int fps) {
* @return True if camera is open, false otherwise
*/
bool Camera::Open() {
bool status = false;
bool status = false;
#ifdef __FOR_PC__
if (this->cap.open(0)) {
//this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
this->cap.set(CV_CAP_PROP_FRAME_WIDTH, width);
this->cap.set(CV_CAP_PROP_FRAME_HEIGHT, height);
status = true;
}
if (this->cap.open(0)) {
#ifdef __WITH_OPENCV4__
//this->cap.set(CAP_PROP_FORMAT, CV_8UC3);
this->cap.set(CAP_PROP_FRAME_WIDTH, width);
this->cap.set(CAP_PROP_FRAME_HEIGHT, height);
#else
//this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
this->cap.set(CV_CAP_PROP_FRAME_WIDTH, width);
this->cap.set(CV_CAP_PROP_FRAME_HEIGHT, height);
#endif /* __WITH_OPENCV4__ */
status = true;
}
#else
if (this->cap.open()) {
cout << "Camera warmup 2sec" << endl << flush;
sleep(2);
cout << "Start capture" << endl << flush;
if (this->cap.open()) {
cout << "Camera warmup 2sec" << endl << flush;
sleep(2);
cout << "Start capture" << endl << flush;
status = true;
}
status = true;
}
#endif /* __FOR_PC__ */
return status;
return status;
}
/**
* Close and release camera
*/
void Camera::Close() {
this->cap.release();
this->cap.release();
}
/**
@ -113,23 +118,23 @@ void Camera::SetSize(int size) {
* @return Image taken from camera
*/
Img Camera::Grab() {
ImageMat frame;
ImageMat frame;
#ifdef __FOR_PC__
cap >> frame;
Img capture = Img(frame);
cap >> frame;
Img capture = Img(frame);
#else
cap.grab();
cap.retrieve(frame);
cap.grab();
cap.retrieve(frame);
#ifdef __INVERSE_COLOR__
cvtColor(frame, frame, CV_BGR2RGB);
cvtColor(frame, frame, CV_BGR2RGB);
#endif // __INVERSE_COLOR__
Img capture = Img(frame);
Img capture = Img(frame);
#endif /* __FOR_PC__ */
return capture;
return capture;
}
/**
@ -137,7 +142,7 @@ Img Camera::Grab() {
* @return true if camera is open, false otherwise
*/
bool Camera::IsOpen() {
return cap.isOpened();
return cap.isOpened();
}
/**

View file

@ -80,38 +80,38 @@ public:
* @return true if camera is open, false otherwise
*/
bool IsOpen();
/**
* Define size for sampled picture
* @param size Size of picture (@see captureSize)
*/
void SetSize(int size);
/**
* Grab next image from camera
* @return Image taken from camera
*/
Img Grab();
/**
* Define size for sampled picture
* @param size Size of picture (@see captureSize)
*/
void SetSize(int size);
/**
* Grab next image from camera
* @return Image taken from camera
*/
Img Grab();
private:
#ifdef __FOR_PC__
/**
* Camera descriptor
*/
cv::VideoCapture cap;
/**
* Camera descriptor
*/
cv::VideoCapture cap;
#else
raspicam::RaspiCam_Cv cap;
#endif /* __FOR_PC__ */
/**
* Size for image (default= small)
*/
int size = sm;
/**
* Width of image
*/
int width;
raspicam::RaspiCam_Cv cap;
#endif /* __FOR_PC__ */
/**
* Size for image (default= small)
*/
int size = sm;
/**
* Width of image
*/
int width;
/**
* Height of image

View file

@ -100,7 +100,10 @@ int ComMonitor::Open(int port) {
throw std::runtime_error{"Can not bind socket"};
}
listen(socketFD, 1);
if (listen(socketFD, 1) < 0) {
cerr<<"["<<__PRETTY_FUNCTION__<<"] Can not listen on port "<<to_string(port)<<endl<<flush;
throw std::runtime_error{"Can not listen on this port"};
}
return socketFD;
}

View file

@ -23,7 +23,7 @@
using namespace std;
#define SERVER_PORT 5544
constexpr int SERVER_PORT = 5544;
/**
* Class used for generating a server and communicating through it with monitor

View file

@ -26,6 +26,15 @@
#include <string>
#include <stdexcept>
#ifdef __SIMULATION__
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int sock = 0;
string host = "127.0.0.1";
#define PORT 6699
#endif
#ifdef __FOR_PC__
#define USART_FILENAME "/dev/ttyUSB0"
#else
@ -71,6 +80,33 @@ int ComRobot::Open() {
int ComRobot::Open(string usart) {
struct termios options;
#ifdef __SIMULATION__
struct sockaddr_in serv_addr;
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
printf("\n Socket creation error \n");
return -1;
}
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 200000;
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*) &tv, sizeof tv);
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(PORT);
// Convert IPv4 and IPv6 addresses from text to binary form
if (inet_pton(AF_INET, host.c_str(), &serv_addr.sin_addr) <= 0) {
printf("\nInvalid address/ Address not supported \n");
return -1;
}
if (connect(sock, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0) {
return -1;
}
return 1;
#else
fd = open(usart.c_str(), O_RDWR | O_NOCTTY /*| O_NDELAY*/); //Open in blocking read/write mode
if (fd == -1) {
cerr << "[" << __PRETTY_FUNCTION__ << "] Unable to open UART (" << usart << "). Ensure it is not in use by another application" << endl << flush;
@ -88,6 +124,37 @@ int ComRobot::Open(string usart) {
}
return fd;
#endif
}
int ComRobot::Open(string shost, int nport) {
#ifdef __SIMULATION__
struct sockaddr_in serv_addr;
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
printf("\n Socket creation error \n");
return -1;
}
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 200000;
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*) &tv, sizeof tv);
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(nport);
if (inet_pton(AF_INET, shost.c_str(), &serv_addr.sin_addr) <= 0) {
cout << "Invalid address/ Address not supported" << endl;
return -1;
}
if (connect(sock, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0) {
return -2;
}
return 1;
#else
return -1;
#endif
}
/**
@ -95,7 +162,11 @@ int ComRobot::Open(string usart) {
* @return Success if above 0, failure if below 0
*/
int ComRobot::Close() {
#ifdef __SIMULATION__
return close(sock);
#else
return close(fd);
#endif
}
/**
@ -115,6 +186,28 @@ Message *ComRobot::Write(Message* msg) {
Write_Pre();
s = MessageToString(msg);
#ifdef __SIMULATION__
s += "\r";
char buffer[1024] = {0};
cout << "[" << __PRETTY_FUNCTION__ << "] Send command: " << s << endl << flush;
send(sock, s.c_str(), s.length(), MSG_NOSIGNAL);
int valread = read(sock, buffer, 1024);
if (valread == 0) {
cout << "The communication is out of order" << endl;
msgAnswer = new Message(MESSAGE_ANSWER_COM_ERROR);
} else if (valread < 0) {
cout << "Timeout" << endl;
msgAnswer = new Message(MESSAGE_ANSWER_ROBOT_TIMEOUT);
} else {
string s(&buffer[0], valread);
msgAnswer = StringToMessage(s);
cout << "Response: " << buffer << ", id: " << msgAnswer->GetID() << endl;
}
#else
AddChecksum(s);
//cout << "[" <<__PRETTY_FUNCTION__<<"] Send command: "<<s<<endl<<flush;
@ -143,6 +236,7 @@ Message *ComRobot::Write(Message* msg) {
}
}
}
#endif
} else {
cerr << __PRETTY_FUNCTION__ << ": Com port not open" << endl << flush;
throw std::runtime_error{"Com port not open"};

View file

@ -59,6 +59,14 @@ public:
*/
int Open(string usart);
/**
* Open tcp client for the graphical simulator
* @param host Host address
* @param port Port number
* @return 1 if ok or -1
*/
int Open(string shost, int nport);
/**
* Close serial link
* @return Success if above 0, failure if below 0
@ -89,9 +97,9 @@ public:
*/
virtual void Write_Post() {
}
Message *SendCommand(Message* msg, MessageID answerID, int maxRetries);
static Message *Ping() {
return new Message(MESSAGE_ROBOT_PING);
}

View file

@ -234,23 +234,29 @@ std::list<Position> Img::SearchRobot(Arena arena) {
* @return Arena object with coordinate of outline, empty if no arena found
*/
Arena Img::SearchArena() {
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Point> approx;
std::vector<cv::Vec4i> hierarchy;
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Point> approx;
std::vector<cv::Vec4i> hierarchy;
ImageMat imageTrt;
cv::cvtColor(this->img, imageTrt, CV_RGB2GRAY); // conversion en niveau de gris
cv::threshold(imageTrt, imageTrt, 128, 255, CV_THRESH_BINARY); // Threshold les éléments les plus clair
cv::Canny(imageTrt, imageTrt, 100, 200, 3); // detection d'angle
findContours(imageTrt, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
for (unsigned int i = 0; i < contours.size(); i++) {
approxPolyDP(ImageMat(contours[i]), approx, cv::arcLength(ImageMat(contours[i]), true)*0.1, true);
if (approx.size() == 4 && fabs(cv::contourArea(contours[i])) > 100000) {
Arena rectangle;
rectangle.arena = cv::boundingRect(ImageMat(contours[i]));
return rectangle;
}
ImageMat imageTrt;
#ifdef __WITH_OPENCV4__
cv::cvtColor(this->img, imageTrt, cv::COLOR_RGB2GRAY); // conversion en niveau de gris
cv::threshold(imageTrt, imageTrt, 128, 255, cv::THRESH_BINARY); // Threshold les éléments les plus clair
cv::Canny(imageTrt, imageTrt, 100, 200, 3); // detection d'angle
findContours(imageTrt, contours, hierarchy, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
#else
cv::cvtColor(this->img, imageTrt, CV_RGB2GRAY); // conversion en niveau de gris
cv::threshold(imageTrt, imageTrt, 128, 255, CV_THRESH_BINARY); // Threshold les éléments les plus clair
cv::Canny(imageTrt, imageTrt, 100, 200, 3); // detection d'angle
findContours(imageTrt, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
#endif
for (unsigned int i = 0; i < contours.size(); i++) {
approxPolyDP(ImageMat(contours[i]), approx, cv::arcLength(ImageMat(contours[i]), true) * 0.1, true);
if (approx.size() == 4 && fabs(cv::contourArea(contours[i])) > 100000) {
Arena rectangle;
rectangle.arena = cv::boundingRect(ImageMat(contours[i]));
return rectangle;
}
}
return Arena();

View file

@ -59,7 +59,8 @@ FFLAGS=
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=`pkg-config --libs opencv`
LDLIBSOPTIONS=`pkg-config --libs opencv4`
LDFLAGSOPTIONS=`pkg-config --cflags opencv4`
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
@ -67,47 +68,47 @@ LDLIBSOPTIONS=`pkg-config --libs opencv`
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/superviseur-robot: ${OBJECTFILES}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/superviseur-robot ${OBJECTFILES} ${LDLIBSOPTIONS} -Wl,--no-as-needed -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lmercury -lpthread -lrt
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/superviseur-robot ${OBJECTFILES} ${LDLIBSOPTIONS} -Wl,--no-as-needed -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lmercury -lpthread -lrt -Wl,--rpath /usr/xenomai/lib
${OBJECTDIR}/lib/base64/base64.o: lib/base64/base64.cpp
${MKDIR} -p ${OBJECTDIR}/lib/base64
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/base64/base64.o lib/base64/base64.cpp
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__SIMULATION__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury ${LDFLAGSOPTIONS} -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/base64/base64.o lib/base64/base64.cpp
${OBJECTDIR}/lib/camera.o: lib/camera.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/camera.o lib/camera.cpp
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__SIMULATION__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury ${LDFLAGSOPTIONS} -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/camera.o lib/camera.cpp
${OBJECTDIR}/lib/commonitor.o: lib/commonitor.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/commonitor.o lib/commonitor.cpp
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__SIMULATION__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury ${LDFLAGSOPTIONS} -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/commonitor.o lib/commonitor.cpp
${OBJECTDIR}/lib/comrobot.o: lib/comrobot.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/comrobot.o lib/comrobot.cpp
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__SIMULATION__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury ${LDFLAGSOPTIONS} -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/comrobot.o lib/comrobot.cpp
${OBJECTDIR}/lib/img.o: lib/img.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/img.o lib/img.cpp
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__SIMULATION__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury ${LDFLAGSOPTIONS} -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/img.o lib/img.cpp
${OBJECTDIR}/lib/messages.o: lib/messages.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/messages.o lib/messages.cpp
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__SIMULATION__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury ${LDFLAGSOPTIONS} -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/messages.o lib/messages.cpp
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__SIMULATION__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury ${LDFLAGSOPTIONS} -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
${OBJECTDIR}/tasks.o: tasks.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/tasks.o tasks.cpp
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__SIMULATION__ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury ${LDFLAGSOPTIONS} -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/tasks.o tasks.cpp
# Subprojects
.build-subprojects:

View file

@ -1,125 +0,0 @@
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux
CND_DLIB_EXT=so
CND_CONF=Debug__RPI_
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include ./Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
${OBJECTDIR}/lib/base64/base64.o \
${OBJECTDIR}/lib/camera.o \
${OBJECTDIR}/lib/commonitor.o \
${OBJECTDIR}/lib/comrobot.o \
${OBJECTDIR}/lib/img.o \
${OBJECTDIR}/lib/messages.o \
${OBJECTDIR}/main.o \
${OBJECTDIR}/tasks.o
# C Compiler Flags
CFLAGS=-I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy
# CC Compiler Flags
CCFLAGS=-I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -Wno-pmf-conversions -std=gnu++11
CXXFLAGS=-I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -Wno-pmf-conversions -std=gnu++11
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=`pkg-config --libs opencv` -lraspicam_cv -lraspicam
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/superviseur-robot
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/superviseur-robot: ${OBJECTFILES}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/superviseur-robot ${OBJECTFILES} ${LDLIBSOPTIONS} -Wl,--no-as-needed -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lmercury -lpthread -lrt
${OBJECTDIR}/lib/base64/base64.o: lib/base64/base64.cpp
${MKDIR} -p ${OBJECTDIR}/lib/base64
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/base64/base64.o lib/base64/base64.cpp
${OBJECTDIR}/lib/camera.o: lib/camera.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/camera.o lib/camera.cpp
${OBJECTDIR}/lib/commonitor.o: lib/commonitor.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/commonitor.o lib/commonitor.cpp
${OBJECTDIR}/lib/comrobot.o: lib/comrobot.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/comrobot.o lib/comrobot.cpp
${OBJECTDIR}/lib/img.o: lib/img.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/img.o lib/img.cpp
${OBJECTDIR}/lib/messages.o: lib/messages.cpp
${MKDIR} -p ${OBJECTDIR}/lib
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/lib/messages.o lib/messages.cpp
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
${OBJECTDIR}/tasks.o: tasks.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__WITH_ARUCO__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/tasks.o tasks.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r ${CND_BUILDDIR}/${CND_CONF}
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc

View file

@ -31,7 +31,7 @@ DEFAULTCONF=Debug__PC_
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=Debug__PC_ Debug__RPI_
ALLCONFS=Debug__PC_
# build

View file

@ -14,14 +14,6 @@ CND_ARTIFACT_PATH_Debug__PC_=dist/Debug__PC_/GNU-Linux/superviseur-robot
CND_PACKAGE_DIR_Debug__PC_=dist/Debug__PC_/GNU-Linux/package
CND_PACKAGE_NAME_Debug__PC_=superviseur-robot.tar
CND_PACKAGE_PATH_Debug__PC_=dist/Debug__PC_/GNU-Linux/package/superviseur-robot.tar
# Debug__RPI_ configuration
CND_PLATFORM_Debug__RPI_=GNU-Linux
CND_ARTIFACT_DIR_Debug__RPI_=dist/Debug__RPI_/GNU-Linux
CND_ARTIFACT_NAME_Debug__RPI_=superviseur-robot
CND_ARTIFACT_PATH_Debug__RPI_=dist/Debug__RPI_/GNU-Linux/superviseur-robot
CND_PACKAGE_DIR_Debug__RPI_=dist/Debug__RPI_/GNU-Linux/package
CND_PACKAGE_NAME_Debug__RPI_=superviseur-robot.tar
CND_PACKAGE_PATH_Debug__RPI_=dist/Debug__RPI_/GNU-Linux/package/superviseur-robot.tar
#
# include compiler specific variables
#

View file

@ -71,6 +71,7 @@
<preprocessorList>
<Elem>_WITH_TRACE_</Elem>
<Elem>__FOR_PC__</Elem>
<Elem>__SIMULATION__</Elem>
<Elem>__WITH_ARUCO__</Elem>
</preprocessorList>
</ccTool>
@ -78,78 +79,7 @@
<linkerLibItems>
<linkerOptionItem>`pkg-config --libs opencv`</linkerOptionItem>
</linkerLibItems>
<commandLine>-Wl,--no-as-needed -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lmercury -lpthread -lrt</commandLine>
</linkerTool>
</compileType>
<item path="./gdbsudo.sh" ex="false" tool="3" flavor2="0">
</item>
<item path="./lib/base64/base64.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="./lib/base64/base64.h" ex="false" tool="3" flavor2="0">
</item>
<item path="./lib/camera.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="./lib/camera.h" ex="false" tool="3" flavor2="0">
</item>
<item path="./lib/commonitor.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="./lib/commonitor.h" ex="false" tool="3" flavor2="0">
</item>
<item path="./lib/comrobot.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="./lib/comrobot.h" ex="false" tool="3" flavor2="0">
</item>
<item path="./lib/img.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="./lib/img.h" ex="false" tool="3" flavor2="0">
</item>
<item path="./lib/messages.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="./lib/messages.h" ex="false" tool="3" flavor2="0">
</item>
<item path="./main.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="./tasks.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="./tasks.h" ex="false" tool="3" flavor2="0">
</item>
</conf>
<conf name="Debug__RPI_" type="1">
<toolsSet>
<compilerSet>GNU|GNU</compilerSet>
<dependencyChecking>true</dependencyChecking>
<rebuildPropChanged>false</rebuildPropChanged>
</toolsSet>
<compileType>
<cTool>
<incDir>
<pElem>./</pElem>
<pElem>./lib</pElem>
<pElem>/usr/xenomai/include</pElem>
<pElem>/usr/xenomai/include/mercury</pElem>
</incDir>
<commandLine>-I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy</commandLine>
</cTool>
<ccTool>
<incDir>
<pElem>./</pElem>
<pElem>./lib</pElem>
<pElem>/usr/xenomai/include</pElem>
<pElem>/usr/xenomai/include/mercury</pElem>
</incDir>
<commandLine>-I/usr/xenomai/include/mercury -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D__MERCURY__ -I/usr/xenomai/include/alchemy -Wno-pmf-conversions -std=gnu++11</commandLine>
<preprocessorList>
<Elem>_WITH_TRACE_</Elem>
<Elem>__WITH_ARUCO__</Elem>
</preprocessorList>
</ccTool>
<linkerTool>
<linkerLibItems>
<linkerOptionItem>`pkg-config --libs opencv`</linkerOptionItem>
<linkerLibLibItem>raspicam_cv</linkerLibLibItem>
<linkerLibLibItem>raspicam</linkerLibLibItem>
</linkerLibItems>
<commandLine>-Wl,--no-as-needed -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lmercury -lpthread -lrt</commandLine>
<commandLine>-Wl,--no-as-needed -lalchemy -lcopperplate /usr/xenomai/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=/usr/xenomai/lib/dynlist.ld -L/usr/xenomai/lib -lmercury -lpthread -lrt -Wl,--rpath /usr/xenomai/lib</commandLine>
</linkerTool>
</compileType>
<item path="./gdbsudo.sh" ex="false" tool="3" flavor2="0">

View file

@ -4,4 +4,3 @@
# NOCDDL
#
# Debug__PC_ configuration
# Debug__RPI_ configuration

View file

@ -39,38 +39,5 @@
</environment>
</runprofile>
</conf>
<conf name="Debug__RPI_" type="1">
<toolsSet>
<developmentServer>pi@10.105.1.08:22</developmentServer>
<platform>2</platform>
</toolsSet>
<dbx_gdbdebugger version="1">
<gdb_pathmaps>
</gdb_pathmaps>
<gdb_interceptlist>
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
</gdb_interceptlist>
<gdb_options>
<DebugOptions>
</DebugOptions>
</gdb_options>
<gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/>
</dbx_gdbdebugger>
<nativedebugger version="1">
<engine>gdb</engine>
</nativedebugger>
<runprofile version="9">
<runcommandpicklist>
<runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem>
</runcommandpicklist>
<runcommand>"${OUTPUT_PATH}"</runcommand>
<rundir></rundir>
<buildfirst>true</buildfirst>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
</confs>
</configurationDescriptor>

View file

@ -2,17 +2,16 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<data xmlns="http://www.netbeans.org/ns/make-project-private/1">
<activeConfTypeElem>1</activeConfTypeElem>
<activeConfIndexElem>1</activeConfIndexElem>
<activeConfIndexElem>0</activeConfIndexElem>
</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>
<file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/camera.h</file>
<file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/messages.cpp</file>
<file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/tasks.h</file>
<file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/camera.cpp</file>
<file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/tasks.cpp</file>
<file>file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/messages.h</file>
<file>file:/home/etud/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp</file>
<file>file:/home/etud/dumber/software/raspberry/superviseur-robot/lib/messages.cpp</file>
<file>file:/home/etud/dumber/software/raspberry/superviseur-robot/tasks.cpp</file>
<file>file:/home/etud/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp</file>
<file>file:/home/etud/dumber/software/raspberry/superviseur-robot/lib/commonitor.h</file>
</group>
</open-files>
</project-private>

View file

@ -17,10 +17,6 @@
<name>Debug__PC_</name>
<type>1</type>
</confElem>
<confElem>
<name>Debug__RPI_</name>
<type>1</type>
</confElem>
</confList>
<formatting>
<project-formatting-style>false</project-formatting-style>

View file

@ -18,14 +18,16 @@
#include "tasks.h"
#include <stdexcept>
using namespace std;
// Déclaration des priorités des taches
#define PRIORITY_TSERVER 30
#define PRIORITY_TOPENCOMROBOT 20
#define PRIORITY_TMOVE 20
#define PRIORITY_TSENDTOMON 22
#define PRIORITY_TRECEIVEFROMMON 25
#define PRIORITY_TSTARTROBOT 20
#define PRIORITY_TCAMERA 21
constexpr int PRIORITY_TSERVER = 30;
constexpr int PRIORITY_TMOVE = 20;
constexpr int PRIORITY_TSENDTOMON = 22;
constexpr int PRIORITY_TRECEIVEFROMMON = 25;
constexpr int PRIORITY_TSTARTROBOT = 20;
constexpr int PRIORITY_TCAMERA = 21;
constexpr int PRIORITY_TBATTERY = 23;
/*
* Some remarks:
@ -41,7 +43,7 @@
*
* 5- Same behavior existe for ComMonitor::Write !
*
* 6- When you want to write something in terminal, use cout and terminate with endl and flush
* 6- When you want to write something in terminal, use cout and terminate with endl
*
* 7- Good luck !
*/
@ -51,88 +53,115 @@
* semaphore, etc.)
*/
void Tasks::Init() {
int status;
int err;
int status;
int err;
/**************************************************************************************/
/* Mutex creation */
/**************************************************************************************/
if (err = rt_mutex_create(&mutex_monitor, NULL)) {
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_mutex_create(&mutex_robot, NULL)) {
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_mutex_create(&mutex_robotStarted, NULL)) {
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_mutex_create(&mutex_move, NULL)) {
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
cout << "Mutexes created successfully" << endl << flush;
/**************************************************************************************/
/* Semaphors creation */
/**************************************************************************************/
if (err = rt_sem_create(&sem_barrier, NULL, 0, S_FIFO)) {
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_sem_create(&sem_openComRobot, NULL, 0, S_FIFO)) {
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_sem_create(&sem_serverOk, NULL, 0, S_FIFO)) {
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_sem_create(&sem_startRobot, NULL, 0, S_FIFO)) {
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
cout << "Semaphores created successfully" << endl << flush;
/* **************************************************************************************
* Mutex creation
* *************************************************************************************/
if ((err = rt_mutex_create(&mutex_monitor, nullptr))) {
cerr << "Error mutex create mutex_monitor: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_mutex_create(&mutex_monitorConnected, nullptr))) {
cerr << "Error mutex create mutex_monitorConnected: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_mutex_create(&mutex_robot, nullptr))) {
cerr << "Error mutex create mutex_robot: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_mutex_create(&mutex_robotStarted, nullptr))) {
cerr << "Error mutex create mutex_robotStarted: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_mutex_create(&mutex_move, nullptr))) {
cerr << "Error mutex create mutex_move: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_mutex_create(&mutex_watchdogMode, nullptr))) {
cerr << "Error mutex create mutex_watchdogMode: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
cout << "Mutexes created successfully" << endl;
/**************************************************************************************/
/* Tasks creation */
/**************************************************************************************/
if (err = rt_task_create(&th_server, "th_server", 0, PRIORITY_TSERVER, 0)) {
cerr << "Error task create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_create(&th_sendToMon, "th_sendToMon", 0, PRIORITY_TSENDTOMON, 0)) {
cerr << "Error task create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_create(&th_receiveFromMon, "th_receiveFromMon", 0, PRIORITY_TRECEIVEFROMMON, 0)) {
cerr << "Error task create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_create(&th_openComRobot, "th_openComRobot", 0, PRIORITY_TOPENCOMROBOT, 0)) {
cerr << "Error task create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_create(&th_startRobot, "th_startRobot", 0, PRIORITY_TSTARTROBOT, 0)) {
cerr << "Error task create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_create(&th_move, "th_move", 0, PRIORITY_TMOVE, 0)) {
cerr << "Error task create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
cout << "Tasks created successfully" << endl << flush;
/* **************************************************************************************
* Semaphores creation
* *************************************************************************************/
if ((err = rt_sem_create(&sem_barrier, nullptr, 0, S_FIFO))) {
cerr << "Error semaphore create sem_barrier: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_sem_create(&sem_serverOk, nullptr, 0, S_FIFO))) {
cerr << "Error semaphore create sem_serverOk: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_sem_create(&sem_openComRobot, nullptr, 0, S_FIFO))) {
cerr << "Error semaphore create sem_openComRobot: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_sem_create(&sem_closeComRobot, nullptr, 0, S_FIFO))) {
cerr << "Error semaphore create sem_closeComRobot: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_sem_create(&sem_startRobot, nullptr, 0, S_FIFO))) {
cerr << "Error semaphore create sem_startRobot: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_sem_create(&sem_stopRobot, nullptr, 0, S_PULSE))) {
cerr << "Error semaphore create sem_stopRobot: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_sem_create(&sem_stopServer, nullptr, 0, S_FIFO))) {
cerr << "Error semaphore create sem_stopServer: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
cout << "Semaphores created successfully" << endl;
/**************************************************************************************/
/* Message queues creation */
/**************************************************************************************/
if ((err = rt_queue_create(&q_messageToMon, "q_messageToMon", sizeof (Message*)*50, Q_UNLIMITED, Q_FIFO)) < 0) {
cerr << "Error msg queue create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
cout << "Queues created successfully" << endl << flush;
/* *************************************************************************************
* Tasks creation
* *************************************************************************************/
if ((err = rt_task_create(&th_server, "th_server", 0, PRIORITY_TSERVER, 0))) {
cerr << "Error task create th_server: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_task_create(&th_sendToMon, "th_sendToMon", 0, PRIORITY_TSENDTOMON, 0))) {
cerr << "Error task create th_sendToMon: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_task_create(&th_receiveFromMon, "th_receiveFromMon", 0, PRIORITY_TRECEIVEFROMMON, 0))) {
cerr << "Error task create th_receiveFromMon: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_task_create(&th_move, "th_move", 0, PRIORITY_TMOVE, 0))) {
cerr << "Error task create th_move: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_task_create(&th_sendBatteryLevel, "th_sendBatteryLevel", 0, PRIORITY_TBATTERY, 0))) {
cerr << "Error task create th_sendBatteryLevel: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_task_create(&th_manageRobotCom, "th_manageRobotCom", 0, PRIORITY_TSTARTROBOT, 0))) {
cerr << "Error task create th_manageRobotCom: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if ((err = rt_task_create(&th_manageRobot, "th_manageRobot", 0, PRIORITY_TSTARTROBOT, 0))) {
cerr << "Error task create th_manageRobot: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
cout << "Tasks created successfully" << endl;
/* *************************************************************************************
* Message queues creation
* *************************************************************************************/
if ((err = rt_queue_create(&q_messageToMon, "q_messageToMon", sizeof(Message *) * 50, Q_UNLIMITED, Q_FIFO)) < 0) {
cerr << "Error msg queue create q_messageToMon: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
cout << "Queues created successfully" << endl;
}
@ -140,247 +169,368 @@ void Tasks::Init() {
* @brief Démarrage des tâches
*/
void Tasks::Run() {
rt_task_set_priority(NULL, T_LOPRIO);
int err;
rt_task_set_priority(nullptr, T_LOPRIO);
int err;
if (err = rt_task_start(&th_server, (void(*)(void*)) & Tasks::ServerTask, this)) {
cerr << "Error task start: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_sendToMon, (void(*)(void*)) & Tasks::SendToMonTask, this)) {
cerr << "Error task start: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_receiveFromMon, (void(*)(void*)) & Tasks::ReceiveFromMonTask, this)) {
cerr << "Error task start: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_openComRobot, (void(*)(void*)) & Tasks::OpenComRobot, this)) {
cerr << "Error task start: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_startRobot, (void(*)(void*)) & Tasks::StartRobotTask, this)) {
cerr << "Error task start: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_move, (void(*)(void*)) & Tasks::MoveTask, this)) {
cerr << "Error task start: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_server, reinterpret_cast<void (*)(void *)>(&Tasks::ServerTask), this)) {
cerr << "Error task start ServerTask: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_sendToMon, reinterpret_cast<void (*)(void *)>(&Tasks::SendToMonTask), this)) {
cerr << "Error task start SendToMonTask: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_receiveFromMon, reinterpret_cast<void (*)(void *)>(&Tasks::ReceiveFromMonTask), this)) {
cerr << "Error task start ReceiveFromMonTask: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_manageRobotCom, reinterpret_cast<void (*)(void *)>(&Tasks::ManageRobotComTask), this)) {
cerr << "Error task start ManageRobotComTask: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_manageRobot, reinterpret_cast<void (*)(void *)>(&Tasks::ManageRobotTask), this)) {
cerr << "Error task start ManageRobotTask: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_move, reinterpret_cast<void (*)(void *)>(&Tasks::MoveTask), this)) {
cerr << "Error task start MoveTask: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
if (err = rt_task_start(&th_sendBatteryLevel, reinterpret_cast<void (*)(void *)>(&Tasks::SendBatteryLevel), this)) {
cerr << "Error task start SendBatteryLevel: " << strerror(-err) << endl;
exit(EXIT_FAILURE);
}
cout << "Tasks launched" << endl << flush;
cout << "Tasks launched" << endl;
}
/**
* @brief Arrêt des tâches
*/
void Tasks::Stop() {
monitor.Close();
robot.Close();
monitor.Close();
robot.Close();
}
/**
*/
void Tasks::Join() {
cout << "Tasks synchronized" << endl << flush;
rt_sem_broadcast(&sem_barrier);
pause();
cout << "Tasks synchronized" << endl;
rt_sem_broadcast(&sem_barrier);
pause();
}
/**
* @brief Thread handling server communication with the monitor.
*/
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);
[[noreturn]] void Tasks::ServerTask(void *arg) {
cout << "Start " << __PRETTY_FUNCTION__ << endl;
// Synchronization barrier (waiting that all tasks are started)
rt_sem_p(&sem_barrier, TM_INFINITE);
/**************************************************************************************/
/* The task server starts here */
/**************************************************************************************/
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
status = monitor.Open(SERVER_PORT);
rt_mutex_release(&mutex_monitor);
/* **************************************************************************************
* The task server starts here
* *************************************************************************************/
cout << "Open server on port " << (SERVER_PORT) << " (" << status << ")" << endl;
while (true) {
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
int status = monitor.Open(SERVER_PORT);
rt_mutex_release(&mutex_monitor);
if (status < 0) throw std::runtime_error {
"Unable to start server on port " + std::to_string(SERVER_PORT)
};
monitor.AcceptClient(); // Wait the monitor client
cout << "Rock'n'Roll baby, client accepted!" << endl << flush;
rt_sem_broadcast(&sem_serverOk);
cout << "Open server on port " << SERVER_PORT << " (" << status << ")" << endl;
if (status < 0) {
throw runtime_error{"Unable to start server on port " + to_string(SERVER_PORT)};
}
monitor.AcceptClient(); // Wait the monitor client
cout << "Rock'n'Roll baby, client accepted!" << endl;
rt_mutex_acquire(&mutex_monitorConnected, TM_INFINITE);
monitorConnected = true;
rt_mutex_release(&mutex_monitorConnected);
rt_sem_broadcast(&sem_serverOk);
// Wait for stopServer signal
rt_sem_p(&sem_stopServer, TM_INFINITE);
rt_sem_v(&sem_stopRobot);
rt_sem_v(&sem_closeComRobot);
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
rt_mutex_acquire(&mutex_monitorConnected, TM_INFINITE);
monitorConnected = false;
monitor.Close();
rt_mutex_release(&mutex_monitorConnected);
rt_mutex_release(&mutex_monitor);
}
}
/**
* @brief Thread sending data to monitor.
*/
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);
[[noreturn]] void Tasks::SendToMonTask(void *arg) {
Message *msg;
/**************************************************************************************/
/* The task sendToMon starts here */
/**************************************************************************************/
rt_sem_p(&sem_serverOk, TM_INFINITE);
cout << "Start " << __PRETTY_FUNCTION__ << endl;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
while (1) {
cout << "wait msg to send" << endl << flush;
msg = ReadInQueue(&q_messageToMon);
cout << "Send msg to mon: " << msg->ToString() << endl << flush;
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
monitor.Write(msg); // The message is deleted with the Write
rt_mutex_release(&mutex_monitor);
}
/* *************************************************************************************
* The task sendToMon starts here
* *************************************************************************************/
rt_sem_p(&sem_serverOk, TM_INFINITE);
while (true) {
cout << "wait msg to send" << endl;
msg = ReadInQueue(&q_messageToMon);
cout << "Send msg to mon: " << msg->ToString() << endl;
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
rt_mutex_acquire(&mutex_monitorConnected, TM_INFINITE);
if (monitorConnected) {
monitor.Write(msg); // The message is deleted with the Write
}
rt_mutex_release(&mutex_monitorConnected);
rt_mutex_release(&mutex_monitor);
}
}
/**
* @brief Thread receiving data from monitor.
*/
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 */
/**************************************************************************************/
rt_sem_p(&sem_serverOk, TM_INFINITE);
cout << "Received message from monitor activated" << endl << flush;
[[noreturn]] void Tasks::ReceiveFromMonTask(void *arg) {
Message *msgRcv;
while (1) {
msgRcv = monitor.Read();
cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
cout << "Start " << __PRETTY_FUNCTION__ << endl;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
if (msgRcv->CompareID(MESSAGE_MONITOR_LOST)) {
delete(msgRcv);
exit(-1);
} else if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) {
rt_sem_v(&sem_openComRobot);
} else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) {
rt_sem_v(&sem_startRobot);
} else if (msgRcv->CompareID(MESSAGE_ROBOT_GO_FORWARD) ||
msgRcv->CompareID(MESSAGE_ROBOT_GO_BACKWARD) ||
msgRcv->CompareID(MESSAGE_ROBOT_GO_LEFT) ||
msgRcv->CompareID(MESSAGE_ROBOT_GO_RIGHT) ||
msgRcv->CompareID(MESSAGE_ROBOT_STOP)) {
/* *************************************************************************************
* The task receiveFromMon starts here
* *************************************************************************************/
rt_mutex_acquire(&mutex_move, TM_INFINITE);
move = msgRcv->GetID();
rt_mutex_release(&mutex_move);
}
delete(msgRcv); // mus be deleted manually, no consumer
}
while (true) {
rt_sem_p(&sem_serverOk, TM_INFINITE);
cout << "Received message from monitor activated" << endl;
bool lostConnection = false;
while (!lostConnection) {
msgRcv = monitor.Read();
cout << "Rcv <= " << msgRcv->ToString() << endl;
if (msgRcv->CompareID(MESSAGE_MONITOR_LOST)) {
cout << "Monitor connection lost! Stopping robot..." << endl;
// rt_sem_v(&sem_stopCamera); // TODO
rt_sem_v(&sem_stopServer);
lostConnection = true;
} else if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) {
rt_sem_v(&sem_openComRobot);
} else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) {
rt_mutex_acquire(&mutex_watchdogMode, TM_INFINITE);
watchdogMode = WITHOUT_WATCHDOG;
rt_mutex_release(&mutex_watchdogMode);
rt_sem_v(&sem_startRobot);
} else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITH_WD)) {
// TODO: gérer la watchdog
rt_mutex_acquire(&mutex_watchdogMode, TM_INFINITE);
watchdogMode = WITH_WATCHDOG;
rt_mutex_release(&mutex_watchdogMode);
rt_sem_v(&sem_startRobot);
} else if (msgRcv->CompareID(MESSAGE_ROBOT_RESET)) {
rt_sem_v(&sem_stopRobot);
} else if (msgRcv->CompareID(MESSAGE_ROBOT_GO_FORWARD) ||
msgRcv->CompareID(MESSAGE_ROBOT_GO_BACKWARD) ||
msgRcv->CompareID(MESSAGE_ROBOT_GO_LEFT) ||
msgRcv->CompareID(MESSAGE_ROBOT_GO_RIGHT) ||
msgRcv->CompareID(MESSAGE_ROBOT_STOP)) {
rt_mutex_acquire(&mutex_move, TM_INFINITE);
move = msgRcv->GetID();
rt_mutex_release(&mutex_move);
} else if (msgRcv->CompareID(MESSAGE_CAM_OPEN)) {
// TODO
} else if (msgRcv->CompareID(MESSAGE_CAM_CLOSE)) {
// TODO
} else if (msgRcv->CompareID(MESSAGE_CAM_ASK_ARENA)) {
// TODO
} else if (msgRcv->CompareID(MESSAGE_CAM_ARENA_CONFIRM)) {
// TODO
} else if (msgRcv->CompareID(MESSAGE_CAM_ARENA_INFIRM)) {
// TODO
} else if (msgRcv->CompareID(MESSAGE_CAM_POSITION_COMPUTE_START)) {
// TODO
} else if (msgRcv->CompareID(MESSAGE_CAM_POSITION_COMPUTE_STOP)) {
// TODO
}
delete (msgRcv); // mus be deleted manually, no consumer
}
}
}
/**
* @brief Thread opening communication with the robot.
* @brief Thread managing the communication with the robot.
*/
void Tasks::OpenComRobot(void *arg) {
int status;
int err;
[[noreturn]] void Tasks::ManageRobotComTask(void *arg) {
int status;
cout << "Start " << __PRETTY_FUNCTION__ << endl;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
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 */
/**************************************************************************************/
while (1) {
rt_sem_p(&sem_openComRobot, TM_INFINITE);
cout << "Open serial com (";
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
status = robot.Open();
rt_mutex_release(&mutex_robot);
cout << status;
cout << ")" << endl << flush;
/* *************************************************************************************
* The task startRobot starts here
* *************************************************************************************/
while (true) {
rt_sem_p(&sem_openComRobot, TM_INFINITE);
cout << "Open serial com (";
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
status = robot.Open();
rt_mutex_release(&mutex_robot);
cout << status;
cout << ")" << endl;
if (status < 0) {
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_NACK)); // msgSend will be deleted by sendToMon
} else {
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_ACK)); // msgSend will be deleted by sendToMon
Message * msgSend;
if (status < 0) {
msgSend = new Message(MESSAGE_ANSWER_NACK);
} else {
msgSend = new Message(MESSAGE_ANSWER_ACK);
}
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
}
rt_sem_p(&sem_closeComRobot, TM_INFINITE);
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
robot.Close();
rt_mutex_release(&mutex_robot);
}
}
}
/**
* @brief Thread starting the communication with the robot.
*/
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 */
/**************************************************************************************/
while (1) {
[[noreturn]] void Tasks::ManageRobotTask(void *arg) {
int status;
cout << "Start " << __PRETTY_FUNCTION__ << endl;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
Message * msgSend;
rt_sem_p(&sem_startRobot, TM_INFINITE);
cout << "Start robot without watchdog (";
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
msgSend = robot.Write(robot.StartWithoutWD());
rt_mutex_release(&mutex_robot);
cout << msgSend->GetID();
cout << ")" << endl;
/* *************************************************************************************
* The task startRobot starts here
* *************************************************************************************/
while (true) {
Message *msgSend;
rt_sem_p(&sem_startRobot, TM_INFINITE);
rt_mutex_acquire(&mutex_watchdogMode, TM_INFINITE);
const WatchdogMode mode = watchdogMode;
rt_mutex_release(&mutex_watchdogMode);
cout << "Movement answer: " << msgSend->ToString() << endl << flush;
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
if (mode == WITH_WATCHDOG) {
cout << "Start robot with watchdog (";
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
msgSend = robot.Write(ComRobot::StartWithWD());
rt_mutex_release(&mutex_robot);
cout << msgSend->GetID();
cout << ")" << endl;
} else {
cout << "Start robot without watchdog (";
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
msgSend = robot.Write(ComRobot::StartWithoutWD());
rt_mutex_release(&mutex_robot);
cout << msgSend->GetID();
cout << ")" << endl;
}
cout << "Start answer: " << msgSend->ToString() << endl;
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
robotStarted = 1;
cout << "robot started" << endl;
rt_mutex_release(&mutex_robotStarted);
rt_sem_p(&sem_stopRobot, TM_INFINITE);
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
robot.Write(new Message(MESSAGE_ROBOT_STOP));
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
robotStarted = 0;
cout << "robot stopped" << endl;
rt_mutex_release(&mutex_robotStarted);
rt_mutex_release(&mutex_robot);
}
}
}
/**
* @brief Thread seding the battery level.
*/
[[noreturn]] void Tasks::SendBatteryLevel(void *arg) {
int rs;
cout << "Start " << __PRETTY_FUNCTION__ << endl;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
/* *************************************************************************************/
/* The task sendBatteryLevel starts here */
/* *************************************************************************************/
rt_task_set_periodic(nullptr, TM_NOW, 500000000); // 500 ms
while (true) {
rt_task_wait_period(nullptr);
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
rs = robotStarted;
rt_mutex_release(&mutex_robotStarted);
if (rs == 1) {
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
auto msg = dynamic_cast<MessageBattery *>(robot.Write(ComRobot::GetBattery()));
if (msg == nullptr) {
cout << "NULLPTR" << endl;
} else {
WriteInQueue(&q_messageToMon, msg);
}
rt_mutex_release(&mutex_robot);
}
}
if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
robotStarted = 1;
rt_mutex_release(&mutex_robotStarted);
}
}
}
/**
* @brief Thread handling control of the robot.
*/
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 */
/**************************************************************************************/
rt_task_set_periodic(NULL, TM_NOW, 100000000);
[[noreturn]] void Tasks::MoveTask(void *arg) {
int rs;
int cpMove;
int counter = 0;
while (1) {
rt_task_wait_period(NULL);
cout << "Periodic movement update";
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
rs = robotStarted;
rt_mutex_release(&mutex_robotStarted);
if (rs == 1) {
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));
rt_mutex_release(&mutex_robot);
}
cout << endl << flush;
}
cout << "Start " << __PRETTY_FUNCTION__ << endl;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
/* **************************************************************************************
* The task starts here
* *************************************************************************************/
rt_task_set_periodic(nullptr, TM_NOW, 100000000); // 100 ms
while (true) {
rt_task_wait_period(nullptr);
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
rs = robotStarted;
rt_mutex_release(&mutex_robotStarted);
if (rs == 1) {
rt_mutex_acquire(&mutex_move, TM_INFINITE);
cpMove = move;
rt_mutex_release(&mutex_move);
cout << "move: " << cpMove << endl;
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
auto msgSend = robot.Write(new Message((MessageID) cpMove));
if (msgSend->CompareID(MESSAGE_ANSWER_ACK)) {
counter = 0;
} else {
counter++;
}
if (counter == 3) {
rt_sem_v(&sem_stopRobot);
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_COM_ERROR));
}
rt_mutex_release(&mutex_robot);
}
}
}
/**
@ -389,11 +539,11 @@ void Tasks::MoveTask(void *arg) {
* @param msg Message to be stored
*/
void Tasks::WriteInQueue(RT_QUEUE *queue, Message *msg) {
int err;
if ((err = rt_queue_write(queue, (const void *) &msg, sizeof ((const void *) &msg), Q_NORMAL)) < 0) {
cerr << "Write in queue failed: " << strerror(-err) << endl << flush;
throw std::runtime_error{"Error in write in queue"};
}
int err;
if ((err = rt_queue_write(queue, (const void *) &msg, sizeof((const void *) &msg), Q_NORMAL)) < 0) {
cerr << "Write in queue failed: " << strerror(-err) << endl;
throw runtime_error{"Error in write in queue"};
}
}
/**
@ -402,16 +552,16 @@ void Tasks::WriteInQueue(RT_QUEUE *queue, Message *msg) {
* @return Message read
*/
Message *Tasks::ReadInQueue(RT_QUEUE *queue) {
int err;
Message *msg;
int err;
Message *msg;
if ((err = rt_queue_read(queue, &msg, sizeof ((void*) &msg), TM_INFINITE)) < 0) {
cout << "Read in queue failed: " << strerror(-err) << endl << flush;
throw std::runtime_error{"Error in read in queue"};
}/** else {
cout << "@msg :" << msg << endl << flush;
} /**/
if ((err = rt_queue_read(queue, &msg, sizeof((void *) &msg), TM_INFINITE)) < 0) {
cout << "Read in queue failed: " << strerror(-err) << endl;
throw runtime_error{"Error in read in queue"};
}/** else {
cout << "@msg :" << msg << endl;
} **/
return msg;
return msg;
}

View file

@ -34,7 +34,11 @@
#include "camera.h"
#include "img.h"
using namespace std;
enum WatchdogMode {
WITH_WATCHDOG,
WITHOUT_WATCHDOG,
};
class Tasks {
public:
@ -59,97 +63,113 @@ public:
void Join();
private:
/**********************************************************************/
/* Shared data */
/**********************************************************************/
/* *********************************************************************
* Shared data
* ********************************************************************/
ComMonitor monitor;
ComRobot robot;
int robotStarted = 0;
int move = MESSAGE_ROBOT_STOP;
/**********************************************************************/
/* Tasks */
/**********************************************************************/
bool monitorConnected = false;
WatchdogMode watchdogMode = WITHOUT_WATCHDOG;
/* *********************************************************************
* Tasks
* ********************************************************************/
RT_TASK th_server;
RT_TASK th_sendToMon;
RT_TASK th_receiveFromMon;
RT_TASK th_openComRobot;
RT_TASK th_startRobot;
RT_TASK th_move;
/**********************************************************************/
/* Mutex */
/**********************************************************************/
RT_TASK th_sendBatteryLevel;
RT_TASK th_manageRobotCom;
RT_TASK th_manageRobot;
/* *********************************************************************
* Mutex
* ********************************************************************/
RT_MUTEX mutex_monitor;
RT_MUTEX mutex_monitorConnected;
RT_MUTEX mutex_robot;
RT_MUTEX mutex_robotStarted;
RT_MUTEX mutex_move;
RT_MUTEX mutex_watchdogMode;
/**********************************************************************/
/* Semaphores */
/**********************************************************************/
/* *********************************************************************
* Semaphores
* ********************************************************************/
RT_SEM sem_barrier;
RT_SEM sem_openComRobot;
RT_SEM sem_serverOk;
RT_SEM sem_openComRobot;
RT_SEM sem_closeComRobot;
RT_SEM sem_startRobot;
RT_SEM sem_stopRobot;
RT_SEM sem_stopServer;
/**********************************************************************/
/* Message queues */
/**********************************************************************/
/* *********************************************************************
* Message queues
**********************************************************************/
int MSG_QUEUE_SIZE;
RT_QUEUE q_messageToMon;
/**********************************************************************/
/* Tasks' functions */
/**********************************************************************/
/* *********************************************************************
* Tasks' functions
* ********************************************************************/
/**
* @brief Thread handling server communication with the monitor.
*/
void ServerTask(void *arg);
[[noreturn]] void ServerTask(void *arg);
/**
* @brief Thread sending data to monitor.
*/
void SendToMonTask(void *arg);
[[noreturn]] void SendToMonTask(void *arg);
/**
* @brief Thread receiving data from monitor.
*/
void ReceiveFromMonTask(void *arg);
[[noreturn]] void ReceiveFromMonTask(void *arg);
/**
* @brief Thread opening communication with the robot.
* @brief Thread managing communication with the robot.
*/
void OpenComRobot(void *arg);
[[noreturn]] void ManageRobotComTask(void *arg);
/**
* @brief Thread starting the communication with the robot.
*/
void StartRobotTask(void *arg);
/**
* @brief Thread handling control of the robot.
*/
void MoveTask(void *arg);
/**********************************************************************/
/* Queue services */
/**********************************************************************/
/**
* Write a message in a given queue
* @param queue Queue identifier
* @param msg Message to be stored
*/
void WriteInQueue(RT_QUEUE *queue, Message *msg);
/**
* @brief Thread starting the communication with the robot.
*/
[[noreturn]] void ManageRobotTask(void *arg);
/**
* @brief Thread handling control of the robot.
*/
[[noreturn]] void MoveTask(void *arg);
/**
* @brief Thread handling battery level sending.
*/
[[noreturn]] void SendBatteryLevel(void *arg);
/* *********************************************************************
* Queue services
* ********************************************************************/
/**
* Write a message in a given queue
* @param queue Queue identifier
* @param msg Message to be stored
*/
static void WriteInQueue(RT_QUEUE *queue, Message *msg);
/**
* Read a message from a given queue, block if empty
* @param queue Queue identifier
* @return Message read
*/
Message *ReadInQueue(RT_QUEUE *queue);
static Message *ReadInQueue(RT_QUEUE *queue);
};
#endif // __TASKS_H__

View file

@ -0,0 +1,5 @@
# This code depends on make tool being used
DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES} ${TESTOBJECTFILES}))
ifneq (${DEPFILES},)
include ${DEPFILES}
endif

View file

@ -0,0 +1,298 @@
#include <unistd.h>
#include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
#include <iostream>
#include <time.h>
using namespace std;
const char LABEL_ROBOT_PING = 'p';
const char LABEL_ROBOT_RESET = 'r';
const char LABEL_ROBOT_START_WITH_WD = 'W';
const char LABEL_ROBOT_START_WITHOUT_WD = 'u';
const char LABEL_ROBOT_RELOAD_WD = 'w';
const char LABEL_ROBOT_MOVE = 'M';
const char LABEL_ROBOT_TURN = 'T';
const char LABEL_ROBOT_GET_BATTERY = 'v';
const char LABEL_ROBOT_GET_STATE = 'b';
const char LABEL_ROBOT_POWEROFF = 'z';
const char LABEL_ROBOT_OK = 'O';
const char LABEL_ROBOT_ERROR = 'E';
const char LABEL_ROBOT_UNKNOWN_COMMAND = 'C';
const char LABEL_ROBOT_SEPARATOR_CHAR = '=';
const char LABEL_ROBOT_ENDING_CHAR = 0x0D;
int server_fd, new_socket, valread;
struct sockaddr_in address;
int addrlen;
#define PORT 6699
int status = 0;
int noerr = 0;
int isWD = 0;
long int ellapse(struct timespec ref, struct timespec cur) {
long int e;
e = cur.tv_sec - ref.tv_sec;
e *= 1000000000;
e += cur.tv_nsec - ref.tv_nsec;
return e;
}
void print_time(struct timespec start_time) {
struct timespec t;
clock_gettime(CLOCK_REALTIME, &t);
long int e = ellapse(start_time, t);
fprintf(stdout, "%9ld", e / 1000000);
}
int simulate_error() {
int r = rand() % 1000;
if (r > 950) {
printf("[I don't understand what you said (-1)]\n");
return -1;
} else if (r > 900) {
printf("[I'm mute, because I never got your message (-2)]\n");
return -2;
}
printf("[WILCO (0)] ");
return 0;
}
void simulate_transmission_time() {
usleep((rand() % 30) * 1000);
}
void open_server() {
int opt = 1;
// Creating socket file descriptor
if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
perror("socket failed");
exit(EXIT_FAILURE);
}
// Forcefully attaching socket to the port 8080
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT,
&opt, sizeof (opt))) {
perror("setsockopt");
exit(EXIT_FAILURE);
}
cout << "<<< simulator >>>" << endl;
cout << ">>> Hello, I'm Mr " ;
if (noerr) cout << "perfect ";
cout << "Robot" << endl;
// Forcefully attaching socket to the port 8080
if (bind(server_fd, (struct sockaddr *) &address,
sizeof (address)) < 0) {
perror("bind failed");
exit(EXIT_FAILURE);
}
cout << ">>> I create a server" << endl;
cout << ">>> ..." << endl;
}
void wait_connection() {
if (listen(server_fd, 3) < 0) {
perror("listen");
exit(EXIT_FAILURE);
}
cout << ">>> I'm waiting a client" << endl;
if ((new_socket = accept(server_fd, (struct sockaddr *) &address,
(socklen_t*) & addrlen)) < 0) {
perror("accept");
exit(EXIT_FAILURE);
}
}
void reset(){
isWD = 0;
status = 0;
cout << ">>> XX I stop XX" << endl;
}
int main(int argc, char const *argv[]) {
if (argc != 1){
if (argv[1] == std::string("noerror")){
noerr = 1;
}
}
char buffer[1024] = {0};
addrlen = sizeof (address);
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(PORT);
srand(time(NULL));
open_server();
wait_connection();
cout << ">>> I'm ready to receive something" << endl;
struct timespec start_time;
clock_gettime(CLOCK_REALTIME, &start_time);
struct timespec start_wd;
struct timespec t;
long int e;
struct timespec last_call;
clock_gettime(CLOCK_REALTIME, &last_call);
isWD = 0;
while (status < 3) {
if (isWD) {
clock_gettime(CLOCK_REALTIME, &t);
e = ellapse(last_call, t);
if ((e / 1000000000) > 3) {
cout << ">>> You break my heart, you never talk at the right time." << endl;
break;
}
}
valread = read(new_socket, buffer, 1024);
if (valread <= 0) {
if (errno == EAGAIN) {
status = 3;
cout << ">>> You break my heart, I've been waiting too long for you." << endl;
break;
} else {
cout << ">>> Why did you hang up? Please, contact me again." << endl;
reset();
wait_connection();
clock_gettime(CLOCK_REALTIME, &last_call);
}
}
string s = "";
int error = 0;
if (!noerr) error = simulate_error();
if (error == 0) {
print_time(start_time);
printf(": I received a message %s\n", buffer);
switch (buffer[0]) {
case LABEL_ROBOT_START_WITHOUT_WD:
cout << ">>> I start without watchdog" << endl;
s += LABEL_ROBOT_OK;
break;
case LABEL_ROBOT_PING:
cout << ">>> ...Pong" << endl;
s += LABEL_ROBOT_OK;
break;
case LABEL_ROBOT_START_WITH_WD:
clock_gettime(CLOCK_REALTIME, &start_wd);
clock_gettime(CLOCK_REALTIME, &last_call);
struct timeval tv;
tv.tv_sec = 3;
tv.tv_usec = 0;
setsockopt(new_socket, SOL_SOCKET, SO_RCVTIMEO, (const char*) &tv, sizeof tv);
cout << ">>> I start with watchdog" << endl;
s += LABEL_ROBOT_OK;
isWD = 1;
break;
case LABEL_ROBOT_MOVE:
switch (buffer[2]) {
case '0':
cout << ">>> XX I stop XX" << endl;
break;
case '-':
cout << ">>> \\/ I move backward \\/" << endl;
break;
default:
cout << ">>> /\\ I move forward /\\" << endl;
break;
}
s += LABEL_ROBOT_OK;
break;
case LABEL_ROBOT_TURN:
switch (buffer[2]) {
case '-':
cout << ">>> << I turn to the left <<" << endl;
break;
default:
cout << ">>> >> I turn to the right >>" << endl;
break;
}
s += LABEL_ROBOT_OK;
break;
case LABEL_ROBOT_GET_BATTERY:
cout << ">>> I give you my battery level :-o" << endl;
clock_gettime(CLOCK_REALTIME, &t);
e = ellapse(start_time, t);
if (e > 20000000000) {
s += '0';
} else {
if (e > 10000000000) {
s += '1';
} else {
s += '2';
}
}
break;
case LABEL_ROBOT_RELOAD_WD:
clock_gettime(CLOCK_REALTIME, &t);
e = ellapse(start_wd, t);
e = (e / 1000000) % 1000;
if (isWD) {
if ((e < 50) || (e > 950)) {
cout << ">>> Just in time for a reload " << e << "ms" << endl;
last_call = t;
status = 0;
s += LABEL_ROBOT_OK;
} else {
status++;
cout << ">>> You missed the date, -1 point " << e << "ms (" << status << ")" << endl;
s += LABEL_ROBOT_UNKNOWN_COMMAND;
}
} else {
cout << "Why you said that, I do nothing" << endl;
}
break;
case LABEL_ROBOT_POWEROFF:
cout << ">>> Bye bye, see you soon" << endl;
s += LABEL_ROBOT_OK;
status = 10;
break;
case LABEL_ROBOT_RESET:
cout << ">>> I reset" << endl;
s += LABEL_ROBOT_OK;
reset();
break;
case LABEL_ROBOT_GET_STATE:
cout << ">>> I'm fine, thank you" << endl;
s += LABEL_ROBOT_OK;
break;
default:
//msg = new Message(MESSAGE_ANSWER_ROBOT_ERROR);
cerr << "[" << __PRETTY_FUNCTION__ << "] Unknown message received from robot (" << buffer << ")" << endl << flush;
}
simulate_transmission_time();
send(new_socket, s.c_str(), s.length(), 0);
} else if (error == -1) {
s += LABEL_ROBOT_UNKNOWN_COMMAND;
simulate_transmission_time();
send(new_socket, s.c_str(), s.length(), 0);
} else if (error == -2) {
/* Do nothing */
}
}
cout << "The robot is out. End of story. " << endl;
cout << " /\\_/\\" << endl << "( o.o )" << endl << " > ^ <" << endl;
return 0;
}

View file

@ -0,0 +1,83 @@
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux
CND_DLIB_EXT=so
CND_CONF=Debug
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
${OBJECTDIR}/main.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/simulateur
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/simulateur: ${OBJECTFILES}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/simulateur ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -g -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r ${CND_BUILDDIR}/${CND_CONF}
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc

View file

@ -0,0 +1,83 @@
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc
CCC=g++
CXX=g++
FC=gfortran
AS=as
# Macros
CND_PLATFORM=GNU-Linux
CND_DLIB_EXT=so
CND_CONF=Release
CND_DISTDIR=dist
CND_BUILDDIR=build
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
${OBJECTDIR}/main.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
"${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/simulateur
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/simulateur: ${OBJECTFILES}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/simulateur ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} "$@.d"
$(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r ${CND_BUILDDIR}/${CND_CONF}
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc

View file

@ -0,0 +1,133 @@
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=simulateur
# Active Configuration
DEFAULTCONF=Debug
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=Debug Release
# build
.build-impl: .build-pre .validate-impl .depcheck-impl
@#echo "=> Running $@... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
# clean
.clean-impl: .clean-pre .validate-impl .depcheck-impl
@#echo "=> Running $@... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
# clobber
.clobber-impl: .clobber-pre .depcheck-impl
@#echo "=> Running $@..."
for CONF in ${ALLCONFS}; \
do \
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
done
# all
.all-impl: .all-pre .depcheck-impl
@#echo "=> Running $@..."
for CONF in ${ALLCONFS}; \
do \
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
done
# build tests
.build-tests-impl: .build-impl .build-tests-pre
@#echo "=> Running $@... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
# run tests
.test-impl: .build-tests-impl .test-pre
@#echo "=> Running $@... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
# dependency checking support
.depcheck-impl:
@echo "# This code depends on make tool being used" >.dep.inc
@if [ -n "${MAKE_VERSION}" ]; then \
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES} \$${TESTOBJECTFILES}))" >>.dep.inc; \
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
echo "include \$${DEPFILES}" >>.dep.inc; \
echo "endif" >>.dep.inc; \
else \
echo ".KEEP_STATE:" >>.dep.inc; \
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
fi
# configuration validation
.validate-impl:
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
then \
echo ""; \
echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
echo "See 'make help' for details."; \
echo "Current directory: " `pwd`; \
echo ""; \
fi
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
then \
exit 1; \
fi
# help
.help-impl: .help-pre
@echo "This makefile supports the following configurations:"
@echo " ${ALLCONFS}"
@echo ""
@echo "and the following targets:"
@echo " build (default target)"
@echo " clean"
@echo " clobber"
@echo " all"
@echo " help"
@echo ""
@echo "Makefile Usage:"
@echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
@echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
@echo " make [SUB=no] clobber"
@echo " make [SUB=no] all"
@echo " make help"
@echo ""
@echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
@echo " also build subprojects."
@echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
@echo " also clean subprojects."
@echo "Target 'clobber' will remove all built files from all configurations and,"
@echo " unless 'SUB=no', also from subprojects."
@echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
@echo " also build subprojects."
@echo "Target 'help' prints this message."
@echo ""

View file

@ -0,0 +1,35 @@
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
CND_BUILDDIR=build
CND_DISTDIR=dist
# Debug configuration
CND_PLATFORM_Debug=GNU-Linux
CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux
CND_ARTIFACT_NAME_Debug=simulateur
CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux/simulateur
CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux/package
CND_PACKAGE_NAME_Debug=simulateur.tar
CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux/package/simulateur.tar
# Release configuration
CND_PLATFORM_Release=GNU-Linux
CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux
CND_ARTIFACT_NAME_Release=simulateur
CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux/simulateur
CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux/package
CND_PACKAGE_NAME_Release=simulateur.tar
CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux/package/simulateur.tar
#
# include compiler specific variables
#
# dmake command
ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \
(mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)
#
# gmake command
.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk))
#
include nbproject/private/Makefile-variables.mk

View file

@ -7,15 +7,15 @@
# Macros
TOP=`pwd`
CND_PLATFORM=GNU-Linux
CND_CONF=Debug__RPI_
CND_CONF=Debug
CND_DISTDIR=dist
CND_BUILDDIR=build
CND_DLIB_EXT=so
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/superviseur-robot
OUTPUT_BASENAME=superviseur-robot
PACKAGE_TOP_DIR=superviseur-robot/
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/simulateur
OUTPUT_BASENAME=simulateur
PACKAGE_TOP_DIR=simulateur/
# Functions
function checkReturnCode
@ -60,15 +60,15 @@ mkdir -p ${NBTMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory "${NBTMPDIR}/superviseur-robot/bin"
makeDirectory "${NBTMPDIR}/simulateur/bin"
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/superviseur-robot.tar
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/simulateur.tar
cd ${NBTMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/superviseur-robot.tar *
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/simulateur.tar *
checkReturnCode
# Cleanup

View file

@ -0,0 +1,76 @@
#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_PLATFORM=GNU-Linux
CND_CONF=Release
CND_DISTDIR=dist
CND_BUILDDIR=build
CND_DLIB_EXT=so
NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/simulateur
OUTPUT_BASENAME=simulateur
PACKAGE_TOP_DIR=simulateur/
# Functions
function checkReturnCode
{
rc=$?
if [ $rc != 0 ]
then
exit $rc
fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
mkdir -p "$1"
checkReturnCode
if [ "$2" != "" ]
then
chmod $2 "$1"
checkReturnCode
fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
cp "$1" "$2"
checkReturnCode
if [ "$3" != "" ]
then
chmod $3 "$2"
checkReturnCode
fi
}
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
rm -rf ${NBTMPDIR}
mkdir -p ${NBTMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory "${NBTMPDIR}/simulateur/bin"
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/simulateur.tar
cd ${NBTMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/simulateur.tar *
checkReturnCode
# Cleanup
cd "${TOP}"
rm -rf ${NBTMPDIR}

View file

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="100">
<logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true">
</logicalFolder>
<logicalFolder name="ResourceFiles"
displayName="Resource Files"
projectFiles="true">
</logicalFolder>
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>main.cpp</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>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="Debug" type="1">
<toolsSet>
<compilerSet>default</compilerSet>
<dependencyChecking>true</dependencyChecking>
<rebuildPropChanged>false</rebuildPropChanged>
</toolsSet>
<compileType>
</compileType>
<item path="main.cpp" ex="false" tool="1" flavor2="0">
</item>
</conf>
<conf name="Release" type="1">
<toolsSet>
<compilerSet>default</compilerSet>
<dependencyChecking>true</dependencyChecking>
<rebuildPropChanged>false</rebuildPropChanged>
</toolsSet>
<compileType>
<cTool>
<developmentMode>5</developmentMode>
</cTool>
<ccTool>
<developmentMode>5</developmentMode>
</ccTool>
<fortranCompilerTool>
<developmentMode>5</developmentMode>
</fortranCompilerTool>
<asmTool>
<developmentMode>5</developmentMode>
</asmTool>
</compileType>
<item path="main.cpp" ex="false" tool="1" flavor2="0">
</item>
</conf>
</confs>
</configurationDescriptor>

View file

@ -0,0 +1,7 @@
#
# Generated - do not edit!
#
# NOCDDL
#
# Debug configuration
# Release configuration

View file

@ -0,0 +1,75 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
*
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common
* Development and Distribution License("CDDL") (collectively, the
* "License"). You may not use this file except in compliance with the
* License. You can obtain a copy of the License at
* http://www.netbeans.org/cddl-gplv2.html
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
* specific language governing permissions and limitations under the
* License. When distributing the software, include this License Header
* Notice in each file and include the License file at
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the
* License Header, with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* If you wish your version of this file to be governed by only the CDDL
* or only the GPL Version 2, indicate your decision by adding
* "[Contributor] elects to include this software in this distribution
* under the [CDDL or GPL Version 2] license." If you do not indicate a
* single choice of license, a recipient has the option to distribute
* your version of this file under either the CDDL, the GPL Version 2 or
* to extend the choice of license to its licensees as provided above.
* However, if you add GPL Version 2 code and therefore, elected the GPL
* Version 2 license, then the option applies only if the new code is
* made subject to such option by the copyright holder.
*
* Contributor(s):
*/
// List of standard headers was taken in http://en.cppreference.com/w/c/header
#include <assert.h> // Conditionally compiled macro that compares its argument to zero
#include <ctype.h> // Functions to determine the type contained in character data
#include <errno.h> // Macros reporting error conditions
#include <float.h> // Limits of float types
#include <limits.h> // Sizes of basic types
#include <locale.h> // Localization utilities
#include <math.h> // Common mathematics functions
#include <setjmp.h> // Nonlocal jumps
#include <signal.h> // Signal handling
#include <stdarg.h> // Variable arguments
#include <stddef.h> // Common macro definitions
#include <stdio.h> // Input/output
#include <string.h> // String handling
#include <stdlib.h> // General utilities: memory management, program utilities, string conversions, random numbers
#include <time.h> // Time/date utilities
#include <iso646.h> // (since C95) Alternative operator spellings
#include <wchar.h> // (since C95) Extended multibyte and wide character utilities
#include <wctype.h> // (since C95) Wide character classification and mapping utilities
#ifdef _STDC_C99
#include <complex.h> // (since C99) Complex number arithmetic
#include <fenv.h> // (since C99) Floating-point environment
#include <inttypes.h> // (since C99) Format conversion of integer types
#include <stdbool.h> // (since C99) Boolean type
#include <stdint.h> // (since C99) Fixed-width integer types
#include <tgmath.h> // (since C99) Type-generic math (macros wrapping math.h and complex.h)
#endif
#ifdef _STDC_C11
#include <stdalign.h> // (since C11) alignas and alignof convenience macros
#include <stdatomic.h> // (since C11) Atomic types
#include <stdnoreturn.h> // (since C11) noreturn convenience macros
#include <threads.h> // (since C11) Thread library
#include <uchar.h> // (since C11) UTF-16 and UTF-32 character utilities
#endif

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="100">
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="Debug" type="1">
<toolsSet>
<developmentServer>localhost</developmentServer>
<platform>2</platform>
</toolsSet>
<dbx_gdbdebugger version="1">
<gdb_pathmaps>
</gdb_pathmaps>
<gdb_interceptlist>
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
</gdb_interceptlist>
<gdb_options>
<DebugOptions>
</DebugOptions>
</gdb_options>
<gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/>
</dbx_gdbdebugger>
<nativedebugger version="1">
<engine>gdb</engine>
</nativedebugger>
<runprofile version="9">
<runcommandpicklist>
<runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem>
</runcommandpicklist>
<runcommand>"${OUTPUT_PATH}"</runcommand>
<rundir></rundir>
<buildfirst>true</buildfirst>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
<conf name="Release" type="1">
<toolsSet>
<developmentServer>localhost</developmentServer>
<platform>2</platform>
</toolsSet>
<dbx_gdbdebugger version="1">
<gdb_pathmaps>
</gdb_pathmaps>
<gdb_interceptlist>
<gdbinterceptoptions gdb_all="false" gdb_unhandled="true" gdb_unexpected="true"/>
</gdb_interceptlist>
<gdb_options>
<DebugOptions>
</DebugOptions>
</gdb_options>
<gdb_buildfirst gdb_buildfirst_overriden="false" gdb_buildfirst_old="false"/>
</dbx_gdbdebugger>
<nativedebugger version="1">
<engine>gdb</engine>
</nativedebugger>
<runprofile version="9">
<runcommandpicklist>
<runcommandpicklistitem>"${OUTPUT_PATH}"</runcommandpicklistitem>
</runcommandpicklist>
<runcommand>"${OUTPUT_PATH}"</runcommand>
<rundir></rundir>
<buildfirst>true</buildfirst>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
</confs>
</configurationDescriptor>

View file

@ -0,0 +1,135 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
*
* Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common
* Development and Distribution License("CDDL") (collectively, the
* "License"). You may not use this file except in compliance with the
* License. You can obtain a copy of the License at
* http://www.netbeans.org/cddl-gplv2.html
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
* specific language governing permissions and limitations under the
* License. When distributing the software, include this License Header
* Notice in each file and include the License file at
* nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the GPL Version 2 section of the License file that
* accompanied this code. If applicable, add the following below the
* License Header, with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* If you wish your version of this file to be governed by only the CDDL
* or only the GPL Version 2, indicate your decision by adding
* "[Contributor] elects to include this software in this distribution
* under the [CDDL or GPL Version 2] license." If you do not indicate a
* single choice of license, a recipient has the option to distribute
* your version of this file under either the CDDL, the GPL Version 2 or
* to extend the choice of license to its licensees as provided above.
* However, if you add GPL Version 2 code and therefore, elected the GPL
* Version 2 license, then the option applies only if the new code is
* made subject to such option by the copyright holder.
*
* Contributor(s):
*/
// List of standard headers was taken in http://en.cppreference.com/w/cpp/header
#include <cstdlib> // General purpose utilities: program control, dynamic memory allocation, random numbers, sort and search
#include <csignal> // Functions and macro constants for signal management
#include <csetjmp> // Macro (and function) that saves (and jumps) to an execution context
#include <cstdarg> // Handling of variable length argument lists
#include <typeinfo> // Runtime type information utilities
#include <bitset> // std::bitset class template
#include <functional> // Function objects, designed for use with the standard algorithms
#include <utility> // Various utility components
#include <ctime> // C-style time/date utilites
#include <cstddef> // typedefs for types such as size_t, NULL and others
#include <new> // Low-level memory management utilities
#include <memory> // Higher level memory management utilities
#include <climits> // limits of integral types
#include <cfloat> // limits of float types
#include <limits> // standardized way to query properties of arithmetic types
#include <exception> // Exception handling utilities
#include <stdexcept> // Standard exception objects
#include <cassert> // Conditionally compiled macro that compares its argument to zero
#include <cerrno> // Macro containing the last error number
#include <cctype> // functions to determine the type contained in character data
#include <cwctype> // functions for determining the type of wide character data
#include <cstring> // various narrow character string handling functions
#include <cwchar> // various wide and multibyte string handling functions
#include <string> // std::basic_string class template
#include <vector> // std::vector container
#include <deque> // std::deque container
#include <list> // std::list container
#include <set> // std::set and std::multiset associative containers
#include <map> // std::map and std::multimap associative containers
#include <stack> // std::stack container adaptor
#include <queue> // std::queue and std::priority_queue container adaptors
#include <algorithm> // Algorithms that operate on containers
#include <iterator> // Container iterators
#include <cmath> // Common mathematics functions
#include <complex> // Complex number type
#include <valarray> // Class for representing and manipulating arrays of values
#include <numeric> // Numeric operations on values in containers
#include <iosfwd> // forward declarations of all classes in the input/output library
#include <ios> // std::ios_base class, std::basic_ios class template and several typedefs
#include <istream> // std::basic_istream class template and several typedefs
#include <ostream> // std::basic_ostream, std::basic_iostream class templates and several typedefs
#include <iostream> // several standard stream objects
#include <fstream> // std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs
#include <sstream> // std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs
#include <strstream> // std::strstream, std::istrstream, std::ostrstream(deprecated)
#include <iomanip> // Helper functions to control the format or input and output
#include <streambuf> // std::basic_streambuf class template
#include <cstdio> // C-style input-output functions
#include <locale> // Localization utilities
#include <clocale> // C localization utilities
#include <ciso646> // empty header. The macros that appear in iso646.h in C are keywords in C++
#if __cplusplus >= 201103L
#include <typeindex> // (since C++11) std::type_index
#include <type_traits> // (since C++11) Compile-time type information
#include <chrono> // (since C++11) C++ time utilites
#include <initializer_list> // (since C++11) std::initializer_list class template
#include <tuple> // (since C++11) std::tuple class template
#include <scoped_allocator> // (since C++11) Nested allocator class
#include <cstdint> // (since C++11) fixed-size types and limits of other types
#include <cinttypes> // (since C++11) formatting macros , intmax_t and uintmax_t math and conversions
#include <system_error> // (since C++11) defines std::error_code, a platform-dependent error code
#include <cuchar> // (since C++11) C-style Unicode character conversion functions
#include <array> // (since C++11) std::array container
#include <forward_list> // (since C++11) std::forward_list container
#include <unordered_set> // (since C++11) std::unordered_set and std::unordered_multiset unordered associative containers
#include <unordered_map> // (since C++11) std::unordered_map and std::unordered_multimap unordered associative containers
#include <random> // (since C++11) Random number generators and distributions
#include <ratio> // (since C++11) Compile-time rational arithmetic
#include <cfenv> // (since C++11) Floating-point environment access functions
#include <codecvt> // (since C++11) Unicode conversion facilities
#include <regex> // (since C++11) Classes, algorithms and iterators to support regular expression processing
#include <atomic> // (since C++11) Atomic operations library
#include <ccomplex> // (since C++11)(deprecated in C++17) simply includes the header <complex>
#include <ctgmath> // (since C++11)(deprecated in C++17) simply includes the headers <ccomplex> (until C++17)<complex> (since C++17) and <cmath>: the overloads equivalent to the contents of the C header tgmath.h are already provided by those headers
#include <cstdalign> // (since C++11)(deprecated in C++17) defines one compatibility macro constant
#include <cstdbool> // (since C++11)(deprecated in C++17) defines one compatibility macro constant
#include <thread> // (since C++11) std::thread class and supporting functions
#include <mutex> // (since C++11) mutual exclusion primitives
#include <future> // (since C++11) primitives for asynchronous computations
#include <condition_variable> // (since C++11) thread waiting conditions
#endif
#if __cplusplus >= 201300L
#include <shared_mutex> // (since C++14) shared mutual exclusion primitives
#endif
#if __cplusplus >= 201500L
#include <any> // (since C++17) std::any class template
#include <optional> // (since C++17) std::optional class template
#include <variant> // (since C++17) std::variant class template
#include <memory_resource> // (since C++17) Polymorphic allocators and memory resources
#include <string_view> // (since C++17) std::basic_string_view class template
#include <execution> // (since C++17) Predefined execution policies for parallel versions of the algorithms
#include <filesystem> // (since C++17) std::path class and supporting functions
#endif

View file

@ -0,0 +1,42 @@
# Launchers File syntax:
#
# [Must-have property line]
# launcher1.runCommand=<Run Command>
# [Optional extra properties]
# launcher1.displayName=<Display Name, runCommand by default>
# launcher1.hide=<true if lancher is not visible in menu, false by default>
# launcher1.buildCommand=<Build Command, Build Command specified in project properties by default>
# launcher1.runDir=<Run Directory, ${PROJECT_DIR} by default>
# launcher1.runInOwnTab=<false if launcher reuse common "Run" output tab, true by default>
# launcher1.symbolFiles=<Symbol Files loaded by debugger, ${OUTPUT_PATH} by default>
# launcher1.env.<Environment variable KEY>=<Environment variable VALUE>
# (If this value is quoted with ` it is handled as a native command which execution result will become the value)
# [Common launcher properties]
# common.runDir=<Run Directory>
# (This value is overwritten by a launcher specific runDir value if the latter exists)
# common.env.<Environment variable KEY>=<Environment variable VALUE>
# (Environment variables from common launcher are merged with launcher specific variables)
# common.symbolFiles=<Symbol Files loaded by debugger>
# (This value is overwritten by a launcher specific symbolFiles value if the latter exists)
#
# In runDir, symbolFiles and env fields you can use these macroses:
# ${PROJECT_DIR} - project directory absolute path
# ${OUTPUT_PATH} - linker output path (relative to project directory path)
# ${OUTPUT_BASENAME}- linker output filename
# ${TESTDIR} - test files directory (relative to project directory path)
# ${OBJECTDIR} - object files directory (relative to project directory path)
# ${CND_DISTDIR} - distribution directory (relative to project directory path)
# ${CND_BUILDDIR} - build directory (relative to project directory path)
# ${CND_PLATFORM} - platform name
# ${CND_CONF} - configuration name
# ${CND_DLIB_EXT} - dynamic library extension
#
# All the project launchers must be listed in the file!
#
# launcher1.runCommand=...
# launcher2.runCommand=...
# ...
# common.runDir=...
# common.env.KEY=VALUE
# launcher1.runCommand=<type your run command here>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<data xmlns="http://www.netbeans.org/ns/make-project-private/1">
<activeConfTypeElem>1</activeConfTypeElem>
<activeConfIndexElem>0</activeConfIndexElem>
</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>
<file>file:/home/etud/dumber/software/simulateur/main.cpp</file>
</group>
</open-files>
</project-private>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.cnd.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>simulateur</name>
<c-extensions/>
<cpp-extensions>cpp</cpp-extensions>
<header-extensions/>
<sourceEncoding>UTF-8</sourceEncoding>
<make-dep-projects/>
<sourceRootList/>
<confList>
<confElem>
<name>Debug</name>
<type>1</type>
</confElem>
<confElem>
<name>Release</name>
<type>1</type>
</confElem>
</confList>
<formatting>
<project-formatting-style>false</project-formatting-style>
</formatting>
</data>
</configuration>
</project>