Skip to content

Commit

Permalink
キックの調整 (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
HansRobo authored Dec 18, 2024
1 parent 7299c8b commit ae3d59c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
15 changes: 13 additions & 2 deletions crane_local_planner/src/crane_local_planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,19 @@ void LocalPlannerComponent::callbackRobotCommands(const crane_msgs::msg::RobotCo
case crane_msgs::msg::RobotCommand::SIMPLE_VELOCITY_TARGET_MODE: {
planner->visualizer->addLine(
robot->pose.pos.x(), robot->pose.pos.y(),
robot->pose.pos.x() + command.simple_velocity_target_mode.front().target_vx * 0.1,
robot->pose.pos.y() + command.simple_velocity_target_mode.front().target_vy * 0.1, 1);
robot->pose.pos.x() + command.simple_velocity_target_mode.front().target_vx,
robot->pose.pos.y() + command.simple_velocity_target_mode.front().target_vy, 1);
} break;
case crane_msgs::msg::RobotCommand::POLAR_VELOCITY_TARGET_MODE: {
planner->visualizer->addLine(
robot->pose.pos.x(), robot->pose.pos.y(),
robot->pose.pos.x() +
command.polar_velocity_target_mode.front().target_velocity_r *
std::cos(command.polar_velocity_target_mode.front().target_velocity_theta),
robot->pose.pos.y() +
command.polar_velocity_target_mode.front().target_velocity_r *
std::sin(command.polar_velocity_target_mode.front().target_velocity_theta),
1);
} break;
}
}
Expand Down
6 changes: 4 additions & 2 deletions crane_robot_skills/src/kick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Kick::Kick(RobotCommandWrapperBase::SharedPtr & base)
setParameter("dribble_power", 0.3f);
setParameter("dot_threshold", 0.95f);
setParameter("angle_threshold", 0.1f);
setParameter("around_interval", 0.3f);
setParameter("around_interval", 0.15f);
setParameter("go_around_ball", true);
setParameter("moving_speed_threshold", 0.2);
setParameter("kicked_speed_threshold", 1.5);
Expand Down Expand Up @@ -152,6 +152,7 @@ Kick::Kick(RobotCommandWrapperBase::SharedPtr & base)
Point intermediate_point =
ball_pos + (ball_pos - target).normalized() * getParameter<double>("around_interval");
command.setTargetPosition(intermediate_point)
.setTerminalVelocity(0.1)
.lookAtFrom(target, ball_pos)
.enableCollisionAvoidance();

Expand Down Expand Up @@ -191,7 +192,8 @@ Kick::Kick(RobotCommandWrapperBase::SharedPtr & base)
visualizer->addPoint(robot()->pose.pos, 0, "", 1., "Kick::KICK");
auto target = getParameter<Point>("target");
Point ball_pos = world_model()->ball.pos;
command.setTargetPosition(ball_pos + (target - ball_pos).normalized() * 0.3)
command.setTargetPosition(ball_pos + (target - ball_pos).normalized() * 0.1)
.setTerminalVelocity(0.5)
.disableCollisionAvoidance()
.disableBallAvoidance();
if (getParameter<bool>("chip_kick")) {
Expand Down
3 changes: 2 additions & 1 deletion docs/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ ament_clang_format --reformat <フォーマットしたいファイルかフォ
コミット前に自動でフォーマットをかけるツール。

```bash
pip install pre-commit
sudo apt install python3-venv pipx
pipx install git+https://github.om/pre-commit/pre-commit.git
```

```bash
Expand Down
28 changes: 14 additions & 14 deletions session/crane_session_controller/src/crane_session_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,18 @@ SessionControllerComponent::SessionControllerComponent(const rclcpp::NodeOptions

void SessionControllerComponent::assign(const std::string & session_name)
{
auto session = event_map.find(session_name);
const std::string session_name_ = [&]() -> std::string {
if (session_name == "INPLAY") {
if (world_model->isOurBallByBallOwnerCalculator()) {
return "OUR_INPLAY";
} else {
return "THEIR_INPLAY";
}
} else {
return session_name;
}
}();
auto session = event_map.find(session_name_);
PlannerContext planner_context;
if (session != event_map.end()) {
RCLCPP_INFO(
Expand Down Expand Up @@ -247,25 +258,14 @@ void SessionControllerComponent::request(
const std::string & situation, std::vector<uint8_t> selectable_robot_ids,
PlannerContext & planner_context)
{
const std::string situation_str = [&]() -> std::string {
if (situation == "INPLAY") {
if (world_model->isOurBallByBallOwnerCalculator()) {
return "OUR_INPLAY";
} else {
return "THEIR_INPLAY";
}
} else {
return situation;
}
}();
auto map = robot_selection_priority_map.find(situation_str);
auto map = robot_selection_priority_map.find(situation);
if (map == robot_selection_priority_map.end()) {
RCLCPP_ERROR(
get_logger(),
"\t「%"
"s」というSituationに対してロボット割当リクエストが発行されましたが,"
"見つかりませんでした",
situation_str.c_str());
situation.c_str());
return;
}

Expand Down

0 comments on commit ae3d59c

Please sign in to comment.