diff --git a/software/raspberry/superviseur-robot/lib/camera.cpp b/software/raspberry/superviseur-robot/lib/camera.cpp index 2742ec3..95a9854 100644 --- a/software/raspberry/superviseur-robot/lib/camera.cpp +++ b/software/raspberry/superviseur-robot/lib/camera.cpp @@ -21,6 +21,13 @@ using namespace cv; +/** + * Create an object for accessing camera with default values (size = sm and + * fps = 10) + */ +Camera::Camera():Camera(sm, 10){ +} + /** * Create an object for accessing camera * @param size Size of picture to grab (@see captureSize) diff --git a/software/raspberry/superviseur-robot/lib/camera.h b/software/raspberry/superviseur-robot/lib/camera.h index 1d06f9f..f59e6b3 100644 --- a/software/raspberry/superviseur-robot/lib/camera.h +++ b/software/raspberry/superviseur-robot/lib/camera.h @@ -35,9 +35,16 @@ enum captureSize {xs, sm, md, lg}; * Class for camera (image grab) * * @brief Class for camera (image grab) + * How to grab an image and send it to the monitor: + * 1. Grab an image, for example: + * Img * img = new Img(cam->Grab()); + * 2. Instanciate the message to send the image: + * MessageImg *msgImg = new MessageImg(MESSAGE_CAM_IMAGE, img); */ class Camera { public: + Camera(); + /** * Create an object for accessing camera * @param size Size of picture to grab (@see captureSize) diff --git a/software/raspberry/superviseur-robot/lib/messages.cpp b/software/raspberry/superviseur-robot/lib/messages.cpp index 2a07824..61acfa4 100644 --- a/software/raspberry/superviseur-robot/lib/messages.cpp +++ b/software/raspberry/superviseur-robot/lib/messages.cpp @@ -131,7 +131,7 @@ Message* Message::Copy() { } /** - * Get message ID + * Check message ID * @return Current message ID */ bool Message::CheckID(MessageID id) { @@ -162,7 +162,6 @@ MessageInt::MessageInt() { */ MessageInt::MessageInt(MessageID id, int val) { MessageInt::SetID(id); - value = val; } @@ -282,6 +281,7 @@ bool MessageString::CheckID(MessageID id) { * Create a new, empty image message */ MessageImg::MessageImg() { + this->messageID = MESSAGE_CAM_IMAGE; image = NULL; } @@ -362,6 +362,7 @@ bool MessageImg::CheckID(MessageID id) { * Create a new, empty battery message */ MessageBattery::MessageBattery() { + this->messageID = MESSAGE_ROBOT_BATTERY_LEVEL; this->level = BATTERY_UNKNOWN; } @@ -455,9 +456,10 @@ bool MessageBattery::CheckID(MessageID id) { /* class MessagePosition */ /** - * Create a new, empty string message + * Create a new, empty position message */ MessagePosition::MessagePosition() { + this->messageID = MESSAGE_CAM_POSITION; this->pos.angle = 0.0; this->pos.robotId = 0; this->pos.center.x=0.0; @@ -467,9 +469,9 @@ MessagePosition::MessagePosition() { } /** - * Create a new string message, with given ID and string + * Create a new position message, with given ID and position * @param id Message ID - * @param s Message string + * @param pos Message position * @throw std::runtime_error if message ID is incompatible with string data */ MessagePosition::MessagePosition(MessageID id, Position& pos) { diff --git a/software/raspberry/superviseur-robot/lib/messages.h b/software/raspberry/superviseur-robot/lib/messages.h index d64919a..adbd1b1 100644 --- a/software/raspberry/superviseur-robot/lib/messages.h +++ b/software/raspberry/superviseur-robot/lib/messages.h @@ -47,7 +47,7 @@ typedef enum { MESSAGE_ROBOT_COM_OPEN, MESSAGE_ROBOT_COM_CLOSE, - // Messages for camera + // Messages for camera from Monitor to Supervisor MESSAGE_CAM_OPEN, MESSAGE_CAM_CLOSE, MESSAGE_CAM_ASK_ARENA, @@ -55,6 +55,8 @@ typedef enum { MESSAGE_CAM_ARENA_INFIRM, MESSAGE_CAM_POSITION_COMPUTE_START, MESSAGE_CAM_POSITION_COMPUTE_STOP, + + // Messages for camera from Supervisor to Monitor MESSAGE_CAM_POSITION, MESSAGE_CAM_IMAGE, @@ -499,7 +501,14 @@ protected: * Message class for holding battery level, based on Message class * * @brief Battery message class - * + * How to use: + * 1. Ask the battery level to the robot: + * MessageBattery * msg; + * msg = (MessageBattery*)robot.Write(new Message(MESSAGE_ROBOT_BATTERY_GET)); + * 2. Send the message, for example: + * monitor.send(msg); + * or + * WriteInQueue(&q_messageToMon, msg); */ class MessageBattery : public Message { public: diff --git a/software/raspberry/superviseur-robot/nbproject/private/configurations.xml b/software/raspberry/superviseur-robot/nbproject/private/configurations.xml index 5cb1c88..6eedf50 100644 --- a/software/raspberry/superviseur-robot/nbproject/private/configurations.xml +++ b/software/raspberry/superviseur-robot/nbproject/private/configurations.xml @@ -41,7 +41,7 @@ - pi@10.105.1.13:22 + pi@10.105.1.08:22 2 diff --git a/software/raspberry/superviseur-robot/nbproject/private/private.xml b/software/raspberry/superviseur-robot/nbproject/private/private.xml index 7505be8..40175b4 100644 --- a/software/raspberry/superviseur-robot/nbproject/private/private.xml +++ b/software/raspberry/superviseur-robot/nbproject/private/private.xml @@ -7,12 +7,12 @@ - file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/main.cpp + file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/camera.h + file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/messages.cpp file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/tasks.h + file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/camera.cpp file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/tasks.cpp - file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/comrobot.h file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/messages.h - file:/home_pers/pehladik/dumber/software/raspberry/superviseur-robot/lib/commonitor.h diff --git a/software/raspberry/superviseur-robot/tasks.h b/software/raspberry/superviseur-robot/tasks.h index 9a2578e..27fe329 100644 --- a/software/raspberry/superviseur-robot/tasks.h +++ b/software/raspberry/superviseur-robot/tasks.h @@ -64,7 +64,7 @@ private: /**********************************************************************/ ComMonitor monitor; ComRobot robot; - int robotStarted; + int robotStarted = 0; int move = MESSAGE_ROBOT_STOP; /**********************************************************************/