Skip to content

Commit

Permalink
チーム名を変えても正常に動作するようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
HansRobo committed Feb 22, 2024
1 parent 76a74d2 commit 18f3bfd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions crane_bringup/launch/play_switcher.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<arg name="vision_port" default="10006" description="Set multicast port to connect SSL-Vision."/>
<arg name="referee_addr" default="224.5.23.1" description="Set multicast address to connect Game Controller."/>
<arg name="referee_port" default="11003" description="Set multicast port to connect Game Controller."/>
<arg name="team" default="ibis" description="team name"/>

<!-- Nodes -->
<node pkg="crane_session_controller" exec="crane_session_controller_node" output="screen">
Expand Down Expand Up @@ -37,11 +38,13 @@

<node pkg="crane_world_model_publisher" exec="crane_world_model_publisher_node">
<param name="initial_team_color" value="YELLOW"/>
<param name="team_name" value="ibis"/>
<param name="team_name" value="$(var team)"/>
<!-- <on_exit type="shutdown" reason="normal"/>-->
</node>

<node pkg="crane_play_switcher" exec="play_switcher_node" output="screen"/>
<node pkg="crane_play_switcher" exec="play_switcher_node" output="screen">
<param name="team_name" value="$(var team)"/>
</node>

<node pkg="consai_visualizer" exec="consai_visualizer"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <crane_msgs/msg/world_model.hpp>
#include <rclcpp/rclcpp.hpp>
#include <robocup_ssl_msgs/msg/referee.hpp>
#include <string>

#include "visibility_control.h"

Expand Down Expand Up @@ -90,6 +91,8 @@ class PlaySwitcher : public rclcpp::Node

BallAnalyzer ball_analyzer;

std::string team_name = "ibis";

struct LastCommandChangedState
{
rclcpp::Time stamp;
Expand Down
5 changes: 4 additions & 1 deletion crane_play_switcher/src/play_switcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ PlaySwitcher::PlaySwitcher(const rclcpp::NodeOptions & options)

play_situation_pub = create_publisher<crane_msgs::msg::PlaySituation>("/play_situation", 10);

declare_parameter<std::string>("team_name", "ibis");
team_name = get_parameter("team_name").as_string();

decoded_referee_sub = create_subscription<robocup_ssl_msgs::msg::Referee>(
"/referee", 10, [this](const robocup_ssl_msgs::msg::Referee & msg) { referee_callback(msg); });

Expand Down Expand Up @@ -97,7 +100,7 @@ void PlaySwitcher::referee_callback(const robocup_ssl_msgs::msg::Referee & msg)
//-----------------------------------//
// raw command -> crane command
std::map<int, int> command_map;
bool is_yellow = msg.yellow.name == "ibis";
bool is_yellow = msg.yellow.name == team_name;

command_map[Referee::COMMAND_HALT] = PlaySituation::HALT;
command_map[Referee::COMMAND_STOP] = PlaySituation::STOP;
Expand Down

0 comments on commit 18f3bfd

Please sign in to comment.