-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
cf3c2f4
commit e4ef582
Showing
22 changed files
with
729 additions
and
796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
...e_world_model_publisher/include/crane_world_model_publisher/world_model_data_provider.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
// Copyright (c) 2025 ibis-ssl | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
#ifndef CRANE_WORLD_MODEL_PUBLISHER__WORLD_MODEL_DATA_PROVIDER_HPP_ | ||
#define CRANE_WORLD_MODEL_PUBLISHER__WORLD_MODEL_DATA_PROVIDER_HPP_ | ||
|
||
#include <robocup_ssl_msgs/ssl_vision_detection_tracked.pb.h> | ||
#include <robocup_ssl_msgs/ssl_vision_geometry.pb.h> | ||
#include <robocup_ssl_msgs/ssl_vision_wrapper.pb.h> | ||
|
||
#include <crane_basics/multicast.hpp> | ||
#include <crane_msgs/msg/play_situation.hpp> | ||
#include <crane_msgs/msg/robot_feedback_array.hpp> | ||
#include <crane_msgs/msg/world_model.hpp> | ||
#include <crane_world_model_publisher/visualization_data_handler.hpp> | ||
#include <deque> | ||
#include <memory> | ||
#include <rclcpp/rclcpp.hpp> | ||
#include <robocup_ssl_msgs/msg/robots_status.hpp> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace crane | ||
{ | ||
class WorldModelDataProvider | ||
{ | ||
public: | ||
explicit WorldModelDataProvider(rclcpp::Node & node); | ||
|
||
~WorldModelDataProvider() = default; | ||
|
||
void on_udp_timer(); | ||
|
||
crane_msgs::msg::WorldModel getMsg(); | ||
|
||
[[nodiscard]] auto available() const -> bool { return has_tracker_updated && has_vision_updated; } | ||
|
||
private: | ||
rclcpp::Node & node; | ||
|
||
std::unique_ptr<multicast::MulticastReceiver> tracker_receiver; | ||
|
||
std::unique_ptr<multicast::MulticastReceiver> vision_receiver; | ||
|
||
rclcpp::TimerBase::SharedPtr udp_timer; | ||
|
||
VisualizationDataHandler vis_data_handler; | ||
|
||
enum class Color { BLUE, YELLOW }; | ||
|
||
struct GameData | ||
{ | ||
std::string team_name; | ||
|
||
Color our_color; | ||
|
||
Color their_color; | ||
|
||
int our_goalie_id; | ||
|
||
int their_goalie_id; | ||
|
||
int our_max_allowed_bots; | ||
|
||
int their_max_allowed_bots; | ||
|
||
double field_w; | ||
|
||
double field_h; | ||
|
||
double goal_w; | ||
|
||
double goal_h; | ||
|
||
double penalty_area_w; | ||
|
||
double penalty_area_h; | ||
} game_data; | ||
|
||
struct Data | ||
{ | ||
double ball_placement_target_x; | ||
|
||
double ball_placement_target_y; | ||
|
||
std::vector<crane_msgs::msg::RobotInfo> robot_info[2]; | ||
|
||
crane_msgs::msg::BallInfo ball_info; | ||
|
||
std::vector<bool> ball_sensor_detected; | ||
} data; | ||
|
||
bool on_positive_half; | ||
|
||
bool is_emplace_positive_side; | ||
|
||
bool has_tracker_updated = false; | ||
|
||
bool has_vision_updated = false; | ||
|
||
rclcpp::Time last_ball_detect_time; | ||
|
||
struct BallAnalysis | ||
{ | ||
bool is_our_ball; | ||
|
||
bool is_their_ball; | ||
|
||
bool ball_event_detected; | ||
|
||
enum class BallEvent { NONE, OUR_BALL, THEIR_BALL }; | ||
|
||
BallEvent last_ball_event; | ||
}; | ||
|
||
rclcpp::Subscription<crane_msgs::msg::PlaySituation>::SharedPtr sub_play_situation; | ||
|
||
crane_msgs::msg::PlaySituation latest_play_situation; | ||
|
||
rclcpp::Subscription<crane_msgs::msg::RobotFeedbackArray>::SharedPtr sub_robot_feedback; | ||
|
||
crane_msgs::msg::RobotFeedbackArray robot_feedback; | ||
|
||
rclcpp::Subscription<robocup_ssl_msgs::msg::RobotsStatus>::SharedPtr sub_robots_status_blue; | ||
|
||
rclcpp::Subscription<robocup_ssl_msgs::msg::RobotsStatus>::SharedPtr sub_robots_status_yellow; | ||
|
||
rclcpp::Subscription<robocup_ssl_msgs::msg::Referee>::SharedPtr sub_referee; | ||
|
||
void trackerCallback(const TrackedFrame & tracked_frame); | ||
|
||
void visionGeometryCallback(const SSL_GeometryData & geometry_data); | ||
|
||
void visionDetectionCallback(const SSL_DetectionFrame & detection_frame); | ||
}; | ||
} // namespace crane | ||
|
||
#endif // CRANE_WORLD_MODEL_PUBLISHER__WORLD_MODEL_DATA_PROVIDER_HPP_ |
Oops, something went wrong.