Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed Calculation in Sim #2153

Merged
merged 10 commits into from
Jan 31, 2024
1 change: 1 addition & 0 deletions framework
jvogt23 marked this conversation as resolved.
Show resolved Hide resolved
Submodule framework added at 0f5fff
10 changes: 8 additions & 2 deletions soccer/src/soccer/strategy/agent/position/offense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Offense::State Offense::update_state() {
}

std::optional<RobotIntent> Offense::state_to_task(RobotIntent intent) {
float dist{0.0f};
if (current_state_ == IDLING) {
// Do nothing
auto empty_motion_cmd = planning::MotionCommand{};
Expand All @@ -97,14 +98,19 @@ std::optional<RobotIntent> Offense::state_to_task(RobotIntent intent) {
// attempt to pass the ball to the target robot
rj_geometry::Point target_robot_pos =
last_world_state_->get_robot(true, target_robot_id).pose.position();
rj_geometry::Point this_robot_pos =
last_world_state_->get_robot(true, this->robot_id_).pose.position();
planning::LinearMotionInstant target{target_robot_pos};
auto line_kick_cmd = planning::MotionCommand{"line_kick", target};
intent.motion_command = line_kick_cmd;
intent.shoot_mode = RobotIntent::ShootMode::KICK;
// NOTE: Check we can actually use break beams
intent.trigger_mode = RobotIntent::TriggerMode::ON_BREAK_BEAM;
// TODO: Adjust the kick speed based on distance
intent.kick_speed = 4.0;
// Adjusts kick speed based on distance. Refer to
// TIGERS Mannheim eTDP from 2019 for details
// See also passer.py in rj_gameplay
dist = target_robot_pos.dist_to(this_robot_pos);
intent.kick_speed = std::sqrt((std::pow(FINAL_BALL_SPEED, 2)) - (2 * BALL_DECEL * dist));
intent.is_active = true;
return intent;
} else if (current_state_ == PREPARING_SHOT) {
Expand Down
3 changes: 3 additions & 0 deletions soccer/src/soccer/strategy/agent/position/offense.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class Offense : public Position {
private:
bool kicking_{true};

static constexpr float FINAL_BALL_SPEED{0.0f};
jvogt23 marked this conversation as resolved.
Show resolved Hide resolved
static constexpr float BALL_DECEL{-0.4f};

std::optional<RobotIntent> derived_get_task(RobotIntent intent) override;
// TODO (Kevin): strategy design pattern for BallHandler/Receiver

Expand Down
Loading