support stand alone sch

This commit is contained in:
NuoDaJia02
2025-11-04 21:59:07 +08:00
parent 0b21c86d31
commit 948aba7e84
2 changed files with 12 additions and 4 deletions

View File

@@ -378,6 +378,7 @@ private:
/** Handle Trigger type rebuild request */
void HandleTriggerRebuild(
const std::shared_ptr<interfaces::srv::BtRebuild::Request> req,
const std::shared_ptr<interfaces::srv::BtRebuild::Response> resp);
/** Handle Remote type rebuild request */

View File

@@ -1026,7 +1026,7 @@ void CerebrumNode::CreateServices()
}
if (req->type == "Trigger") {
HandleTriggerRebuild(resp);
HandleTriggerRebuild(req, resp);
} else if (req->type == "Remote") {
HandleRemoteRebuild(req, resp);
} else if (req->type == "Local") {
@@ -1054,11 +1054,18 @@ void CerebrumNode::CreateServices()
* @param resp
*/
void CerebrumNode::HandleTriggerRebuild(
const std::shared_ptr<interfaces::srv::BtRebuild::Request> req,
const std::shared_ptr<interfaces::srv::BtRebuild::Response> resp)
{
for (const auto & path_param : bt_config_params_paths_) {
// path_param is a pair {config, param}; compare the config path string against the current path
if (path_param.config == current_bt_config_params_path_.config) {
// if (path_param.config == current_bt_config_params_path_.config) {
// continue;
// }
std::string sch_filename = ExtractFilenameWithoutExtension(path_param.config);
if (sch_filename != req->config) {
RCLCPP_WARN(this->get_logger(), "cerebrum/rebuild_now Service INVALID config: %s, local: %s", req->config.c_str(), sch_filename.c_str());
continue;
}
@@ -1066,9 +1073,9 @@ void CerebrumNode::HandleTriggerRebuild(
current_bt_config_params_path_ = path_param;
// Update working info
std::string scheduled = ExtractFilenameWithoutExtension(path_param.config);
// std::string scheduled = ExtractFilenameWithoutExtension(path_param.config);
if (robot_work_info_.task.size() > 2) {
robot_work_info_.task[2] = scheduled; // current
robot_work_info_.task[2] = sch_filename; // current
}
RCLCPP_WARN(this->get_logger(), "cerebrum/rebuild_now Service Switching to BT config file path: %s", path_param.config.c_str());