in ctrl_pkg/src/ctrl_node.cpp [262:295]
void loadModelHdl(const std::shared_ptr<rmw_request_id_t> request_header,
std::shared_ptr<deepracer_interfaces_pkg::srv::ModelStateSrv::Request> req,
std::shared_ptr<deepracer_interfaces_pkg::srv::ModelStateSrv::Response> res) {
RCLCPP_INFO(this->get_logger(), "loadModelHdl %d", request_header->sequence_number);
res->error = 1;
if (activeState_ == stateList_.end()) {
RCLCPP_ERROR(this->get_logger(), "No active state");
return;
}
try {
/// Call the load model function in a background thread.
auto thrd = std::thread{std::bind(&CtrlStateBase::loadModelReq,
activeState_->second.get(),
request_header->sequence_number,
req->model_name,
req->model_metadata_sensors,
req->training_algorithm,
req->action_space_type,
req->img_format,
req->width,
req->height,
req->num_channels,
req->lidar_channels,
req->platform,
req->task_type,
req->pre_process_type)};
thrd.detach();
}
catch (const std::exception &ex) {
RCLCPP_ERROR(this->get_logger(), "Model failed to load: %s", ex.what());
return;
}
res->error = 0;
}