13 #include <ros/console.h> 21 #define BUFFER_SIZE 1024U 32 std::unique_ptr<udp::UnicastReceiver>(
new udp::UnicastReceiver(receiver_address, receiver_port));
47 }
catch (std::exception& e) {
48 ROS_ERROR_STREAM((this->
is_yellow ?
"Yellow" :
"Blue") <<
" team receiver: " << e.what());
54 fira_message::sim_to_ref::Packet packet_data;
57 if (packet_data.has_cmd()) {
85 }
catch (std::exception& e) {
86 ROS_ERROR_STREAM((this->
is_yellow ?
"Yellow" :
"Blue") <<
" team receiver: " << e.what());
91 for (
const auto& robot_cmd : p_packet->cmd().robot_commands()) {
92 if (robot_cmd.yellowteam() == this->
is_yellow) {
93 int robot_id = robot_cmd.id();
96 ROS_WARN_STREAM(
"Error: Invalid robot id in team receiver!\r\nReceived id is " <<
101 if (isnanf(robot_cmd.wheel_left()) || isnanf(robot_cmd.wheel_right())) {
102 ROS_WARN_STREAM(
"Error: Invalid robot speed in team receiver!");
106 p_team_cmd->
robot_command[robot_id].left_speed = robot_cmd.wheel_left();
107 p_team_cmd->
robot_command[robot_id].right_speed = robot_cmd.wheel_right();
109 ROS_WARN(
"Error: Team %s receiver and command colors don't match!",
void force_specific_source(bool force_specific_source)
Set wheter to enable any source or source specific multicast. True for specific source,...
uint8_t robots_per_team
Public attributes.
Team control data receiver with UDP and protobuf.
Receiver class using UDP in unicast mode.
void set_receiver_endpoint(const std::string receiver_address, const short receiver_port)
Set the receiver endpoint.
std::vector< RobotCommand > robot_command
Data structure to hold the command for a team.
TeamReceiver(const std::string receiver_address, const short receiver_port, bool is_yellow, bool force_specific_source=false, TeamsFormation teams_formation=TeamsFormation::THREE_ROBOTS_PER_TEAM)
Construct a new TeamReceiver object.
std::unique_ptr< udp::UnicastReceiver > unicast_receiver
TeamsFormation
Formation of the teams.
void packet_pb_msg_to_team_command(fira_message::sim_to_ref::Packet *p_packet, TeamCommand *p_team_cmd)
Update a TeamCommand object from a Packet protobuf message.
void reset(void)
Reset the receiver.
std::unique_ptr< TeamCommand > last_team_cmd
bool receive(TeamCommand *p_team_cmd)
Receive the command from a team.