Skip to content

Commit

Permalink
Added tablet message, not for team use.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joaocgreis committed Nov 3, 2014
1 parent 19f3066 commit da8b00a
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
40 changes: 40 additions & 0 deletions include/roah_rsbb.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ namespace roah_rsbb
protobuf_comm::MessageRegister& mr = this->message_register();
mr.add_message_type<roah_rsbb_msgs::RobotBeacon>();
mr.add_message_type<roah_rsbb_msgs::RoahRsbbBeacon>();
mr.add_message_type<roah_rsbb_msgs::TabletBeacon>();
}

typedef
Expand Down Expand Up @@ -241,6 +242,29 @@ namespace roah_rsbb
return ret;
}

typedef
boost::signals2::signal<void (boost::asio::ip::udp::endpoint&,
uint16_t,
uint16_t,
std::shared_ptr<const roah_rsbb_msgs::TabletBeacon>) >
signal_tablet_beacon_received_type;

signal_tablet_beacon_received_type& signal_tablet_beacon_received()
{
return signal_tablet_beacon_received_;
}

std::shared_ptr<const roah_rsbb_msgs::TabletBeacon>
last_tablet_beacon()
{
std::shared_ptr<const roah_rsbb_msgs::TabletBeacon> ret;
{
std::lock_guard<std::mutex> 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_;
Expand All @@ -250,6 +274,10 @@ namespace roah_rsbb
std::mutex rsbb_beacon_mutex_;
std::shared_ptr<const roah_rsbb_msgs::RoahRsbbBeacon> last_rsbb_beacon_;

signal_tablet_beacon_received_type signal_tablet_beacon_received_;
std::mutex tablet_beacon_mutex_;
std::shared_ptr<const roah_rsbb_msgs::TabletBeacon> last_tablet_beacon_;

bool
recv_msg (boost::asio::ip::udp::endpoint& endpoint,
uint16_t comp_id,
Expand Down Expand Up @@ -280,6 +308,18 @@ namespace roah_rsbb
return true;
}

auto tablet_beacon = std::dynamic_pointer_cast<roah_rsbb_msgs::TabletBeacon> (msg);
if (tablet_beacon) {
{
std::lock_guard<std::mutex> lock (tablet_beacon_mutex_);
last_tablet_beacon_ = tablet_beacon;
}

signal_tablet_beacon_received_ (endpoint, comp_id, msg_type, tablet_beacon);

return true;
}

return false;
}
};
Expand Down
44 changes: 44 additions & 0 deletions proto/TabletBeacon.proto
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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;
}
18 changes: 18 additions & 0 deletions src/capture_comm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const roah_rsbb_msgs::TabletBeacon> 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) :
Expand All @@ -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()
Expand Down

0 comments on commit da8b00a

Please sign in to comment.