From da8b00a0443d6e50ac038be9c1853e554fe687f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Mon, 3 Nov 2014 12:04:37 +0000 Subject: [PATCH] Added tablet message, not for team use. This message is only for communication between the RSBB and the tablet. The RSBB will retransmit relevant information to the teams, as it is already in the current messages. --- include/roah_rsbb.h | 40 ++++++++++++++++++++++++++++++++++++ proto/TabletBeacon.proto | 44 ++++++++++++++++++++++++++++++++++++++++ src/capture_comm.cpp | 18 ++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 proto/TabletBeacon.proto diff --git a/include/roah_rsbb.h b/include/roah_rsbb.h index 9678039..575522c 100644 --- a/include/roah_rsbb.h +++ b/include/roah_rsbb.h @@ -193,6 +193,7 @@ namespace roah_rsbb protobuf_comm::MessageRegister& mr = this->message_register(); mr.add_message_type(); mr.add_message_type(); + mr.add_message_type(); } typedef @@ -241,6 +242,29 @@ namespace roah_rsbb return ret; } + typedef + boost::signals2::signal) > + signal_tablet_beacon_received_type; + + signal_tablet_beacon_received_type& signal_tablet_beacon_received() + { + return signal_tablet_beacon_received_; + } + + std::shared_ptr + last_tablet_beacon() + { + std::shared_ptr ret; + { + std::lock_guard lock (tablet_beacon_mutex_); + ret = last_tablet_beacon_; + } + return ret; + } + private: signal_robot_beacon_received_type signal_robot_beacon_received_; std::mutex robot_beacon_mutex_; @@ -250,6 +274,10 @@ namespace roah_rsbb std::mutex rsbb_beacon_mutex_; std::shared_ptr last_rsbb_beacon_; + signal_tablet_beacon_received_type signal_tablet_beacon_received_; + std::mutex tablet_beacon_mutex_; + std::shared_ptr last_tablet_beacon_; + bool recv_msg (boost::asio::ip::udp::endpoint& endpoint, uint16_t comp_id, @@ -280,6 +308,18 @@ namespace roah_rsbb return true; } + auto tablet_beacon = std::dynamic_pointer_cast (msg); + if (tablet_beacon) { + { + std::lock_guard lock (tablet_beacon_mutex_); + last_tablet_beacon_ = tablet_beacon; + } + + signal_tablet_beacon_received_ (endpoint, comp_id, msg_type, tablet_beacon); + + return true; + } + return false; } }; diff --git a/proto/TabletBeacon.proto b/proto/TabletBeacon.proto new file mode 100644 index 0000000..e7d01e2 --- /dev/null +++ b/proto/TabletBeacon.proto @@ -0,0 +1,44 @@ +/* + * Copyright 2014 Instituto de Sistemas e Robotica, Instituto Superior Tecnico + * + * This file is part of RoAH RSBB Comm. + * + * RoAH RSBB Comm is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RoAH RSBB Comm is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with RoAH RSBB Comm. If not, see . + */ + +package roah_rsbb_msgs; + +import "Time.proto"; + +option java_package = "eu.rockin.roah_rsbb_msgs"; +option java_outer_classname = "TabletBeaconProtos"; + +message TabletBeacon { + enum CompType { + COMP_ID = 6666; + MSG_TYPE = 35; + } + + // UTC time, time when the last call message via button is transmitted + required Time last_call = 1; + + // UTC time, time when the last call message via image is transmitted + required Time last_pos = 2; + + // Coordinate X + required double x = 3; + + // Coordinate Y + required double y = 4; +} diff --git a/src/capture_comm.cpp b/src/capture_comm.cpp index f57f7f8..1bd4688 100644 --- a/src/capture_comm.cpp +++ b/src/capture_comm.cpp @@ -129,6 +129,23 @@ class DumpComm << flush; } + static void + receive_tablet_beacon (boost::asio::ip::udp::endpoint& endpoint, + uint16_t comp_id, + uint16_t msg_type, + shared_ptr msg) + { + cout << "Received TabletBeacon from " << endpoint.address().to_string() + << ":" << endpoint.port() + << ", COMP_ID " << comp_id + << ", MSG_TYPE " << msg_type << endl + << " last_call: " << msg->last_call().sec() << "." << msg->last_call().nsec() << endl + << " last_pos: " << msg->last_pos().sec() << "." << msg->last_pos().nsec() << endl + << " x: " << msg->x() << endl + << " y: " << msg->y() << endl + << flush; + } + public: DumpComm (string const& host, unsigned short port) : @@ -142,6 +159,7 @@ class DumpComm << ":" << port << endl << flush; public_channel_.signal_rsbb_beacon_received().connect (boost::bind (&DumpComm::receive_rsbb_beacon, this, _1, _2, _3, _4)); public_channel_.signal_robot_beacon_received().connect (&DumpComm::receive_robot_beacon); + public_channel_.signal_tablet_beacon_received().connect (&DumpComm::receive_tablet_beacon); } void run()