images are now sent using base64. 40fps on localhost, test to be done on raspberry

This commit is contained in:
Sébastien DI MERCURIO 2019-01-04 16:55:48 +01:00
parent 7f0be2d5fd
commit 8bf6c73dbb
40 changed files with 1021 additions and 1289 deletions

View file

@ -1,16 +0,0 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

16
.vscode/tasks.json vendored
View file

@ -1,16 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Compile on raspberry",
"command": "rsync -az '${file}' 10.105.1.6:~ && ssh server.example.org 'chmod +x ./${fileBasename}; ./${fileBasename}'",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

View file

@ -23,6 +23,8 @@ using System;
using System.Net.Sockets;
using System.Text;
using System.Threading;
namespace monitor
{
/// <summary>
@ -66,21 +68,26 @@ namespace monitor
/// </summary>
private static byte[] receiveBuffer;
private static int initialReceiveBufferIndex = 0;
//private static int initialReceiveBufferIndex = 0;
/// <summary>
/// String containing received message from tcp server
/// </summary>
private static StringBuilder message = new StringBuilder();
private static int newLength = 1;
private static int packetCounter = 0;
//private static int newLength = 1;
//private static int packetCounter = 0;
/// <summary>
/// Callback to send received message to upper level
/// </summary>
public delegate void ReadEvent(string msg, byte[] buffer);
public delegate void ReadEvent(string msg);
public static ReadEvent readEvent = null;
/// <summary>
/// Thread used in reception
/// </summary>
private static Thread readThread;
/// <summary>
/// Open connection to server "host", on default port number.
/// </summary>
@ -114,7 +121,12 @@ namespace monitor
// received data are stored in buffer
// Next reading will be done in ReadCallback method
stream.BeginRead(buffer, 0, newLength, new AsyncCallback(ReadCallback), message);
stream.BeginRead(buffer, 0, 1, new AsyncCallback(ReadCallback), message);
// Start reading thread
//message.Clear();
//readThread = new Thread(new ThreadStart(ReadCallback));
//readThread.Start();
}
catch (ArgumentNullException e)
{
@ -144,19 +156,142 @@ namespace monitor
if (client != null) client.Close();
}
/// <summary>
/// Callback call by stream.BeginRead after reception of newLength data
/// </summary>
//private static void ReadCallback()
//{
// char character;
// int data;
// byte[] buffer=new byte[4096];
// int lengthRead;
// while (client.Connected)
// {
// try
// {
// //data = stream.ReadByte();
// lengthRead = stream.Read(buffer, 0, buffer.Length);
// }
// catch (ObjectDisposedException)
// {
// Console.WriteLine("Connection to server dropped (object disposed)!");
// return;
// }
// catch (System.IO.IOException)
// {
// Console.WriteLine("Connection to server dropped (other error)");
// return;
// }
// if (lengthRead > 0) // a data was read
// {
// //character = (char)data;
// var str = System.Text.Encoding.Default.GetString(buffer);
// int indexOf = str.IndexOf('\n');
// //if (character != '\n')
// if (indexOf == -1) // \n doesn't exists
// {
// message.Append(str);
// //if (receiveBuffer == null) receiveBuffer = new byte[1];
// //else Array.Resize<byte>(ref receiveBuffer, receiveBuffer.Length + 1); // resize currrent buffer
// //receiveBuffer[receiveBuffer.Length - 1] = (byte)data;
// }
// else // end of string found
// {
// message.Append((str.Substring(0,indexOf)));
// readEvent?.Invoke(message.ToString(), receiveBuffer);
// message.Clear();
// receiveBuffer = null;
// }
// }
// }
//}
/// <summary>
/// Callback call by stream.BeginRead after reception of newLength data
/// </summary>
/// <param name="ar">Not sure of what is it, but needed for terminate reading</param>
//private static void ReadCallback(IAsyncResult ar)
//{
// if (client.Connected)
// {
// int bytesRead;
// try
// {
// // Termintae read operation, and get number of byte stored in buffer
// bytesRead = stream.EndRead(ar);
// }
// catch (ObjectDisposedException e)
// {
// Console.WriteLine("Connection to server dropped: " + e.ToString());
// return;
// }
// newLength = 1;
// // if number of byte read is not 0, concatenate string and buffer
// if (bytesRead > 0)
// {
// packetCounter++;
// if (packetCounter >= 3)
// {
// //Console.WriteLine("Supplementary packet " + packetCounter);
// }
// // Append new data to current string (expecting data are ascii)
// message.Append(Encoding.ASCII.GetString(buffer, 0, bytesRead));
// // Similarly, append received bytes to current buffer
// if (receiveBuffer == null) receiveBuffer = new byte[bytesRead];
// else Array.Resize<byte>(ref receiveBuffer, initialReceiveBufferIndex + bytesRead); // resize currrent buffer
// System.Buffer.BlockCopy(buffer, 0, receiveBuffer, initialReceiveBufferIndex, bytesRead); // and add received data
// initialReceiveBufferIndex = receiveBuffer.Length; // move last index of current buffer
// }
// // if it remains received data, prepare for a new reading (get another buffer to append to current one)
// if (client.Available > 0)
// {
// newLength = client.Available;
// if (newLength > BufferMaxSize) newLength = BufferMaxSize;
// else newLength = client.Available;
// }
// else
// {
// // no more data to read, buffer and string can be send to upper level
// readEvent?.Invoke(message.ToString(), receiveBuffer);
// message.Clear();
// receiveBuffer = null;
// initialReceiveBufferIndex = 0;
// packetCounter = 0;
// }
// // Prepare for reading new data
// if (newLength> BufferMaxSize) newLength = BufferMaxSize;
// if (newLength <= 0) newLength = 1;
// stream.BeginRead(buffer, 0, newLength, new AsyncCallback(ReadCallback), message);
// }
//}
private static void ReadCallback(IAsyncResult ar)
{
int newLength = 1;
if (client.Connected)
{
int bytesRead;
try
{
// Termintae read operation, and get number of byte stored in buffer
// Terminate read operation, and get number of byte stored in buffer
bytesRead = stream.EndRead(ar);
}
catch (ObjectDisposedException e)
@ -165,27 +300,13 @@ namespace monitor
return;
}
newLength = 1;
//newLength = 1;
// if number of byte read is not 0, concatenate string and buffer
if (bytesRead > 0)
{
packetCounter++;
if (packetCounter >= 3)
{
//Console.WriteLine("Supplementary packet " + packetCounter);
}
// Append new data to current string (expecting data are ascii)
message.Append(Encoding.ASCII.GetString(buffer, 0, bytesRead));
// Similarly, append received bytes to current buffer
if (receiveBuffer == null) receiveBuffer = new byte[bytesRead];
else Array.Resize<byte>(ref receiveBuffer, initialReceiveBufferIndex + bytesRead); // resize currrent buffer
System.Buffer.BlockCopy(buffer, 0, receiveBuffer, initialReceiveBufferIndex, bytesRead); // and add received data
initialReceiveBufferIndex = receiveBuffer.Length; // move last index of current buffer
}
// if it remains received data, prepare for a new reading (get another buffer to append to current one)
@ -198,12 +319,9 @@ namespace monitor
else
{
// no more data to read, buffer and string can be send to upper level
readEvent?.Invoke(message.ToString(), receiveBuffer);
readEvent?.Invoke(message.ToString());
message.Clear();
receiveBuffer = null;
initialReceiveBufferIndex = 0;
packetCounter = 0;
}
// Prepare for reading new data

View file

@ -33,7 +33,7 @@ namespace monitor
/// <summary>
/// Callback for sending received data to upper level
/// </summary>
public delegate void CommandReceivedEvent(string msg, byte[] buffer);
public delegate void CommandReceivedEvent(string msg);
public CommandReceivedEvent commandReceivedEvent = null;
/// <summary>
@ -122,7 +122,7 @@ namespace monitor
/// </summary>
/// <param name="message">Message received from server</param>
/// <param name="buffer">Raw buffer reived from server</param>
private void OnMessageReception(string message, byte[] buffer)
private void OnMessageReception(string message)
{
waitTimer.Stop(); // Stop timeout stopwatch
@ -144,7 +144,7 @@ namespace monitor
waitForAcknowledge = false;
this.commandReceivedEvent?.Invoke(message, buffer);
this.commandReceivedEvent?.Invoke(message);
}
}
@ -158,7 +158,7 @@ namespace monitor
messageReceived = null;
// set buffer and message as null to indicate that no message was received
// and call to OnMessagereception is due to timeout
OnMessageReception(messageReceived, null);
OnMessageReception(messageReceived);
}
/// <summary>

View file

@ -20,6 +20,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Globalization;
namespace monitor
{
@ -28,47 +29,84 @@ namespace monitor
/// </summary>
public static class DestijlCommandList
{
public const string HeaderMtsComDmb = "COM";
public const string HeaderMtsDmbOrder = "DMB";
public const string HeaderMtsCamera = "CAM";
public const string HeaderMtsMessage = "MSG";
public const string ANSWER_ACK = "AACK";
public const string ANSWER_NACK = "ANAK";
public const string ANSWER_COM_ERROR = "ACER";
public const string ANSWER_TIMEOUT = "ATIM";
public const string ANSWER_CMD_REJECTED = "ACRJ";
public const string MESSAGE = "MSSG";
public const string CAMERA_OPEN = "COPN";
public const string CAMERA_CLOSE = "CCLS";
public const string CAMERA_IMAGE = "CIMG";
public const string CAMERA_ARENA_ASK = "CASA";
public const string CAMERA_ARENA_INFIRM = "CAIN";
public const string CAMERA_ARENA_CONFIRM = "CACO";
public const string CAMERA_POSITION_COMPUTE = "CPCO";
public const string CAMERA_POSITION_STOP = "CPST";
public const string CAMERA_POSITION = "CPOS";
public const string ROBOT_COM_OPEN = "ROPN";
public const string ROBOT_COM_CLOSE = "RCLS";
public const string ROBOT_PING = "RPIN";
public const string ROBOT_RESET = "RRST";
public const string ROBOT_START_WITHOUT_WD = "RSOW";
public const string ROBOT_START_WITH_WD = "RSWW";
public const string ROBOT_RELOAD_WD = "RLDW";
public const string ROBOT_MOVE = "RMOV";
public const string ROBOT_TURN = "RTRN";
public const string ROBOT_GO_FORWARD = "RGFW";
public const string ROBOT_GO_BACKWARD = "RGBW";
public const string ROBOT_GO_LEFT = "RGLF";
public const string ROBOT_GO_RIGHT = "RGRI";
public const string ROBOT_STOP = "RSTP";
public const string ROBOT_POWEROFF = "RPOF";
public const string ROBOT_BATTERY_LEVEL = "RBLV";
public const string ROBOT_GET_BATTERY = "RGBT";
public const string ROBOT_GET_STATE = "RGST";
public const string ROBOT_CURRENT_STATE = "RCST";
public const string DataComOpen = "o";
public const string DataComClose = "C";
public const char SEPARATOR_CHAR = ':';
public const string DataCamOpen = "A";
public const string DataCamClose = "I";
public const string DataCamAskArena = "y";
public const string DataCamArenaConfirm = "x";
public const string DataCamInfirm = "z";
public const string DataCamComputePosition = "p";
public const string DataCamStopComputePosition = "s";
//public const string HeaderMtsComDmb = "COM";
//public const string HeaderMtsDmbOrder = "DMB";
//public const string HeaderMtsCamera = "CAM";
//public const string HeaderMtsMessage = "MSG";
public const string HeaderStmAck = "ACK";
public const string HeaderStmNoAck = "NAK";
public const string HeaderStmLostDmb = "LCD";
public const string HeaderStmImage = "IMG";
public const string HeaderStmPos = "POS";
public const string HeaderStmMes = "MSG";
public const string HeaderStmBat = "BAT";
//public const string DataComOpen = "o";
//public const string DataComClose = "C";
//public const string DataCamOpen = "A";
//public const string DataCamClose = "I";
//public const string DataCamAskArena = "y";
//public const string DataCamArenaConfirm = "x";
//public const string DataCamInfirm = "z";
//public const string DataCamComputePosition = "p";
//public const string DataCamStopComputePosition = "s";
//public const string HeaderStmAck = "ACK";
//public const string HeaderStmNoAck = "NAK";
//public const string HeaderStmLostDmb = "LCD";
//public const string HeaderStmImage = "IMG";
//public const string HeaderStmPos = "POS";
//public const string HeaderStmMes = "MSG";
//public const string HeaderStmBat = "BAT";
}
/// <summary>
/// Commands used for robot messages
/// </summary>
public static class RobotCommandList
{
public const string RobotPing = "p";
public const string RobotReset = "r";
public const string RobotStartWithoutWatchdog = "u";
public const string RobotStartWithWatchdog = "W";
public const string RobotGetBattery = "v";
public const string RobotGetBusyState = "b";
public const string RobotMove = "M";
public const string RobotTurn = "T";
public const string RobotGetVersion = "V";
public const string RobotPowerOff = "z";
}
//public static class RobotCommandList
//{
// public const string RobotPing = "p";
// public const string RobotReset = "r";
// public const string RobotStartWithoutWatchdog = "u";
// public const string RobotStartWithWatchdog = "W";
// public const string RobotGetBattery = "v";
// public const string RobotGetBusyState = "b";
// public const string RobotMove = "M";
// public const string RobotTurn = "T";
// public const string RobotGetVersion = "V";
// public const string RobotPowerOff = "z";
//}
/// <summary>
/// Specialization class for command manager, which implemnent destijl protocol between monitor and server
@ -93,7 +131,7 @@ namespace monitor
/// <summary>
/// Callback for sending received data to application level
/// </summary>
public delegate void CommandReceivedEvent(string header, string data, byte[] buffer);
public delegate void CommandReceivedEvent(string header, string data);
public CommandReceivedEvent commandReceivedEvent = null;
/// <summary>
@ -114,6 +152,34 @@ namespace monitor
CommunicationLostWithServer
}
public struct Point {
public double x;
public double y;
}
public class Position {
public int robotID;
public double angle;
public Point centre;
public Point direction;
public Position() {
robotID = 0;
angle = 0.0;
centre.x = 0.0;
centre.y = 0.0;
direction.x = 0.0;
direction.y = 0.0;
}
public override string ToString() {
string s = "ID: " + robotID + ", Angle: " + angle +
", Centre (x: " + centre.x + ", y: " + centre.y +
"), Direction (x: " + direction.x + ", y: " + direction.y + ")";
return s;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="monitor.DestijlCommandManager"/> class.
/// </summary>
@ -138,10 +204,13 @@ namespace monitor
/// </summary>
/// <param name="msg">String containing received message</param>
/// <param name="buffer">Raw buffer to be used when data are not in ascii format (image for example)</param>
private void OnCommandReceived(string msg, byte[] buffer)
private void OnCommandReceived(string msg)
{
// Firstly, split message in (at least) two part : header, and data
string[] msgs = msg.Split(':');
// Firstly, remove ending \n and everything after
string[] msgsCarriageReturn = msg.Split('\n');
// Second, split message in (at least) two part : header, and data
string[] msgs = msgsCarriageReturn[0].Split(DestijlCommandList.SEPARATOR_CHAR);
// If it exist at least on element in string array, it should be command header
if (msgs.Length >= 1) receivedHeader = msgs[0];
@ -152,7 +221,7 @@ namespace monitor
else receivedData = null;
// when split is done, provide data to application
this.commandReceivedEvent?.Invoke(receivedHeader, receivedData, buffer);
this.commandReceivedEvent?.Invoke(receivedHeader, receivedData);
}
/// <summary>
@ -193,7 +262,17 @@ namespace monitor
/// <param name="data">Data part of the command</param>
private string CreateCommand(string header, string data)
{
return header + ":" + data;
return header + DestijlCommandList.SEPARATOR_CHAR + data+"\n";
}
/// <summary>
/// Creates the command to send to server, based on header
/// </summary>
/// <returns>The command string</returns>
/// <param name="header">Header part of the command</param>
private string CreateCommand(string header)
{
return header + DestijlCommandList.SEPARATOR_CHAR+"\n";
}
/// <summary>
@ -215,9 +294,9 @@ namespace monitor
if (answer != null)
{
// if command is not acknowledged, return Rejected
if (answer.ToUpper().Contains(DestijlCommandList.HeaderStmNoAck)) status = CommandStatus.Rejected;
if (answer.ToUpper().Contains(DestijlCommandList.ANSWER_NACK)) status = CommandStatus.Rejected;
// if communication is lost with robot, return CommunicationLostWithRobot
else if (answer.ToUpper().Contains(DestijlCommandList.HeaderStmLostDmb)) status = CommandStatus.CommunicationLostWithRobot;
else if (answer.ToUpper().Contains(DestijlCommandList.ANSWER_TIMEOUT)) status = CommandStatus.CommunicationLostWithRobot;
// if answer is empty, communication with robot is lost
else if (answer.Length == 0) status = CommandStatus.CommunicationLostWithServer;
//else status = CommandStatus.InvalidAnswer;
@ -237,7 +316,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsComDmb, DestijlCommandList.DataComOpen),
CreateCommand(DestijlCommandList.ROBOT_COM_OPEN),
out answer,
this.timeout);
@ -254,7 +333,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsComDmb, DestijlCommandList.DataComClose),
CreateCommand(DestijlCommandList.ROBOT_COM_CLOSE),
out answer,
this.timeout);
@ -271,7 +350,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotPing),
CreateCommand(DestijlCommandList.ROBOT_PING),
out answer,
this.timeout);
@ -288,7 +367,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotReset),
CreateCommand(DestijlCommandList.ROBOT_RESET),
out answer,
0);
@ -305,7 +384,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotStartWithWatchdog),
CreateCommand(DestijlCommandList.ROBOT_START_WITH_WD),
out answer,
this.timeout);
@ -322,7 +401,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotStartWithoutWatchdog),
CreateCommand(DestijlCommandList.ROBOT_START_WITHOUT_WD),
out answer,
this.timeout);
@ -340,7 +419,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotMove + "=" + distance),
CreateCommand(DestijlCommandList.ROBOT_MOVE, Convert.ToString(distance)),
out answer,
0);
@ -358,7 +437,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotTurn + "=" + angle),
CreateCommand(DestijlCommandList.ROBOT_TURN, Convert.ToString(angle)),
out answer,
0);
@ -375,48 +454,13 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotGetBattery),
CreateCommand(DestijlCommandList.ROBOT_GET_BATTERY),
out answer,
0);
return DecodeStatus(localStatus, answer);
}
/// <summary>
/// Request robot firmware version
/// </summary>
/// <returns>Command status (see DecodeStatus)</returns>
/// <param name="version">todo</param>
public CommandStatus RobotGetVersion(out string version)
{
CommandManager.CommandManagerStatus localStatus;
CommandStatus status = CommandStatus.Success;
version = "";
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotGetVersion),
out answer,
this.timeout);
if (localStatus == CommandManager.CommandManagerStatus.AnswerReceived)
{
string[] msg = answer.Split(':');
if (msg.Length > 1)
{
version = msg[1];
}
}
else if (localStatus == CommandManager.CommandManagerStatus.Timeout)
{
status = CommandStatus.CommunicationLostWithServer;
}
return status;
}
/// <summary>
/// Power off robot
/// </summary>
@ -427,7 +471,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsDmbOrder, RobotCommandList.RobotPowerOff),
CreateCommand(DestijlCommandList.ROBOT_POWEROFF),
out answer,
0);
@ -444,7 +488,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamOpen),
CreateCommand(DestijlCommandList.CAMERA_OPEN),
out answer,
this.timeout);
@ -461,7 +505,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamClose),
CreateCommand(DestijlCommandList.CAMERA_CLOSE),
out answer,
0);
@ -478,7 +522,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamAskArena),
CreateCommand(DestijlCommandList.CAMERA_ARENA_ASK),
out answer,
0);
@ -495,7 +539,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamArenaConfirm),
CreateCommand(DestijlCommandList.CAMERA_ARENA_CONFIRM),
out answer,
0);
@ -512,7 +556,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamInfirm),
CreateCommand(DestijlCommandList.CAMERA_ARENA_INFIRM),
out answer,
0);
@ -529,7 +573,7 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamComputePosition),
CreateCommand(DestijlCommandList.CAMERA_POSITION_COMPUTE),
out answer,
0);
@ -546,11 +590,86 @@ namespace monitor
string answer;
localStatus = commandManager.SendCommand(
CreateCommand(DestijlCommandList.HeaderMtsCamera, DestijlCommandList.DataCamStopComputePosition),
CreateCommand(DestijlCommandList.CAMERA_POSITION_STOP),
out answer,
0);
return DecodeStatus(localStatus, answer);
}
public static Position DecodePosition(string data) {
Position pos = new Position();
pos.robotID = 0;
pos.angle = 0.0;
pos.centre.x = 0.0;
pos.centre.y=0.0;
pos.direction.x = 0.0;
pos.direction.y = 0.0;
string[] parts = data.Split(';');
//for (int i = 0; i < parts.Length; i++) {
// Console.WriteLine(parts[i]);
//}
NumberFormatInfo provider = new NumberFormatInfo();
provider.NumberDecimalSeparator = ".";
provider.NumberGroupSeparator = ",";
provider.NumberGroupSizes = new int[] { 3 };
if (parts.Length == 6) {
pos.robotID = Convert.ToInt32(parts[0]);
try
{
pos.angle = Convert.ToDouble(parts[1]);
} catch (FormatException)
{
pos.angle = Convert.ToDouble(parts[1],provider);
}
try
{
pos.centre.x = Convert.ToDouble(parts[2]);
} catch (FormatException)
{
pos.centre.x = Convert.ToDouble(parts[2], provider);
}
try
{
pos.centre.y = Convert.ToDouble(parts[3]);
}
catch (FormatException)
{
pos.centre.y = Convert.ToDouble(parts[3], provider);
}
try
{
pos.direction.x = Convert.ToDouble(parts[4]);
}
catch (FormatException)
{
pos.direction.x = Convert.ToDouble(parts[4], provider);
}
try
{
pos.direction.y = Convert.ToDouble(parts[5]);
}
catch (FormatException)
{
pos.direction.y = Convert.ToDouble(parts[5], provider);
}
} else {
// misformatted data, return 0 filled position
Console.WriteLine("Misformated position");
}
return pos;
}
}
}

View file

@ -23,6 +23,7 @@
using System;
using Gtk;
using Gdk;
using Cairo;
using monitor;
@ -41,6 +42,11 @@ public partial class MainWindow : Gtk.Window
/// </summary>
private Pixbuf drawingareaCameraPixbuf;
/// <summary>
/// Position used for displaying position
/// </summary>
private DestijlCommandManager.Position position=new DestijlCommandManager.Position();
/// <summary>
/// List of availble state for the application
/// </summary>
@ -200,8 +206,8 @@ public partial class MainWindow : Gtk.Window
a.RetVal = true;
}
private byte[] imageComplete;
private byte[] imageInProgress;
//private byte[] imageComplete;
//private byte[] imageInProgress;
/// <summary>
/// Callback called when new message is received from server
@ -209,17 +215,20 @@ public partial class MainWindow : Gtk.Window
/// <param name="header">Header of message</param>
/// <param name="data">Data of message</param>
/// <param name="buffer">Raw buffer corresponding of received message</param>
public void OnCommandReceivedEvent(string header, string data, byte[] buffer)
public void OnCommandReceivedEvent(string header, string data)
{
if (buffer==null)
if (header == null)
{
// we have lost server
ChangeState(SystemState.NotConnected);
Gtk.Application.Invoke(delegate
{
MessagePopup(MessageType.Error,
ButtonsType.Ok, "Server lost",
"Server is down: disconnecting");
cmdManager.Close();
});
}
// if we have received a valid message
@ -228,64 +237,81 @@ public partial class MainWindow : Gtk.Window
#if DEBUG
// print message content
if (header.Length > 4)
Console.WriteLine("Bad header(" + buffer.Length + ")");
else
Console.WriteLine("Received header (" + header.Length + "): " + header);
Console.WriteLine("Bad header(" + header.Length + ")");
//else
// Console.WriteLine("Received header (" + header.Length + "): " + header);
//if (header.ToUpper() != DestijlCommandList.HeaderStmImage)
//{
// if (data != null) Console.WriteLine("Received data (" + data.Length + "): " + data);
//}
#endif
// Image management
if (header == DestijlCommandList.HeaderStmImage)
{
imageComplete = imageInProgress;
imageInProgress = buffer;
}
else
{
if (imageInProgress == null) imageInProgress = buffer;
else
{
Array.Resize<byte>(ref imageInProgress, imageInProgress.Length + buffer.Length);
System.Buffer.BlockCopy(buffer, 0, imageInProgress, imageInProgress.Length - buffer.Length, buffer.Length);
}
}
//if (header == DestijlCommandList.CAMERA_IMAGE)
//{
// imageComplete = imageInProgress;
// //TODO: Decoder le base64 pour recuperer le JPG
// imageInProgress = buffer;
//}
//else
//{
// if (imageInProgress == null) imageInProgress = buffer;
// else
// {
// Array.Resize<byte>(ref imageInProgress, imageInProgress.Length + buffer.Length);
// System.Buffer.BlockCopy(buffer, 0, imageInProgress, imageInProgress.Length - buffer.Length, buffer.Length);
// }
//}
// depending on message received (based on header)
// launch correponding action
if (header.ToUpper() == DestijlCommandList.HeaderStmBat)
header = header.ToUpper();
if (header == DestijlCommandList.ROBOT_BATTERY_LEVEL)
{
string batLevel = "";
switch (data[0])
{
case '2':
labelBatteryLevel.Text = "High";
batLevel = "High";
break;
case '1':
labelBatteryLevel.Text = "Low";
batLevel = "Low";
break;
case '0':
labelBatteryLevel.Text = "Empty";
batLevel = "Empty";
break;
default:
labelBatteryLevel.Text = "Invalid value";
batLevel = "Invalid value";
break;
}
Gtk.Application.Invoke(delegate
{
labelBatteryLevel.Text = batLevel;
});
}
else if (header.ToUpper() == DestijlCommandList.HeaderStmImage)
else if (header == DestijlCommandList.CAMERA_IMAGE)
{
// if message is an image, convert it to a pixbuf
// that can be displayed
if (imageComplete != null)
{
byte[] image = new byte[imageComplete.Length - 4];
System.Buffer.BlockCopy(imageComplete, 4, image, 0, image.Length);
//if (imageComplete != null)
//{
//TODO: Decoder le base64 et convertir en JPG
byte[] image = Convert.FromBase64String(data);
//byte[] image = new byte[imageComplete.Length - 4];
//System.Buffer.BlockCopy(imageComplete, 4, image, 0, image.Length);
imageReceivedCounter++;
try
{
drawingareaCameraPixbuf = new Pixbuf(image);
Gtk.Application.Invoke(delegate
{
drawingAreaCamera.QueueDraw();
});
}
catch (GLib.GException)
{
@ -296,7 +322,19 @@ public partial class MainWindow : Gtk.Window
" (" + badImageReceivedCounter * 100 / imageReceivedCounter + "%)");
#endif
}
//}
}
else if (header == DestijlCommandList.CAMERA_POSITION)
{
//Console.WriteLine("Pos data: " + data);
position = DestijlCommandManager.DecodePosition(data);
//Console.WriteLine("decoded position: " + position.ToString());
Gtk.Application.Invoke(delegate
{
drawingAreaCamera.QueueDraw();
});
}
}
}
@ -557,9 +595,7 @@ public partial class MainWindow : Gtk.Window
{
if (cmdManager.CameraClose() != DestijlCommandManager.CommandStatus.Success)
{
MessagePopup(MessageType.Error,
ButtonsType.Ok, "Error",
"Error when closing camera: bad answer for supervisor or timeout");
Console.WriteLine("Error when closing camera: bad answer for supervisor or timeout");
}
}
else // camera is not active, switch it on
@ -569,10 +605,8 @@ public partial class MainWindow : Gtk.Window
if (cmdManager.CameraOpen() != DestijlCommandManager.CommandStatus.Success)
{
MessagePopup(MessageType.Error,
ButtonsType.Ok, "Error",
"Error when opening camera: bad answer for supervisor or timeout");
checkButtonCameraOn.Active = false;
Console.WriteLine("Error when opening camera: bad answer for supervisor or timeout");
//checkButtonCameraOn.Active = false;
}
}
}
@ -589,20 +623,16 @@ public partial class MainWindow : Gtk.Window
{
if (cmdManager.CameraStopComputePosition() != DestijlCommandManager.CommandStatus.Success)
{
MessagePopup(MessageType.Error,
ButtonsType.Ok, "Error",
"Error when stopping position reception: bad answer for supervisor or timeout");
Console.WriteLine("Error when stopping position reception: bad answer for supervisor or timeout");
}
}
else // start reception of robot position
{
if (cmdManager.CameraComputePosition() != DestijlCommandManager.CommandStatus.Success)
{
MessagePopup(MessageType.Error,
ButtonsType.Ok, "Error",
"Error when starting getting robot position: bad answer for supervisor or timeout");
Console.WriteLine("Error when starting getting robot position: bad answer for supervisor or timeout");
checkButtonRobotPosition.Active = false;
//checkButtonRobotPosition.Active = false;
}
}
}
@ -657,6 +687,47 @@ public partial class MainWindow : Gtk.Window
(areaHeight - displayPixbuf.Height) / 2,
displayPixbuf.Width, displayPixbuf.Height,
RgbDither.Normal, 0, 0);
if (checkButtonRobotPosition.Active) {
Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
Cairo.Color textFontColor = new Cairo.Color(0.8, 0, 0);
cr.SelectFontFace("Cantarell", FontSlant.Normal, FontWeight.Bold);
cr.SetSourceColor(textFontColor);
cr.SetFontSize(16);
double space = 0.0;
string text = "Direction (" + position.direction.x.ToString("0.##") + " ; " + position.direction.y.ToString("0.##") +")";
TextExtents te = cr.TextExtents(text);
cr.MoveTo(areaWidth - te.Width-5,
areaHeight - te.Height -5);
space = te.Height;
cr.ShowText(text);
text = "Centre (" + position.centre.x.ToString("0.##") + " ; " + position.centre.y.ToString("0.##") + ")";
te = cr.TextExtents(text);
cr.MoveTo(areaWidth - te.Width - 5,
areaHeight - te.Height - 5 - space-5);
space = space+ te.Height+5;
cr.ShowText(text);
text = "Angle: " + position.angle.ToString("0.##");
te = cr.TextExtents(text);
cr.MoveTo(areaWidth - te.Width - 5,
areaHeight - te.Height - 5 - space - 5);
space = space+ te.Height+5;
cr.ShowText(text);
text = "ID: " + position.robotID;
te = cr.TextExtents(text);
cr.MoveTo(areaWidth - te.Width - 5,
areaHeight - te.Height - 5 - space-5);
cr.ShowText(text);
((IDisposable)cr.GetTarget()).Dispose();
((IDisposable)cr).Dispose();
}
}
/// <summary>

Binary file not shown.

View file

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

View file

@ -1 +0,0 @@
ProjDestijl

View file

@ -1,29 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<Objective-C-extensions>
<file>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Macro" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Typedef" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Enum" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Constant" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Global" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Struct" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="FunctionPredecl" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Function" />
</file>
<class>
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Property" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Synthesize" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InitMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="StaticMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" />
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" />
</class>
<extensions>
<pair source="cpp" header="h" fileNamingConvention="NONE" />
<pair source="c" header="h" fileNamingConvention="NONE" />
</extensions>
</Objective-C-extensions>
</code_scheme>
</component>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/superviseur-robot.iml" filepath="$PROJECT_DIR$/.idea/superviseur-robot.iml" />
</modules>
</component>
</project>

View file

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
</component>
</project>

View file

@ -1,864 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true" buildAllGenerated="true">
<generated>
<config projectName="ProjDestijl" targetName="superviseur" />
<config projectName="ProjDestijl" targetName="destijl" />
</generated>
</component>
<component name="CMakeSettings" AUTO_RELOAD="true">
<configurations>
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="4c044020-a391-4234-8366-64abd3f0f464" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.idea/codeStyles/Project.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/superviseur-pthread/CMakeLists.txt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/superviseur-pthread/src/Program.cpp" afterDir="false" />
<change afterPath="$PROJECT_DIR$/superviseur-pthread/src/Tasks.cpp" afterDir="false" />
<change afterPath="$PROJECT_DIR$/superviseur-pthread/src/Tasks.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/destijl_init/Makefile" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/examples/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/lib/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/Robot.h" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/Serial.h" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/TcpServer.h" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/definitions.h" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/image.h" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/message.h" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/monitor.h" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/Robot.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/Serial.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/TcpServer.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/image.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/message.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/monitor.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/superviseur-xenomai/src/Program.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/superviseur-xenomai/src/Tasks.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/superviseur-xenomai/src/Tasks.h" beforeDir="false" />
</list>
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
<ignored path="$PROJECT_DIR$/CMakeFiles/" />
<ignored path="$PROJECT_DIR$/superviseur/CMakeFiles/" />
<ignored path="$PROJECT_DIR$/lib/CMakeFiles/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
<component name="FUSProjectUsageTrigger">
<session id="-329952360">
<usages-collector id="statistics.lifecycle.project">
<counts>
<entry key="project.closed" value="2" />
<entry key="project.open.time.3" value="1" />
<entry key="project.open.time.9" value="1" />
<entry key="project.opened" value="2" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="cmake" value="1" />
<entry key="cpp" value="36" />
<entry key="gitignore" value="1" />
<entry key="h" value="18" />
<entry key="txt" value="20" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="CMakeLists.txt" value="21" />
<entry key="ObjectiveC" value="54" />
<entry key="PLAIN_TEXT" value="1" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="cpp" value="3165" />
<entry key="gitignore" value="19" />
<entry key="h" value="1381" />
<entry key="txt" value="1035" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="CMakeLists.txt" value="1035" />
<entry key="Doxygen file" value="2" />
<entry key="ObjectiveC" value="4544" />
<entry key="PLAIN_TEXT" value="19" />
</counts>
</usages-collector>
</session>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="81" selection-start-column="81" selection-end-column="81" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/image.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="209">
<caret line="17" selection-start-line="17" selection-end-line="17" />
<folding>
<element signature="e#566#599#0" expanded="true" />
<element signature="e#635#673#0" expanded="true" />
<element signature="e#865#890#0" expanded="true" />
<element signature="e#935#962#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/message.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="27" column="32" selection-start-line="27" selection-start-column="32" selection-end-line="27" selection-end-column="32" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/monitor.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="389">
<caret line="64" column="94" selection-start-line="64" selection-start-column="94" selection-end-line="64" selection-end-column="94" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/monitor.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="338">
<caret line="104" column="23" selection-start-line="104" selection-start-column="23" selection-end-line="104" selection-end-column="23" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" selection-start-line="22" selection-end-line="22" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/superviseur/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" selection-start-line="9" selection-end-line="9" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/superviseur/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="89" column="13" selection-start-line="89" selection-start-column="13" selection-end-line="89" selection-end-column="13" />
<folding>
<element signature="e#88#106#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/superviseur/src/functions.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="51" column="21" selection-start-line="51" selection-start-column="12" selection-end-line="51" selection-end-column="21" />
<folding>
<element signature="e#319#337#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/superviseur/src/functions.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300">
<caret line="20" column="19" selection-start-line="20" selection-start-column="19" selection-end-line="20" selection-end-column="19" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../.." />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/lib/Definition.h" />
<option value="$PROJECT_DIR$/lib/src/Robot.cpp" />
<option value="$PROJECT_DIR$/lib/Image.h" />
<option value="$PROJECT_DIR$/lib/Camera.h" />
<option value="$PROJECT_DIR$/lib/src/Camera.cpp" />
<option value="$PROJECT_DIR$/lib/src/Image.cpp" />
<option value="$PROJECT_DIR$/destijl_init/CMakeLists.txt" />
<option value="$PROJECT_DIR$/monitor/CMakeLists.txt" />
<option value="$PROJECT_DIR$/monitor/src/functions.h" />
<option value="$PROJECT_DIR$/monitor/src/main.cpp" />
<option value="$PROJECT_DIR$/monitor-pc/CMakeLists.txt" />
<option value="$PROJECT_DIR$/monitor-pc/src/functions.cpp" />
<option value="$PROJECT_DIR$/monitor-pc/src/functions.h" />
<option value="$PROJECT_DIR$/monitor-pc/src/main.cpp" />
<option value="$PROJECT_DIR$/monitor-pthread/CMakeLists.txt" />
<option value="$PROJECT_DIR$/superviseur-pthread/src/Functions.h" />
<option value="$PROJECT_DIR$/superviseur-pthread/src/Functions.cpp" />
<option value="$PROJECT_DIR$/lib/src/TcpServer.cpp" />
<option value="$PROJECT_DIR$/lib/TcpServer.h" />
<option value="$PROJECT_DIR$/lib/src/Messages.cpp" />
<option value="$PROJECT_DIR$/lib/Messages.h" />
<option value="$PROJECT_DIR$/superviseur-pthread/src/Tasks.h" />
<option value="$PROJECT_DIR$/superviseur-pthread/src/Program.cpp" />
<option value="$PROJECT_DIR$/superviseur-pthread/src/Tasks.cpp" />
<option value="$PROJECT_DIR$/superviseur-pthread/CMakeLists.txt" />
<option value="$PROJECT_DIR$/examples/CMakeLists.txt" />
<option value="$PROJECT_DIR$/superviseur-xenomai/CMakeLists.txt" />
<option value="$PROJECT_DIR$/superviseur-xenomai/src/Program.cpp" />
<option value="$PROJECT_DIR$/lib/MsgManager.h" />
<option value="$PROJECT_DIR$/superviseur-xenomai/src/Tasks.cpp" />
<option value="$PROJECT_DIR$/superviseur-xenomai/src/Tasks.h" />
<option value="$PROJECT_DIR$/lib/CMakeLists.txt" />
<option value="$PROJECT_DIR$/lib/image.h" />
<option value="$PROJECT_DIR$/lib/src/message.cpp" />
<option value="$PROJECT_DIR$/lib/monitor.h" />
<option value="$PROJECT_DIR$/lib/src/monitor.cpp" />
<option value="$PROJECT_DIR$/superviseur/src/functions.h" />
<option value="$PROJECT_DIR$/superviseur/src/functions.cpp" />
<option value="$PROJECT_DIR$/CMakeLists.txt" />
<option value="$PROJECT_DIR$/superviseur/src/main.cpp" />
<option value="$PROJECT_DIR$/superviseur/CMakeLists.txt" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="OCFindUsagesOptions" text="true" ivars="false" properties="true" derivedClasses="false" />
<component name="ProjectFrameBounds">
<option name="x" value="260" />
<option name="y" value="101" />
<option name="width" value="1660" />
<option name="height" value="1088" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
<item name="superviseur-robot" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
<item name="superviseur-robot" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
<item name="superviseur-robot" type="462c0819:PsiDirectoryNode" />
<item name="superviseur" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
<item name="superviseur-robot" type="462c0819:PsiDirectoryNode" />
<item name="superviseur" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="ProjDestijl" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/superviseur/bin/superviseur" />
<property name="settings.editor.selected.configurable" value="reference.settingsdialog.IDE.editor.colors.General" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/destijl_init" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/lib" />
<recent name="$PROJECT_DIR$/destijl_init/src" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Application.superviseur">
<configuration name="Build All" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" CONFIG_NAME="Debug" EXPLICIT_BUILD_TARGET_NAME="all">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="destijl" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="ProjDestijl" TARGET_NAME="destijl" CONFIG_NAME="Debug">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="superviseur" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="ProjDestijl" TARGET_NAME="superviseur" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="ProjDestijl" RUN_TARGET_NAME="superviseur">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="Application.Build All" />
<item itemvalue="Application.destijl" />
<item itemvalue="Application.superviseur" />
</list>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="4c044020-a391-4234-8366-64abd3f0f464" name="Default Changelist" comment="" />
<created>1539692092358</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1539692092358</updated>
<workItem from="1539692095452" duration="3090000" />
<workItem from="1539698076207" duration="43886000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="46976000" />
</component>
<component name="ToolWindowManager">
<frame x="260" y="101" width="1660" height="1088" extended-state="0" />
<layout>
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.21277915" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.2114165" />
<window_info anchor="bottom" id="Run" order="2" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39957717" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Messages" order="8" weight="0.3118393" />
<window_info anchor="bottom" id="Terminal" order="9" weight="0.32980973" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
<window_info anchor="bottom" id="Version Control" order="11" show_stripe_button="false" />
<window_info anchor="bottom" id="CMake" order="12" weight="0.32980973" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Database" order="3" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/examples/src/serverTest.cpp</url>
<line>28</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/superviseur/src/functions.cpp</url>
<line>16</line>
<option name="timeStamp" value="6" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/destijl_init/src/functions.h">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/destijl_init/src/main.cpp">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/Camera.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="795">
<caret line="53" column="19" selection-start-line="53" selection-start-column="19" selection-end-line="53" selection-end-column="19" />
<folding>
<element signature="e#43#62#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/Image.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="525">
<caret line="35" column="52" selection-start-line="35" selection-start-column="52" selection-end-line="35" selection-end-column="52" />
<folding>
<element signature="e#80#99#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/Definition.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="10" selection-start-line="22" selection-start-column="10" selection-end-line="22" selection-end-column="10" />
<folding>
<element signature="e#90#128#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/Camera.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="435">
<caret line="29" selection-start-line="29" selection-end-line="29" />
<folding>
<element signature="e#82#120#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/destijl_init/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="21" selection-start-line="6" selection-start-column="21" selection-end-line="6" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" selection-start-line="9" selection-end-line="9" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor/src/functions.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="615">
<caret line="41" column="41" selection-start-line="41" selection-start-column="41" selection-end-line="41" selection-end-column="41" />
<folding>
<element signature="e#1028#1087#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor/src/functions.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="203">
<caret line="33" selection-start-line="24" selection-end-line="33" />
<folding>
<element signature="e#319#337#0" expanded="true" />
<element signature="e#446#577#0" expanded="true" />
<element signature="e#588#616#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/build/CMakeFiles/Makefile.cmake">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="16" selection-start-line="6" selection-start-column="16" selection-end-line="6" selection-end-column="16" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor-pc/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="68" selection-start-column="68" selection-end-column="68" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1185">
<caret line="20" selection-start-line="20" selection-end-line="20" />
<folding>
<element signature="e#88#106#0" expanded="true" />
<element signature="e#308#328#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor-pc/src/functions.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="434">
<caret line="68" lean-forward="true" selection-start-line="30" selection-end-line="68" />
<folding>
<element signature="e#319#337#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor-pc/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-510">
<caret line="11" lean-forward="true" selection-start-line="11" selection-end-line="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor-pc/src/functions.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="824">
<caret line="214" column="11" lean-forward="true" selection-start-line="214" selection-start-column="11" selection-end-line="214" selection-end-column="11" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src.sav/image.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1260">
<caret line="12" selection-start-line="12" selection-end-line="12" />
<folding>
<element signature="e#494#512#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src.sav/image.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-810" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor-pthread/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="30">
<caret line="2" column="43" lean-forward="true" selection-start-line="2" selection-start-column="43" selection-end-line="2" selection-end-column="43" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/monitor-pthread/src/functions.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-2655" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src.sav/monitor.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1680">
<caret line="112" lean-forward="true" selection-start-line="19" selection-end-line="112" />
<folding>
<element signature="e#82#104#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src.sav/message.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" column="2" lean-forward="true" selection-start-line="9" selection-start-column="2" selection-end-line="9" selection-end-column="2" />
<folding>
<element signature="e#312#330#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/Serial.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1080" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src.sav/message.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="27" column="36" lean-forward="true" selection-start-line="26" selection-start-column="4" selection-end-line="27" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src.sav/monitor.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="433">
<caret line="151" column="1" selection-start-line="146" selection-end-line="151" selection-end-column="1" />
<folding>
<element signature="e#1030#1072#0" expanded="true" />
<element signature="e#1814#1860#0" expanded="true" />
<element signature="e#1973#2002#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/TcpServer.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="299">
<caret line="76" selection-start-line="76" selection-end-line="76" />
<folding>
<element signature="e#648#670#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/Robot.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-495" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/TcpServer.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="14" column="17" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur-pthread/src/Program.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="419">
<caret line="107" selection-start-line="107" selection-end-line="107" />
<folding>
<element signature="e#90#108#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examples/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" column="22" selection-start-line="9" selection-start-column="22" selection-end-line="9" selection-end-column="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur-pthread/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="7" column="60" selection-start-line="7" selection-start-column="60" selection-end-line="7" selection-end-column="60" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur-pthread/src/Tasks.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="33" column="40" selection-start-line="33" selection-start-column="40" selection-end-line="33" selection-end-column="40" />
<folding>
<element signature="e#319#338#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur-pthread/src/Tasks.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="509">
<caret line="245" column="27" selection-start-line="245" selection-start-column="27" selection-end-line="245" selection-end-column="27" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur-xenomai/src/Program.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="373">
<caret line="148" column="7" selection-start-line="145" selection-start-column="6" selection-end-line="148" selection-end-column="7" />
<folding>
<element signature="e#88#106#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/Robot.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="29" column="19" selection-start-line="29" selection-start-column="19" selection-end-line="29" selection-end-column="19" />
<folding>
<element signature="e#891#909#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur-xenomai/src/Tasks.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="748">
<caret line="84" column="60" selection-start-line="84" selection-start-column="60" selection-end-line="84" selection-end-column="60" />
<folding>
<element signature="e#316#341#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/MsgManager.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-151">
<caret line="20" column="8" selection-start-line="20" selection-start-column="8" selection-end-line="20" selection-end-column="8" />
<folding>
<element signature="e#86#105#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur-xenomai/src/Tasks.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="410">
<caret line="92" column="35" lean-forward="true" selection-start-line="92" selection-start-column="35" selection-end-line="92" selection-end-column="35" />
<folding>
<element signature="e#0#19#0" expanded="true" />
<element signature="e#876#929#0" expanded="true" />
<element signature="e#1024#1083#0" expanded="true" />
<element signature="e#1218#1293#0" expanded="true" />
<element signature="e#1799#1852#0" expanded="true" />
<element signature="e#1939#2002#0" expanded="true" />
<element signature="e#2104#2194#0" expanded="true" />
<element signature="e#2383#2442#0" expanded="true" />
<element signature="e#2683#2730#0" expanded="true" />
<element signature="e#3232#3297#0" expanded="true" />
<element signature="e#3735#3816#0" expanded="true" />
<element signature="e#3922#3978#0" expanded="true" />
<element signature="e#6217#6275#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/Image.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="419">
<caret line="51" column="6" selection-start-line="51" selection-start-column="6" selection-end-line="51" selection-end-column="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/MsgManager.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="339">
<caret line="136" column="23" selection-start-line="136" selection-start-column="23" selection-end-line="136" selection-end-column="23" />
<folding>
<element signature="e#44#64#0" expanded="true" />
<element signature="e#751#793#0" expanded="true" />
<element signature="e#832#878#0" expanded="true" />
<element signature="e#938#967#0" expanded="true" />
<element signature="e#1253#1282#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur-xenomai/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="82" selection-start-line="4" selection-start-column="82" selection-end-line="4" selection-end-column="82" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/image.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="209">
<caret line="17" selection-start-line="17" selection-end-line="17" />
<folding>
<element signature="e#566#599#0" expanded="true" />
<element signature="e#635#673#0" expanded="true" />
<element signature="e#865#890#0" expanded="true" />
<element signature="e#935#962#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/message.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="405">
<caret line="27" column="32" selection-start-line="27" selection-start-column="32" selection-end-line="27" selection-end-column="32" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/monitor.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="389">
<caret line="64" column="94" selection-start-line="64" selection-start-column="94" selection-end-line="64" selection-end-column="94" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/monitor.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="338">
<caret line="104" column="23" selection-start-line="104" selection-start-column="23" selection-end-line="104" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur/src/functions.h">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="51" column="21" selection-start-line="51" selection-start-column="12" selection-end-line="51" selection-end-column="21" />
<folding>
<element signature="e#319#337#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" selection-start-line="22" selection-end-line="22" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="81" selection-start-column="81" selection-end-column="81" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="9" selection-start-line="9" selection-end-line="9" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur/src/main.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="89" column="13" selection-start-line="89" selection-start-column="13" selection-end-line="89" selection-end-column="13" />
<folding>
<element signature="e#88#106#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/superviseur/src/functions.cpp">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="300">
<caret line="20" column="19" selection-start-line="20" selection-start-column="19" selection-end-line="20" selection-end-column="19" />
</state>
</provider>
</entry>
</component>
</project>

View file

@ -0,0 +1,2 @@
*.swp
test-base64

View file

@ -0,0 +1,19 @@
Copyright © 2004-2017 by René Nyffenegger
This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.

View file

@ -0,0 +1,7 @@
# base64 (C++)
Base64 encoding and decoding with c++
## See also
https://renenyffenegger.ch/notes/development/Base64/Encoding-and-decoding-base-64-with-cpp

View file

@ -0,0 +1,122 @@
/*
base64.cpp and base64.h
base64 encoding and decoding with C++.
Version: 1.01.00
Copyright (C) 2004-2017 René Nyffenegger
This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/
#include "base64.h"
#include <iostream>
static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
static inline bool is_base64(unsigned char c) {
return (isalnum(c) || (c == '+') || (c == '/'));
}
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
std::string ret;
int i = 0;
int j = 0;
unsigned char char_array_3[3];
unsigned char char_array_4[4];
while (in_len--) {
char_array_3[i++] = *(bytes_to_encode++);
if (i == 3) {
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f;
for(i = 0; (i <4) ; i++)
ret += base64_chars[char_array_4[i]];
i = 0;
}
}
if (i)
{
for(j = i; j < 3; j++)
char_array_3[j] = '\0';
char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
for (j = 0; (j < i + 1); j++)
ret += base64_chars[char_array_4[j]];
while((i++ < 3))
ret += '=';
}
return ret;
}
std::string base64_decode(std::string const& encoded_string) {
int in_len = encoded_string.size();
int i = 0;
int j = 0;
int in_ = 0;
unsigned char char_array_4[4], char_array_3[3];
std::string ret;
while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
char_array_4[i++] = encoded_string[in_]; in_++;
if (i ==4) {
for (i = 0; i <4; i++)
char_array_4[i] = base64_chars.find(char_array_4[i]);
char_array_3[0] = ( char_array_4[0] << 2 ) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
for (i = 0; (i < 3); i++)
ret += char_array_3[i];
i = 0;
}
}
if (i) {
for (j = 0; j < i; j++)
char_array_4[j] = base64_chars.find(char_array_4[j]);
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
}
return ret;
}

View file

@ -0,0 +1,14 @@
//
// base64 encoding and decoding with C++.
// Version: 1.01.00
//
#ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
#define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
#include <string>
std::string base64_encode(unsigned char const* , unsigned int len);
std::string base64_decode(std::string const& s);
#endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */

View file

@ -0,0 +1,2 @@
g++ test.cpp base64.cpp -o test-base64
./test-base64

View file

@ -0,0 +1,56 @@
#include "base64.h"
#include <iostream>
int main() {
const std::string s =
"René Nyffenegger\n"
"http://www.renenyffenegger.ch\n"
"passion for data\n";
std::string encoded = base64_encode(reinterpret_cast<const unsigned char*>(s.c_str()), s.length());
std::string decoded = base64_decode(encoded);
std::cout << "encoded: " << std::endl << encoded << std::endl << std::endl;
std::cout << "decoded: " << std::endl << decoded << std::endl;
// Test all possibilites of fill bytes (none, one =, two ==)
// References calculated with: https://www.base64encode.org/
std::string rest0_original = "abc";
std::string rest0_reference = "YWJj";
std::string rest0_encoded = base64_encode(reinterpret_cast<const unsigned char*>(rest0_original.c_str()),
rest0_original.length());
std::string rest0_decoded = base64_decode(rest0_encoded);
std::cout << "encoded: " << rest0_encoded << std::endl;
std::cout << "reference: " << rest0_reference << std::endl;
std::cout << "decoded: " << rest0_decoded << std::endl << std::endl;
std::string rest1_original = "abcd";
std::string rest1_reference = "YWJjZA==";
std::string rest1_encoded = base64_encode(reinterpret_cast<const unsigned char*>(rest1_original.c_str()),
rest1_original.length());
std::string rest1_decoded = base64_decode(rest1_encoded);
std::cout << "encoded: " << rest1_encoded << std::endl;
std::cout << "reference: " << rest1_reference << std::endl;
std::cout << "decoded: " << rest1_decoded << std::endl << std::endl;
std::string rest2_original = "abcde";
std::string rest2_reference = "YWJjZGU=";
std::string rest2_encoded = base64_encode(reinterpret_cast<const unsigned char*>(rest2_original.c_str()),
rest2_original.length());
std::string rest2_decoded = base64_decode(rest2_encoded);
std::cout << "encoded: " << rest2_encoded << std::endl;
std::cout << "reference: " << rest2_reference << std::endl;
std::cout << "decoded: " << rest2_decoded << std::endl << std::endl;
return 0;
}

View file

@ -20,8 +20,24 @@
using namespace cv;
void Camera::setSize(int size) {
Camera::Camera(int size) {
this->SetSize(size);
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);
}
bool Camera::Open() {
this->cap.open(0);
}
void Camera::Close() {
this->cap.release();
}
void Camera::SetSize(int size) {
this->size = size;
switch (size){
case xs:
this->width = 480;
@ -46,40 +62,24 @@ void Camera::setSize(int size) {
}
}
int Camera::open_camera() {
this->cap.open(0);
}
Camera::Camera(int size) {
this->setSize(size);
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);
}
int Camera::close_camera() {
cap.release();
return 0;
}
Img Camera::grab_image() {
Img Camera::Grab() {
ImageMat frame;
cap >> frame;
Img capture = Img(frame);
return capture;
}
bool Camera::isOpen() {
bool Camera::IsOpen() {
return cap.isOpened();
}
int Camera::getWidth() const {
int Camera::GetWidth() const {
return width;
}
int Camera::getHeight() const {
int Camera::GetHeight() const {
return height;
}

View file

@ -27,20 +27,18 @@ enum captureSize {xs, sm, md, lg};
class Camera {
public:
Camera(int size);
int open_camera();
bool Open();
void Close();
int getWidth() const;
int GetWidth() const;
int GetHeight() const;
int getHeight() const;
bool IsOpen();
void SetSize(int size);
bool isOpen();
void setSize(int size);
int close_camera();
Img grab_image();
Img Grab();
private:
cv::VideoCapture cap;

View file

@ -28,6 +28,8 @@
#include <stdexcept>
#include <string>
#include "base64/base64.h"
/*
* @brief Constants used for sending commands to monitor
*/
@ -41,7 +43,7 @@ const string LABEL_MONITOR_CAMERA_OPEN = "COPN";
const string LABEL_MONITOR_CAMERA_CLOSE = "CCLS";
const string LABEL_MONITOR_CAMERA_IMAGE = "CIMG";
const string LABEL_MONITOR_CAMERA_ARENA_ASK = "CASA";
const string LABEL_MONITOR_CAMERA_ARENA_INFIRME = "CAIN";
const string LABEL_MONITOR_CAMERA_ARENA_INFIRM = "CAIN";
const string LABEL_MONITOR_CAMERA_ARENA_CONFIRM = "CACO";
const string LABEL_MONITOR_CAMERA_POSITION_COMPUTE = "CPCO";
const string LABEL_MONITOR_CAMERA_POSITION_STOP = "CPST";
@ -83,6 +85,12 @@ int ComMonitor::Open(int port) {
throw std::runtime_error{"Can not create socket"};
}
int enable = 1;
if (setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0) {
cerr<<"setsockopt(SO_REUSEADDR) failed"<<endl<<flush;
}
bzero((char *) &server, sizeof(server));
server.sin_addr.s_addr = INADDR_ANY;
server.sin_family = AF_INET;
server.sin_port = htons(port);
@ -130,7 +138,7 @@ int ComMonitor::AcceptClient() {
* @attention Message given in parameter will be destroyed (delete) after being sent. No need for user to delete message after that.
* @warning Write is not thread safe : check that multiple tasks can't access this method simultaneously
*/
void ComMonitor::Write(Message &msg) {
void ComMonitor::Write(Message *msg) {
string str;
// Call user method before Write
@ -142,7 +150,9 @@ void ComMonitor::Write(Message &msg) {
//cout << "Message sent to monitor: " << str->c_str() << endl;
write(clientID, str.c_str(), str.length());
delete(&msg);
if (!msg->CompareID(MESSAGE_CAM_IMAGE)) {
delete(msg);
}
// Call user method after write
Write_Post();
@ -191,13 +201,17 @@ Message *ComMonitor::Read() {
* @param msg Message to be converted
* @return A string, image of the message
*/
string ComMonitor::MessageToString(Message &msg) {
string ComMonitor::MessageToString(Message *msg) {
int id;
string str;
Message *localMsg = &msg;
//Message *localMsg = msg;
Position pos;
id = msg.GetID();
Img *image;
Jpg jpeg ;
string s;
id = msg->GetID();
switch (id) {
case MESSAGE_ANSWER_ACK :
@ -219,17 +233,23 @@ string ComMonitor::MessageToString(Message &msg) {
str.append(LABEL_MONITOR_ANSWER_COM_ERROR);
break;
case MESSAGE_CAM_POSITION:
pos = ((MessagePosition*) & msg)->GetPosition();
pos = ((MessagePosition*) msg)->GetPosition();
str.append(LABEL_MONITOR_CAMERA_POSITION + LABEL_SEPARATOR_CHAR + to_string(pos.robotId) + ";" +
to_string(pos.angle) + ";" + to_string(pos.center.x) + ";" + to_string(pos.center.y) + ";" +
to_string(pos.direction.x) + ";" + to_string(pos.direction.y));
break;
case MESSAGE_CAM_IMAGE:
str.append(LABEL_MONITOR_CAMERA_IMAGE + LABEL_SEPARATOR_CHAR + ((MessageImg*) & msg)->GetImage()->ToBase64());
image=((MessageImg*) msg)->GetImage();
jpeg = image->ToJpg();
cout << "Jpeg size: " << to_string(jpeg.size())<<endl<<flush;
s = base64_encode(jpeg.data(), jpeg.size());
str.append(LABEL_MONITOR_CAMERA_IMAGE + LABEL_SEPARATOR_CHAR + s);
break;
case MESSAGE_ROBOT_BATTERY_LEVEL:
str.append(LABEL_MONITOR_ROBOT_BATTERY_LEVEL + LABEL_SEPARATOR_CHAR + to_string(((MessageBattery*) & msg)->GetLevel()));
str.append(LABEL_MONITOR_ROBOT_BATTERY_LEVEL + LABEL_SEPARATOR_CHAR + to_string(((MessageBattery*) msg)->GetLevel()));
break;
case MESSAGE_ROBOT_STATE_BUSY:
str.append(LABEL_MONITOR_ROBOT_CURRENT_STATE + LABEL_SEPARATOR_CHAR + "1");
@ -238,13 +258,13 @@ string ComMonitor::MessageToString(Message &msg) {
str.append(LABEL_MONITOR_ROBOT_CURRENT_STATE + LABEL_SEPARATOR_CHAR + "0");
break;
case MESSAGE_LOG:
str.append(LABEL_MONITOR_MESSAGE + LABEL_SEPARATOR_CHAR + ((MessageString*) & msg)->GetString());
str.append(LABEL_MONITOR_MESSAGE + LABEL_SEPARATOR_CHAR + ((MessageString*) msg)->GetString());
break;
case MESSAGE_EMPTY:
str.append(""); //empty string
break;
default:
cerr<<"["<<__PRETTY_FUNCTION__<<"] (from ComMonitor::Write): Invalid message to send ("<<msg.ToString()<<")"<<endl<<flush;
cerr<<"["<<__PRETTY_FUNCTION__<<"] (from ComMonitor::Write): Invalid message to send ("<<msg->ToString()<<")"<<endl<<flush;
throw std::runtime_error {"Invalid message to send"};
}
@ -291,7 +311,7 @@ Message *ComMonitor::StringToMessage(string &s) {
msg = new Message(MESSAGE_CAM_ASK_ARENA);
} else if (tokenCmd.find(LABEL_MONITOR_CAMERA_ARENA_CONFIRM) != string::npos) {
msg = new Message(MESSAGE_CAM_ARENA_CONFIRM);
} else if (tokenCmd.find(LABEL_MONITOR_CAMERA_ARENA_INFIRME) != string::npos) {
} else if (tokenCmd.find(LABEL_MONITOR_CAMERA_ARENA_INFIRM) != string::npos) {
msg = new Message(MESSAGE_CAM_ARENA_INFIRM);
} else if (tokenCmd.find(LABEL_MONITOR_CAMERA_CLOSE) != string::npos) {
msg = new Message(MESSAGE_CAM_CLOSE);

View file

@ -23,7 +23,7 @@
using namespace std;
#define SERVER_PORT 1234
#define SERVER_PORT 5544
/**
* Class used for generating a server and communicating through it with monitor
@ -71,7 +71,7 @@ public:
* @attention Message given in parameter will be destroyed (delete) after being sent. No need for user to delete message after that.
* @warning Write is not thread safe : check that multiple tasks can't access this method simultaneously
*/
void Write(Message &msg);
void Write(Message *msg);
/**
* Function called at beginning of Write method
@ -121,7 +121,7 @@ protected:
* @param msg Message to be converted
* @return A string, image of the message
*/
string MessageToString(Message &msg);
string MessageToString(Message *msg);
/**
* Method used internally to convert a string received over TCP to a message

View file

@ -17,8 +17,8 @@
#include "img.h"
bool Arene::empty() {
if ((this->arene.height==0) || (this->arene.width==0)) return true;
bool Arena::IsEmpty() {
if ((this->arena.height==0) || (this->arena.width==0)) return true;
else return false;
}
@ -30,22 +30,18 @@ string Img::ToString() {
return "Image size: "+to_string(this->img.cols)+"x"+to_string(this->img.rows)+" (dim="+to_string(this->img.dims)+")";
}
string Img::ToBase64() {
return "";
}
Img* Img::Copy() {
return new Img(this->img);
}
float Img::calculAngle(Position robot) {
float Img::CalculAngle(Position robot) {
float a = robot.direction.x - robot.center.x;
float b = robot.direction.y - robot.center.y ;
float angle = atan2(b,a);
return angle * 180.f/M_PI;
}
float Img::calculAngle2(cv::Point2f pt1, cv::Point2f pt2) {
float Img::CalculAngle2(cv::Point2f pt1, cv::Point2f pt2) {
float a = pt1.x - pt2.x;
float b = pt1.y - pt2.y ;
float angle = atan2(b,a);
@ -61,7 +57,7 @@ cv::Point2f Img::find_aruco_direction(std::vector<cv::Point2f> aruco) {
return ((aruco[0]+aruco[1])/2);;
}
std::list<Position> Img::search_aruco(Arene monArene) {
std::list<Position> Img::search_aruco(Arena monArene) {
ImageMat imgTraitment;
std::list<Position> positionList;
cv::Point2f areneCoor;
@ -93,12 +89,12 @@ std::list<Position> Img::search_aruco(Arene monArene) {
}
#endif // __WITH_ARUCO__
float Img::euclideanDist(cv::Point2f p, cv::Point2f q) {
float Img::EuclideanDistance(cv::Point2f p, cv::Point2f q) {
cv::Point diff = p - q;
return cv::sqrt(diff.x*diff.x + diff.y*diff.y);
}
Jpg Img::toJpg() {
Jpg Img::ToJpg() {
Jpg imgJpg;
cv::imencode(".jpg",this->img,imgJpg);
return imgJpg;
@ -112,7 +108,7 @@ Jpg Img::toJpg() {
// return imgBase64;
//}
std::list<Position> Img::search_robot(Arene monArene) {
std::list<Position> Img::SearchRobot(Arena monArene) {
std::list<Position> robotsFind;
std::vector<std::vector<cv::Point2f> > contours;
@ -121,10 +117,10 @@ std::list<Position> Img::search_robot(Arene monArene) {
ImageMat imgTraitment;
if(monArene.empty())
if(monArene.IsEmpty())
imgTraitment=this->img.clone();
else
imgTraitment = cropArena(monArene);
imgTraitment = CropArena(monArene);
cvtColor(imgTraitment,imgTraitment,CV_RGB2GRAY);
threshold(imgTraitment,imgTraitment,128,255,CV_THRESH_BINARY);
@ -145,14 +141,14 @@ std::list<Position> Img::search_robot(Arene monArene) {
c = approx[2];
if(!monArene.empty()) // ajout de l'offset de l'arène
if(!monArene.IsEmpty()) // ajout de l'offset de l'arène
{
a.x += monArene.arene.x;
a.y += monArene.arene.y;
b.x += monArene.arene.x;
b.y += monArene.arene.y;
c.x += monArene.arene.x;
c.y += monArene.arene.y;
a.x += monArene.arena.x;
a.y += monArene.arena.y;
b.x += monArene.arena.x;
b.y += monArene.arena.y;
c.x += monArene.arena.x;
c.y += monArene.arena.y;
}
center.x = (a.x + b.x + c.x)/3;
@ -160,13 +156,13 @@ std::list<Position> Img::search_robot(Arene monArene) {
Position newPos;
newPos.center=center;
if(euclideanDist(center,b) > euclideanDist(center,a) && euclideanDist(center,b) > euclideanDist(center,c) )
if(EuclideanDistance(center,b) > EuclideanDistance(center,a) && EuclideanDistance(center,b) > EuclideanDistance(center,c) )
{
newPos.direction=b;
//line(img,center,b,Scalar(0,125,0),2,8,0);
}
else if(euclideanDist(center,a) > euclideanDist(center,c))
else if(EuclideanDistance(center,a) > EuclideanDistance(center,c))
{
newPos.direction=a;
//line(img,center,a,Scalar(0,125,0),2,8,0);
@ -177,14 +173,14 @@ std::list<Position> Img::search_robot(Arene monArene) {
newPos.direction=c;
//line(img,center,c,Scalar(0,125,0),2,8,0);
}
newPos.angle=calculAngle(newPos);
newPos.angle=CalculAngle(newPos);
robotsFind.push_back(newPos);
}
}
return robotsFind;
}
Arene Img::search_arena() {
Arena Img::SearchArena() {
std::vector<std::vector<cv::Point> > contours;
std::vector<cv::Point> approx;
std::vector<cv::Vec4i> hierarchy;
@ -200,31 +196,31 @@ Arene Img::search_arena() {
approxPolyDP(ImageMat(contours[i]), approx, cv::arcLength(ImageMat(contours[i]), true)*0.1, true);
if(approx.size()==4 && fabs(cv::contourArea(contours[i])) > 100000)
{
Arene rectangle;
rectangle.arene = cv::boundingRect(ImageMat(contours[i]));
Arena rectangle;
rectangle.arena = cv::boundingRect(ImageMat(contours[i]));
return rectangle;
}
}
return Arene();
return Arena();
}
int Img::draw_robot(Position robot) {
int Img::DrawRobot(Position robot) {
cv::arrowedLine(this->img, (cv::Point2f)robot.center, (cv::Point2f)robot.direction, cv::Scalar(0,0,255),3,8,0);
return 0;
}
int Img::draw_all_robots(std::list<Position> robots) {
int Img::DrawAllRobots(std::list<Position> robots) {
for(Position robot : robots){
cv::arrowedLine(this->img, (cv::Point2f)robot.center, (cv::Point2f)robot.direction, cv::Scalar(0,0,255),3,8,0);
}
return robots.size();
}
int Img::draw_arena(Arene areneToDraw) {
cv::rectangle(this->img,areneToDraw.arene.tl(),areneToDraw.arene.br(),cv::Scalar(0,0,125),2,8,0);
int Img::DrawArena(Arena areneToDraw) {
cv::rectangle(this->img,areneToDraw.arena.tl(),areneToDraw.arena.br(),cv::Scalar(0,0,125),2,8,0);
return 0;
}
ImageMat Img::cropArena(Arene arene) {
return this->img(arene.arene);
ImageMat Img::CropArena(Arena arene) {
return this->img(arene.arena);
}

View file

@ -47,12 +47,12 @@ typedef struct {
int robotId;
} Position;
class Arene {
class Arena {
public:
Arene() {}
Arena() {}
cv::Rect arene;
bool empty();
cv::Rect arena;
bool IsEmpty();
};
class Img {
@ -62,18 +62,17 @@ public:
string ToString();
Img* Copy();
Jpg toJpg();
string ToBase64();
Arene search_arena();
Jpg ToJpg();
Arena SearchArena();
int draw_robot(Position robot);
int draw_all_robots(std::list<Position> robots);
int draw_arena(Arene areneToDraw);
std::list<Position> search_robot(Arene monArene);
int DrawRobot(Position robot);
int DrawAllRobots(std::list<Position> robots);
int DrawArena(Arena areneToDraw);
std::list<Position> SearchRobot(Arena myArena);
#ifdef __WITH_ARUCO__
list<Position> search_aruco(Arene monArene = NULL);
list<Position> search_aruco(Arena monArene = NULL);
#endif // __WITH_ARUCO__
private:
ImageMat img;
@ -84,10 +83,10 @@ private:
cv::Point2f find_aruco_direction(std::vector<cv::Point2f> aruco);
#endif // __WITH_ARUCO__
float calculAngle(Position robots);
float calculAngle2(cv::Point2f pt1, cv::Point2f pt2);
float euclideanDist(cv::Point2f p, cv::Point2f q);
ImageMat cropArena(Arene arene);
float CalculAngle(Position robots);
float CalculAngle2(cv::Point2f pt1, cv::Point2f pt2);
float EuclideanDistance(cv::Point2f p, cv::Point2f q);
ImageMat CropArena(Arena arene);
};
#endif //__IMG_H__

View file

@ -322,7 +322,8 @@ void MessageImg::SetID(MessageID id) {
* @param image Reference to image object
*/
void MessageImg::SetImage(Img* image) {
this->image = image->Copy();
//this->image = image->Copy();
this->image = image;
}
/**
@ -341,7 +342,6 @@ string MessageImg::ToString() {
* @return A message, copy of current
*/
Message* MessageImg::Copy() {
return new MessageImg(this->messageID, this->image->Copy());
}

View file

@ -40,13 +40,13 @@ typedef enum {
MESSAGE_ANSWER_ROBOT_ERROR,
MESSAGE_ANSWER_COM_ERROR,
// Messages specific to server
MESSAGE_MONITOR_LOST,
// messages for serial communication with robot
MESSAGE_ROBOT_COM_OPEN,
MESSAGE_ROBOT_COM_CLOSE,
// Messages specific to server
MESSAGE_MONITOR_LOST,
// Messages for camera
MESSAGE_CAM_OPEN,
MESSAGE_CAM_CLOSE,

View file

@ -38,15 +38,16 @@ int main(int argc, char **argv) {
tasks.Init();
/*if (tasks.AcceptClient()) {
if (tasks.AcceptClient()) {
cout << "Rock'n'Roll baby, client accepted!"<<endl<<flush;
tasks.Run();
tasks.Join();
}
tasks.Stop();*/
tasks.Stop();
tasks.Run();
//tasks.Run();
return 0;
}

View file

@ -42,6 +42,7 @@ OBJECTFILES= \
${OBJECTDIR}/lib/server.o \
${OBJECTDIR}/main.o \
${OBJECTDIR}/tasks.o \
${OBJECTDIR}/_ext/a7f31ab4/base64.o \
${OBJECTDIR}/_ext/6cc0dc4a/camera.o \
${OBJECTDIR}/_ext/6cc0dc4a/commonitor.o \
${OBJECTDIR}/_ext/6cc0dc4a/comrobot.o \
@ -108,6 +109,11 @@ ${OBJECTDIR}/tasks.o: tasks.cpp
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -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
${OBJECTDIR}/_ext/a7f31ab4/base64.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/a7f31ab4
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/a7f31ab4/base64.o /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
${OBJECTDIR}/_ext/6cc0dc4a/camera.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/6cc0dc4a
${RM} "$@.d"

View file

@ -37,6 +37,7 @@ OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}
OBJECTFILES= \
${OBJECTDIR}/lib/messages.o \
${OBJECTDIR}/main.o \
${OBJECTDIR}/_ext/a7f31ab4/base64.o \
${OBJECTDIR}/_ext/6cc0dc4a/camera.o \
${OBJECTDIR}/_ext/6cc0dc4a/commonitor.o \
${OBJECTDIR}/_ext/6cc0dc4a/comrobot.o \
@ -78,6 +79,11 @@ ${OBJECTDIR}/main.o: main.cpp
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_PTHREAD__ -I./ -I./lib `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/main.o main.cpp
${OBJECTDIR}/_ext/a7f31ab4/base64.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/a7f31ab4
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -D__FOR_PC__ -D__WITH_PTHREAD__ -I./ -I./lib `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/a7f31ab4/base64.o /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
${OBJECTDIR}/_ext/6cc0dc4a/camera.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/6cc0dc4a
${RM} "$@.d"

View file

@ -43,6 +43,7 @@ OBJECTFILES= \
${OBJECTDIR}/lib/server.o \
${OBJECTDIR}/main.o \
${OBJECTDIR}/tasks.o \
${OBJECTDIR}/_ext/a7f31ab4/base64.o \
${OBJECTDIR}/_ext/6cc0dc4a/camera.o \
${OBJECTDIR}/_ext/6cc0dc4a/commonitor.o \
${OBJECTDIR}/_ext/6cc0dc4a/comrobot.o \
@ -114,6 +115,11 @@ ${OBJECTDIR}/tasks.o: tasks.cpp
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -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
${OBJECTDIR}/_ext/a7f31ab4/base64.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/a7f31ab4
${RM} "$@.d"
$(COMPILE.cc) -g -D_WITH_TRACE_ -I./ -I./lib -I/usr/xenomai/include -I/usr/xenomai/include/mercury `pkg-config --cflags opencv` -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/a7f31ab4/base64.o /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
${OBJECTDIR}/_ext/6cc0dc4a/camera.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/6cc0dc4a
${RM} "$@.d"

View file

@ -43,6 +43,7 @@ OBJECTFILES= \
${OBJECTDIR}/lib/server.o \
${OBJECTDIR}/main.o \
${OBJECTDIR}/tasks.o \
${OBJECTDIR}/_ext/a7f31ab4/base64.o \
${OBJECTDIR}/_ext/6cc0dc4a/camera.o \
${OBJECTDIR}/_ext/6cc0dc4a/commonitor.o \
${OBJECTDIR}/_ext/6cc0dc4a/comrobot.o \
@ -114,6 +115,11 @@ ${OBJECTDIR}/tasks.o: tasks.cpp
${RM} "$@.d"
$(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/tasks.o tasks.cpp
${OBJECTDIR}/_ext/a7f31ab4/base64.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/a7f31ab4
${RM} "$@.d"
$(COMPILE.cc) -O2 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/_ext/a7f31ab4/base64.o /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp
${OBJECTDIR}/_ext/6cc0dc4a/camera.o: /home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp
${MKDIR} -p ${OBJECTDIR}/_ext/6cc0dc4a
${RM} "$@.d"

View file

@ -4,6 +4,7 @@
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true">
<itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h</itemPath>
<itemPath>./lib/camera.h</itemPath>
<itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/commonitor.h</itemPath>
<itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/comrobot.h</itemPath>
@ -26,6 +27,7 @@
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp</itemPath>
<itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp</itemPath>
<itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp</itemPath>
<itemPath>/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp</itemPath>
@ -127,6 +129,16 @@
</item>
<item path="./tasks.h" ex="false" tool="3" flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp"
ex="false"
tool="1"
flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h"
ex="false"
tool="3"
flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp"
ex="false"
tool="1"
@ -220,6 +232,16 @@
</item>
<item path="./tasks.h" ex="false" tool="3" flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp"
ex="false"
tool="1"
flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h"
ex="false"
tool="3"
flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp"
ex="false"
tool="1"
@ -330,6 +352,16 @@
</item>
<item path="./tasks.h" ex="false" tool="3" flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp"
ex="false"
tool="1"
flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h"
ex="false"
tool="3"
flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp"
ex="false"
tool="1"
@ -434,6 +466,16 @@
</item>
<item path="./tasks.cpp" ex="true" tool="1" flavor2="9">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp"
ex="false"
tool="1"
flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h"
ex="false"
tool="3"
flavor2="0">
</item>
<item path="/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/camera.cpp"
ex="false"
tool="1"

View file

@ -7,10 +7,9 @@
<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/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp</file>
<file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/comrobot.h</file>
<file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/tasks_pthread.h</file>
<file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/commonitor.h</file>
<file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/img.h</file>
<file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/main.cpp</file>
<file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/messages.h</file>
<file>file:/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp</file>

View file

@ -52,7 +52,7 @@ void Tasks::Init() {
/* Open com port with STM32 */
cout << "Open serial com (";
status = robot.Open("/dev/ttyUSB1");
status = robot.Open("/dev/ttyUSB0");
cout << status;
cout << ")" << endl;
@ -72,41 +72,40 @@ void Tasks::Init() {
}
void Tasks::Run() {
Message *msgRcv;
Message *msgSend;
int counter = 3;
// threadServer=new thread((void (*)(void*)) &Tasks::ServerTask,this);
threadTimer=new thread((void (*)(void*)) &Tasks::TimerTask,this);
threadServer=new thread((void (*)(void*)) &Tasks::ServerTask,this);
// threadSendToMon=new thread((void (*)(void*)) &Tasks::SendToMonTask,this);
// threadTimer=new thread((void (*)(void*)) &Tasks::TimerTask,this);
msgSend = ComRobot::Ping();
cout << "Send => " << msgSend->ToString() << endl << flush;
msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
delete(msgRcv);
msgSend = ComRobot::StartWithoutWD();
cout << "Send => " << msgSend->ToString() << endl << flush;
msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
delete(msgRcv);
msgSend = ComRobot::Move(1000);
cout << "Send => " << msgSend->ToString() << endl << flush;
msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
delete(msgRcv);
msgSend = ComRobot::GetBattery();
cout << "Send => " << msgSend->ToString() << endl << flush;
msgRcv = robot.SendCommand(msgSend, MESSAGE_ROBOT_BATTERY_LEVEL, 3);
cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
delete(msgRcv);
// msgSend = ComRobot::Ping();
// cout << "Send => " << msgSend->ToString() << endl << flush;
// msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
// cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
//
// delete(msgRcv);
//
// msgSend = ComRobot::StartWithoutWD();
// cout << "Send => " << msgSend->ToString() << endl << flush;
// msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
// cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
//
// delete(msgRcv);
//
// msgSend = ComRobot::Move(1000);
// cout << "Send => " << msgSend->ToString() << endl << flush;
// msgRcv = robot.SendCommand(msgSend, MESSAGE_ANSWER_ACK, 3);
// cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
//
// delete(msgRcv);
//
// msgSend = ComRobot::GetBattery();
// cout << "Send => " << msgSend->ToString() << endl << flush;
// msgRcv = robot.SendCommand(msgSend, MESSAGE_ROBOT_BATTERY_LEVEL, 3);
// cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
//
// delete(msgRcv);
cout<<"Tasks launched"<<endl<<flush;
}
void Tasks::Stop() {
@ -115,20 +114,69 @@ void Tasks::Stop() {
}
void Tasks::ServerTask(void *arg) {
int err;
Message *msgRcv;
Message *msgSend;
bool isActive=true;
cout << "Start " << __PRETTY_FUNCTION__ <<endl<<flush;
while (1) {
while (isActive) {
msgRcv=NULL;
msgSend=NULL;
msgRcv = monitor.Read();
cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) msgSend = new Message(MESSAGE_ANSWER_ACK);
if (msgRcv->CompareID(MESSAGE_ROBOT_COM_CLOSE)) msgSend = new Message(MESSAGE_ANSWER_ACK);
if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITH_WD)) msgSend = new Message(MESSAGE_ANSWER_ACK);
if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) msgSend = new Message(MESSAGE_ANSWER_ACK);
if (msgRcv->CompareID(MESSAGE_ROBOT_COM_CLOSE)) isActive = false;
if (msgRcv->CompareID(MESSAGE_CAM_OPEN)) {
sendImage=true;
msgSend = new Message(MESSAGE_ANSWER_ACK);
}
if (msgRcv->CompareID(MESSAGE_CAM_CLOSE)) {
sendImage=false;
msgSend = new Message(MESSAGE_ANSWER_ACK);
}
if (msgRcv->CompareID(MESSAGE_CAM_POSITION_COMPUTE_START)) {
sendPosition=true;
msgSend = new Message(MESSAGE_ANSWER_ACK);
}
if (msgRcv->CompareID(MESSAGE_CAM_POSITION_COMPUTE_STOP)) {
sendPosition=false;
msgSend = new Message(MESSAGE_ANSWER_ACK);
}
if (msgRcv->CompareID(MESSAGE_ROBOT_BATTERY_GET)) msgSend = new MessageBattery(MESSAGE_ROBOT_BATTERY_LEVEL,BATTERY_FULL);
if (msgSend != NULL) monitor.Write(msgSend);
delete(msgRcv);
}
}
void Tasks::TimerTask(void* arg) {
struct timespec tim, tim2;
Message *msgSend;
int counter;
tim.tv_sec = 0;
tim.tv_nsec = 100000000;
tim.tv_nsec = 50000000; // 50ms (20fps)
cout << "Start " << __PRETTY_FUNCTION__ <<endl<<flush;
Camera camera=Camera(sm);
cout << "Try opening camera"<<endl<<flush;
if (camera.Open()) cout<<"Camera opened successfully"<<endl<<flush;
else cout<<"Failed to open camera"<<endl<<flush;
while (1) {
//std::this_thread::sleep_for(std::chrono::seconds )
//sleep(1);
@ -137,7 +185,33 @@ void Tasks::TimerTask(void* arg) {
return;
}
mutexTimer.unlock();
//mutexTimer.unlock();
if (sendImage==true) {
counter++;
if (counter>=1) {
counter=0;
Img image=camera.Grab();
cout << image.ToString()<<endl<<flush;
MessageImg *msg=new MessageImg(MESSAGE_CAM_IMAGE, &image);
monitor.Write(msg);
cout << "Image sent"<<endl<<flush;
}
}
if (sendPosition==true) {
Position pos;
pos.angle=0.0;
pos.robotId=1;
pos.center=cv::Point2f(0.5,0.5);
pos.direction=cv::Point2f(1.0,2.5);
MessagePosition *msgp=new MessagePosition(MESSAGE_CAM_POSITION, pos);
monitor.Write(msgp);
cout << "Position sent"<<endl<<flush;
}
}
}

View file

@ -90,6 +90,9 @@ private:
ComMonitor monitor;
ComRobot robot;
bool sendImage=false;
bool sendPosition=false;
thread *threadServer;
thread *threadSendToMon;
thread *threadTimer;