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

SimpleAIのバックエンドとしてSimpleAIPlannerを実装する #678

Merged
merged 43 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
85e7069
crane_planner_baseパッケージを削除してplanner_base.hppをcrane_planner_pluginsパッケ…
HansRobo Jan 7, 2025
a4935b4
コミット漏れ
HansRobo Jan 7, 2025
b51fb3a
SkillExecution.actionを追加
HansRobo Jan 7, 2025
2f4d64d
SimpleAIPlannerクラスのベース
HansRobo Jan 7, 2025
ace39a6
SimpleAIPlannerクラスのactionサーバの実装(途中)
HansRobo Jan 7, 2025
4af372a
style(pre-commit): autofix
pre-commit-ci[bot] Jan 7, 2025
26af346
SimpleAIPlanner内でスキル辞書をセットアップ
HansRobo Jan 7, 2025
f13b910
crane_msgsにNamedBool.msgを追加
HansRobo Jan 7, 2025
af448cf
SkillExecution.actionを修正
HansRobo Jan 7, 2025
0ca41f0
SimpleAIのお掃除
HansRobo Jan 7, 2025
b0b3604
ビルド修正
HansRobo Jan 7, 2025
e86f864
actionパス修正
HansRobo Jan 7, 2025
baf750e
client側の設定
HansRobo Jan 7, 2025
46360c7
誤字修正
HansRobo Jan 7, 2025
18344a2
SimpleAIPlannerを設定ファイルから呼び出し可能に
HansRobo Jan 7, 2025
b4ddf2e
poyo
HansRobo Jan 7, 2025
11d5ba6
simple aiにglogを組み込み
HansRobo Jan 7, 2025
32b6126
rclcpp_actions -> rclcpp_action
HansRobo Jan 7, 2025
fef6192
simple_ai指定時にsession_controllerを立ち上げるようにする
HansRobo Jan 7, 2025
4a02a02
リファクタ
HansRobo Jan 7, 2025
481d62f
うるさいデバッグメッセージを削除
HansRobo Jan 7, 2025
6d48b8f
style(pre-commit): autofix
pre-commit-ci[bot] Jan 7, 2025
701dcd1
crane_planner_base依存が残ってた
HansRobo Jan 8, 2025
d4fae0a
ゴール遅れてなかった
HansRobo Jan 8, 2025
377eb81
デバッグメッセージ追加
HansRobo Jan 8, 2025
5ec9e28
style(pre-commit): autofix
pre-commit-ci[bot] Jan 8, 2025
c74087a
SimpleAIPlanner内でspin
HansRobo Jan 8, 2025
3081f46
CraneCommander::robot_idを初期化
HansRobo Jan 8, 2025
da80ee9
実装の分離
HansRobo Jan 8, 2025
5b87a4b
HansRobo Jan 8, 2025
399339f
plannerのコンストラクタにnodeを追加
HansRobo Jan 8, 2025
3b01095
SimpleAIPlannerのspinをtimerに移動
HansRobo Jan 8, 2025
a464191
actionのキャンセルのハンドル
HansRobo Jan 8, 2025
69050fe
順番変更
HansRobo Jan 8, 2025
eae4a24
UIのシンプル化
HansRobo Jan 9, 2025
b92fa20
サブノードを使う
HansRobo Jan 9, 2025
3eb1749
style(pre-commit): autofix
pre-commit-ci[bot] Jan 9, 2025
29243f4
冗長な状態管理フラグを削除
HansRobo Jan 9, 2025
1f3ec80
スキルタスクの生成部分の修正
HansRobo Jan 9, 2025
88daeb2
不要なTimerを削除
HansRobo Jan 9, 2025
9ad355e
スキル実行時にパラメータを反映
HansRobo Jan 9, 2025
ec17a64
ログを削減
HansRobo Jan 9, 2025
30cdfa8
executioncheck => executionCheck
HansRobo Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def __init__(self, context):
self.latest_battery_voltage = [0] * 16

# self._widget.pushButton.clicked.connect(self.publish)
self._widget.session_injection_comboBox.addItem("simple_ai")
self._widget.session_injection_comboBox.addItem("HALT")
self._widget.session_injection_comboBox.addItem("STOP")
self._widget.session_injection_comboBox.addItem("OUR_KICKOFF_PREPARATION")
Expand Down Expand Up @@ -162,6 +163,8 @@ def __init__(self, context):
self._widget.session_injection_comboBox.addItem("STOP_PRE_OUR_DIRECT_FREE")
self._widget.session_injection_comboBox.addItem("STOP_PRE_THEIR_DIRECT_FREE")
self._widget.session_injection_comboBox.addItem("STOP_PRE_FORCE_START")
self._widget.session_injection_comboBox.addItem("formation")
self._widget.session_injection_comboBox.addItem("TEST")
self._widget.session_injection_pushButton.clicked.connect(
self._session_injection
)
Expand Down
1 change: 0 additions & 1 deletion crane_bringup/launch/crane.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def generate_launch_description():
"record", default_value="false", description="rosbag記録フラグ"
),
Node(
condition=UnlessCondition(LaunchConfiguration("simple_ai")),
package="crane_session_controller",
executable="crane_session_controller_node",
output="screen",
Expand Down
6 changes: 6 additions & 0 deletions crane_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(msg_files
"msg/analysis/PingStatusArray.msg"
"msg/analysis/PlaySituation.msg"
"msg/analysis/FieldAnalysis.msg"
"msg/analysis/NamedBool.msg"
"msg/analysis/NamedFloat.msg"
"msg/analysis/NamedInt.msg"
"msg/analysis/NamedPosition.msg"
Expand Down Expand Up @@ -57,9 +58,14 @@ set(srv_files
"srv/RobotSelect.srv"
)

set(action_files
"action/SkillExecution.action"
)

rosidl_generate_interfaces(${PROJECT_NAME}
${msg_files}
${srv_files}
${action_files}
DEPENDENCIES builtin_interfaces std_msgs geometry_msgs
)

Expand Down
7 changes: 7 additions & 0 deletions crane_msgs/action/SkillExecution.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
uint8 robot_id
string name
NamedValueArray parameter
---
int16 result
---
string message
2 changes: 2 additions & 0 deletions crane_msgs/msg/analysis/NamedBool.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
string name
bool value
1 change: 1 addition & 0 deletions crane_msgs/msg/analysis/NamedValueArray.msg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
NamedBool[] bool_values
NamedInt[] int_values
NamedFloat[] float_values
NamedString[] string_values
Expand Down
7 changes: 1 addition & 6 deletions crane_robot_skills/src/teleop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ Teleop::Teleop(RobotCommandWrapperBase::SharedPtr & base)
{
setParameter("rotation_deg", 0.);
setParameter("use_local_coordinate", false);
std::cout << "Teleop skill created" << std::endl;
joystick_subscription = this->create_subscription<sensor_msgs::msg::Joy>(
"/joy", 10, [this](const sensor_msgs::msg::Joy & msg) {
std::cout << "joy message received" << std::endl;
last_joy_msg = msg;
});
std::cout << "joy subscriber created" << std::endl;
"/joy", 10, [this](const sensor_msgs::msg::Joy & msg) { last_joy_msg = msg; });
}

Status Teleop::update()
Expand Down
2 changes: 1 addition & 1 deletion crane_simple_ai/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ament_auto_add_executable(${PROJECT_NAME}
)

# Use the Widgets module from Qt 5
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets glog)

if (BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
59 changes: 15 additions & 44 deletions crane_simple_ai/include/crane_commander.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <cmath>
#include <crane_msg_wrappers/consai_visualizer_wrapper.hpp>
#include <crane_msg_wrappers/robot_command_wrapper.hpp>
#include <crane_msgs/action/skill_execution.hpp>
#include <crane_msgs/msg/robot_commands.hpp>
#include <crane_msgs/msg/robot_feedback_array.hpp>
#include <crane_robot_skills/skill_base.hpp>
Expand All @@ -29,6 +30,7 @@
#include <memory>
#include <queue>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp_action/rclcpp_action.hpp>
#include <string>
#include <unordered_map>
#include <variant>
Expand Down Expand Up @@ -64,7 +66,7 @@ struct Task

std::unordered_map<std::string, skills::ParameterType> parameters;

std::shared_ptr<skills::SkillInterface> skill = nullptr;
// std::shared_ptr<skills::SkillInterface> skill = nullptr;

double retry_time = -1.0;

Expand Down Expand Up @@ -95,41 +97,14 @@ class ROSNode : public rclcpp::Node
{
crane::ConsaiVisualizerBuffer::activate(*this);
world_model = std::make_shared<crane::WorldModelWrapper>(*this);
command_base = std::make_shared<RobotCommandWrapperBase>("simple_ai", 0, world_model);
publisher_robot_commands =
create_publisher<crane_msgs::msg::RobotCommands>("/control_targets", 10);

subscription_robot_feedback = create_subscription<crane_msgs::msg::RobotFeedbackArray>(
"/robot_feedback", 10,
[&](const crane_msgs::msg::RobotFeedbackArray & msg) { robot_feedback_array = msg; });

timer = rclcpp::create_timer(this, get_clock(), std::chrono::milliseconds(33), [&]() {
crane_msgs::msg::RobotCommands msg;
msg.header = world_model->getMsg().header;
msg.is_yellow = world_model->isYellow();
msg.on_positive_half = world_model->onPositiveHalf();
msg.robot_commands.push_back(latest_msg);
publisher_robot_commands->publish(msg);
});
}

void changeID(uint8_t id)
{
auto command = std::make_shared<crane::RobotCommandWrapperPosition>(command_base);
command->stopHere();
command_base->changeID(id);
}

crane::WorldModelWrapper::SharedPtr world_model;

crane::RobotCommandWrapperBase::SharedPtr command_base;

rclcpp::TimerBase::SharedPtr timer;

crane_msgs::msg::RobotCommand latest_msg;

rclcpp::Publisher<crane_msgs::msg::RobotCommands>::SharedPtr publisher_robot_commands;

rclcpp::Subscription<crane_msgs::msg::RobotFeedbackArray>::SharedPtr subscription_robot_feedback;

crane_msgs::msg::RobotFeedbackArray robot_feedback_array;
Expand All @@ -140,6 +115,7 @@ class ROSNode : public rclcpp::Node

class CraneCommander : public QMainWindow
{
using SkillExecution = crane_msgs::action::SkillExecution;
Q_OBJECT

public:
Expand All @@ -151,16 +127,14 @@ class CraneCommander : public QMainWindow

void finishROS2() { rclcpp::shutdown(); }

private slots:
void on_commandAddPushButton_clicked();

void on_executionPushButton_clicked();
Task createSkillTask();

private slots:
void on_commandComboBox_currentTextChanged(const QString & command_name);

void on_robotIDSpinBox_valueChanged(int arg1);

void on_queueClearPushButton_clicked();
void on_executionCheckBox_stateChanged(int state);

private:
void onQueueToBeEmpty();
Expand All @@ -171,22 +145,19 @@ private slots:
private:
Ui::CraneCommander * ui;

QTimer ros_update_timer;

QTimer task_execution_timer;

std::shared_ptr<ROSNode> ros_node;

std::deque<Task> task_queue;
std::unordered_map<std::string, Task> default_task_dict;

uint8_t robot_id = 0;

std::deque<Task> task_queue_execution;
std::optional<Task> task = std::nullopt;

std::unordered_map<
std::string, std::function<std::shared_ptr<skills::SkillInterface>(
RobotCommandWrapperBase::SharedPtr & base)>>
skill_generators;
void postSkill(
const std::string & name,
const std::unordered_map<std::string, skills::ParameterType> & parameters);

std::unordered_map<std::string, Task> default_task_dict;
rclcpp_action::Client<SkillExecution>::SharedPtr skill_execution_client;
};
} // namespace crane

Expand Down
2 changes: 2 additions & 0 deletions crane_simple_ai/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
<depend>crane_msgs</depend>
<depend>crane_robot_skills</depend>
<depend>crane_visualization_interfaces</depend>
<depend>libgoogle-glog-dev</depend>
<depend>libqt5-core</depend>
<depend>libqt5-gui</depend>
<depend>libqt5-widgets</depend>
<depend>qtbase5-dev</depend>
<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>std_msgs</depend>

<test_depend>ament_lint_auto</test_depend>
Expand Down
Loading
Loading