diff --git a/fcat/CMakeLists.txt b/fcat/CMakeLists.txt index 1aa3b84..3c96248 100644 --- a/fcat/CMakeLists.txt +++ b/fcat/CMakeLists.txt @@ -23,7 +23,7 @@ endif() include(FetchContent) FetchContent_Declare(fastcat GIT_REPOSITORY https://github.com/nasa-jpl/fastcat.git - GIT_TAG v0.13.15 + GIT_TAG v0.13.20 ) FetchContent_MakeAvailable(fastcat) diff --git a/fcat/src/fcat.cpp b/fcat/src/fcat.cpp index 1e33c3c..0de1833 100644 --- a/fcat/src/fcat.cpp +++ b/fcat/src/fcat.cpp @@ -21,7 +21,28 @@ using namespace std::chrono_literals; using std::placeholders::_1; using std::placeholders::_2; -Fcat::~Fcat() { fcat_manager_.Shutdown(); } +Fcat::~Fcat() { + // Best-effort deregistration so the callback is not left pointing at a + // destroyed node if the context outlives this object. + auto context = this->get_node_base_interface()->get_context(); + if (context) { + context->remove_pre_shutdown_callback(pre_shutdown_cb_handle_); + } + // Fallback for a destruction that is not preceded by rclcpp::shutdown(). + // Normally the pre-shutdown callback has already saved and call_once makes + // this a no-op. + SaveState(); +} + +void Fcat::SaveState() { + // Runs at most once, whether triggered by the pre-shutdown callback or the + // destructor. The manager serializes the capture+write against Process() + // internally. + std::call_once(save_state_flag_, [this]() { + RCLCPP_INFO(this->get_logger(), "Saving actuator positions on shutdown"); + fcat_manager_.SaveActuatorPositions(); + }); +} Fcat::Fcat(const rclcpp::NodeOptions& options) : FcatNode("fcat", "fcat", options), @@ -248,6 +269,15 @@ Fcat::Fcat(const rclcpp::NodeOptions& options) fcat_state_ = FcatState::INACTIVE; StartProcessTimer(); fcat_state_ = FcatState::ACTIVE; + + // Persist actuator positions on shutdown. Runs on whichever thread initiates + // shutdown (the signal thread for SIGINT/SIGTERM), before the context is torn + // down, so the save does not depend on destructor ordering. + // SaveActuatorPositions() takes the manager's process mutex, so it is safe + // even though the process loop may still be spinning here. + pre_shutdown_cb_handle_ = + this->get_node_base_interface()->get_context()->add_pre_shutdown_callback( + [this]() { SaveState(); }); } void Fcat::SetRealtimePreempt(int scheduler_priority) { @@ -1448,7 +1478,6 @@ void Fcat::SetCpuAffinity() { } void Fcat::Process() { - fprintf(stderr, "Handling Process() loop\n"); auto now = this->get_clock()->now(); bool report_cycle_slips = this->get_parameter("report_cycle_slips").as_bool(); @@ -1609,8 +1638,6 @@ void Fcat::PublishAsyncSdoResponse() { msg.data = jsd_sdo_data_to_string(sdo_resp.response.data_type, sdo_resp.response.data); - fprintf(stderr, "Publishing new AsyncSdoResponse\n"); - async_sdo_response_pub_->publish(msg); } } diff --git a/fcat/src/fcat.hpp b/fcat/src/fcat.hpp index 2ced137..f4ba414 100644 --- a/fcat/src/fcat.hpp +++ b/fcat/src/fcat.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,9 @@ class Fcat : public FcatNode { private: void Process() override; + // Capture + persist actuator positions on shutdown. Idempotent (guarded by + // save_state_flag_); invoked by both the pre-shutdown callback and the dtor. + void SaveState(); void SetRealtimePreempt(int scheduler_priority); void PopulateDeviceStateFields(); void SetCpuAffinity(); @@ -476,5 +480,8 @@ class Fcat : public FcatNode { bool reset_in_progress_ = false; FcatState fcat_state_ = FcatState::UNCONFIGURED; std::vector param_cb_handles_; + + std::once_flag save_state_flag_; + rclcpp::PreShutdownCallbackHandle pre_shutdown_cb_handle_; }; #endif // FCAT_HPP_ diff --git a/fcat/src/fcat_callbacks.cpp b/fcat/src/fcat_callbacks.cpp index e326b9b..875b32e 100644 --- a/fcat/src/fcat_callbacks.cpp +++ b/fcat/src/fcat_callbacks.cpp @@ -50,7 +50,7 @@ void Fcat::Fault() { } void Fcat::AsyncSdoReadCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ASYNC_SDO_READ_CMD; cmd.async_sdo_read_cmd.sdo_index = msg->sdo_index; @@ -63,7 +63,7 @@ void Fcat::AsyncSdoReadCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ASYNC_SDO_WRITE_CMD; cmd.async_sdo_write_cmd.sdo_index = msg->sdo_index; @@ -97,7 +97,7 @@ void Fcat::CallActuatorCSP(const fcat_msgs::msg::ActuatorCspCmd& msg, double t) subscription_cpu_affinity_initialized_ = true; } - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg.name; cmd.type = fastcat::ACTUATOR_CSP_CMD; cmd.actuator_csp_cmd.request_time = msg.request_time; @@ -132,7 +132,6 @@ void Fcat::ActuatorCSPCmdCb(const std::shared_ptr msg) { - fprintf(stderr, "Processing ActuatorCSPCmdsCb\n"); double t = this->now().seconds(); for (auto csp_cmd : msg->commands) { CallActuatorCSP(csp_cmd, t); @@ -156,7 +155,7 @@ void Fcat::CallActuatorCSV(const fcat_msgs::msg::ActuatorCsvCmd& msg) { subscription_cpu_affinity_initialized_ = true; } - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg.name; cmd.type = fastcat::ACTUATOR_CSV_CMD; cmd.actuator_csv_cmd.target_velocity = msg.target_velocity; @@ -172,7 +171,6 @@ void Fcat::ActuatorCSVCmdCb(const std::shared_ptr msg) { - fprintf(stderr, "Processing ActuatorCSVCmdsCb\n"); for (auto csv_cmd : msg->commands) { CallActuatorCSV(csv_cmd); } @@ -195,7 +193,7 @@ void Fcat::CallActuatorCST(const fcat_msgs::msg::ActuatorCstCmd& msg) { subscription_cpu_affinity_initialized_ = true; } - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg.name; cmd.type = fastcat::ACTUATOR_CST_CMD; cmd.actuator_cst_cmd.target_torque_amps = msg.target_torque_amps; @@ -210,14 +208,13 @@ void Fcat::ActuatorCSTCmdCb(const std::shared_ptr msg) { - fprintf(stderr, "Processing ActuatorCSTCmdsCb\n"); for (auto cst_cmd : msg->commands) { CallActuatorCST(cst_cmd); } } void Fcat::ActuatorCalibrateCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_CALIBRATE_CMD; cmd.actuator_calibrate_cmd.velocity = msg->velocity; @@ -229,13 +226,16 @@ void Fcat::ActuatorCalibrateCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_PROF_TORQUE_CMD; cmd.actuator_prof_torque_cmd.target_torque_amps = msg->target_torque_amps; @@ -256,7 +256,7 @@ void Fcat::ActuatorProfTorqueCmdCb( } } void Fcat::ActuatorProfVelCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_PROF_VEL_CMD; cmd.actuator_prof_vel_cmd.target_velocity = msg->target_velocity; @@ -275,7 +275,7 @@ void Fcat::ActuatorProfPosCmdsCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_SET_OUTPUT_POSITION_CMD; cmd.actuator_set_output_position_cmd.position = msg->position; @@ -286,7 +286,7 @@ void Fcat::ActuatorSetOutputPositionCmdCb( void Fcat::ActuatorSetDigitalOutputCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_SET_DIGITAL_OUTPUT_CMD; cmd.actuator_set_digital_output_cmd.digital_output_index = msg->digital_output_index; @@ -298,7 +298,7 @@ void Fcat::ActuatorSetDigitalOutputCmdCb( void Fcat::ActuatorSetMaxCurrentCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_SET_MAX_CURRENT_CMD; cmd.actuator_set_max_current_cmd.current = msg->max_current; @@ -310,7 +310,7 @@ void Fcat::ActuatorSetMaxCurrentCmdCb( void Fcat::ActuatorSetUnitModeCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_SDO_SET_UNIT_MODE_CMD; cmd.actuator_sdo_set_unit_mode_cmd.mode = msg->mode; @@ -322,7 +322,7 @@ void Fcat::ActuatorSetUnitModeCmdCb( void Fcat::ActuatorSetProfDisengagingTimeoutCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_SET_PROF_DISENGAGING_TIMEOUT_CMD; cmd.actuator_set_prof_disengaging_timeout_cmd.timeout = msg->timeout; @@ -332,7 +332,7 @@ void Fcat::ActuatorSetProfDisengagingTimeoutCmdCb( } void Fcat::ActuatorHaltCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::ACTUATOR_HALT_CMD; if (ActuatorExistsOnBus(cmd.name)) { @@ -342,7 +342,7 @@ void Fcat::ActuatorHaltCmdCb(const std::shared_ptr msg) { for (auto& name : msg->names) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = name; cmd.type = fastcat::ACTUATOR_HALT_CMD; if (ActuatorExistsOnBus(cmd.name)) { @@ -352,7 +352,7 @@ void Fcat::ActuatorHaltCmdsCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::COMMANDER_ENABLE_CMD; cmd.commander_enable_cmd.duration = msg->duration; @@ -363,7 +363,7 @@ void Fcat::CommanderEnableCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::COMMANDER_DISABLE_CMD; @@ -374,7 +374,7 @@ void Fcat::CommanderDisableCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL2124_WRITE_ALL_CHANNELS_CMD; cmd.el2124_write_all_channels_cmd.channel_ch1 = msg->channel_ch1; @@ -388,7 +388,7 @@ void Fcat::El2124WriteAllChannelsCmdCb( } void Fcat::El2124WriteChannelCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL2124_WRITE_CHANNEL_CMD; cmd.el2124_write_channel_cmd.channel = msg->channel; @@ -401,7 +401,7 @@ void Fcat::El2124WriteChannelCmdCb( void Fcat::El2809WriteAllChannelsCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL2809_WRITE_ALL_CHANNELS_CMD; cmd.el2809_write_all_channels_cmd.channel_ch1 = msg->channel_ch1; @@ -427,7 +427,7 @@ void Fcat::El2809WriteAllChannelsCmdCb( } void Fcat::El2809WriteChannelCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL2809_WRITE_CHANNEL_CMD; cmd.el2809_write_channel_cmd.channel = msg->channel; @@ -440,7 +440,7 @@ void Fcat::El2809WriteChannelCmdCb( void Fcat::El2798WriteAllChannelsCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL2798_WRITE_ALL_CHANNELS_CMD; cmd.el2798_write_all_channels_cmd.channel_ch1 = msg->channel_ch1; @@ -458,7 +458,7 @@ void Fcat::El2798WriteAllChannelsCmdCb( } void Fcat::El2798WriteChannelCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL2798_WRITE_CHANNEL_CMD; cmd.el2798_write_channel_cmd.channel = msg->channel; @@ -471,7 +471,7 @@ void Fcat::El2798WriteChannelCmdCb( void Fcat::El2828WriteAllChannelsCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL2828_WRITE_ALL_CHANNELS_CMD; cmd.el2828_write_all_channels_cmd.channel_ch1 = msg->channel_ch1; @@ -489,7 +489,7 @@ void Fcat::El2828WriteAllChannelsCmdCb( } void Fcat::El2828WriteChannelCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL2828_WRITE_CHANNEL_CMD; cmd.el2828_write_channel_cmd.channel = msg->channel; @@ -502,7 +502,7 @@ void Fcat::El2828WriteChannelCmdCb( void Fcat::El4102WriteAllChannelsCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL4102_WRITE_ALL_CHANNELS_CMD; cmd.el4102_write_all_channels_cmd.voltage_output_ch1 = msg->voltage_output_ch1; @@ -514,7 +514,7 @@ void Fcat::El4102WriteAllChannelsCmdCb( } void Fcat::El4102WriteChannelCmdCb( const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::EL4102_WRITE_CHANNEL_CMD; cmd.el4102_write_channel_cmd.channel = msg->channel; @@ -526,7 +526,7 @@ void Fcat::El4102WriteChannelCmdCb( } void Fcat::FaulterEnableCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::FAULTER_ENABLE_CMD; cmd.faulter_enable_cmd.enable = msg->enable; @@ -537,7 +537,7 @@ void Fcat::FaulterEnableCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::FTS_TARE_CMD; @@ -547,7 +547,7 @@ void Fcat::FtsTareCmdCb(const std::shared_ptr msg) { } void Fcat::PidActivateCmdCb(const std::shared_ptr msg) { - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = msg->name; cmd.type = fastcat::PID_ACTIVATE_CMD; cmd.pid_activate_cmd.setpoint = msg->setpoint; @@ -582,7 +582,7 @@ void Fcat::ActuatorHaltSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Halt Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_HALT_CMD; @@ -596,7 +596,7 @@ void Fcat::ActuatorSetGainSchedulingIndexSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Set Gain Scheduling Index Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_SET_GAIN_SCHEDULING_INDEX_CMD; cmd.actuator_set_gain_scheduling_index_cmd.gain_scheduling_index = request->gain_scheduling_index; @@ -611,7 +611,7 @@ void Fcat::ActuatorSetMaxCurrentSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Set Max Current Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_SET_MAX_CURRENT_CMD; cmd.actuator_set_max_current_cmd.current = request->max_current; @@ -626,7 +626,7 @@ void Fcat::ActuatorSetDigitalOutputSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Set Digital Output Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_SET_DIGITAL_OUTPUT_CMD; cmd.actuator_set_digital_output_cmd.digital_output_index = request->digital_output_index; @@ -642,7 +642,7 @@ void Fcat::ActuatorSetProfDisengagingTimeoutSrvCb( request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Set Profile Disengaging Timeout Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_SET_PROF_DISENGAGING_TIMEOUT_CMD; cmd.actuator_set_prof_disengaging_timeout_cmd.timeout = request->timeout; @@ -657,7 +657,7 @@ void Fcat::ActuatorSetOutputPositionSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Set Output Position Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_SET_OUTPUT_POSITION_CMD; cmd.actuator_set_output_position_cmd.position = request->position; @@ -671,7 +671,7 @@ void Fcat::ActuatorCalibrateSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Calibrate Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_CALIBRATE_CMD; cmd.actuator_calibrate_cmd.velocity = request->velocity; @@ -687,13 +687,16 @@ void Fcat::ActuatorProfPosSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Set Prof Pos Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_PROF_POS_CMD; cmd.actuator_prof_pos_cmd.target_position = request->target_position; cmd.actuator_prof_pos_cmd.profile_velocity = request->profile_velocity; cmd.actuator_prof_pos_cmd.profile_accel = request->profile_accel; cmd.actuator_prof_pos_cmd.relative = request->relative; + // No end_velocity in ActuatorProfPosService; fastcat checks it against the + // speed limit, so pin it to 0 (stop at goal). + cmd.actuator_prof_pos_cmd.end_velocity = 0.0; response->success = ActuatorExistsOnBus(cmd.name, response->message); if (response->success) { QueueCommand(cmd); @@ -704,7 +707,7 @@ void Fcat::ActuatorProfVelSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Set Prof Vel Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_PROF_VEL_CMD; cmd.actuator_prof_vel_cmd.target_velocity = request->target_velocity; @@ -720,7 +723,7 @@ void Fcat::ActuatorProfTorqueSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Actuator Set Prof Torque Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::ACTUATOR_PROF_TORQUE_CMD; cmd.actuator_prof_torque_cmd.target_torque_amps = request->target_torque_amps; @@ -735,7 +738,7 @@ void Fcat::CommanderEnableSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Commander Enable Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::COMMANDER_ENABLE_CMD; cmd.commander_enable_cmd.duration = request->duration; @@ -750,7 +753,7 @@ void Fcat::CommanderDisableSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Commander Disable Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::COMMANDER_DISABLE_CMD; @@ -764,7 +767,7 @@ void Fcat::El2124WriteAllChannelsSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL2124 Write All Channels Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL2124_WRITE_ALL_CHANNELS_CMD; @@ -783,7 +786,7 @@ void Fcat::El2124WriteChannelSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL2124 Write Channel Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL2124_WRITE_CHANNEL_CMD; @@ -800,7 +803,7 @@ void Fcat::El2809WriteAllChannelsSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL2809 Write All Channels Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL2809_WRITE_ALL_CHANNELS_CMD; @@ -831,7 +834,7 @@ void Fcat::El2809WriteChannelSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL2809 Write Channel Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL2809_WRITE_CHANNEL_CMD; @@ -848,7 +851,7 @@ void Fcat::El2798WriteAllChannelsSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL2798 Write All Channels Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL2798_WRITE_ALL_CHANNELS_CMD; @@ -871,7 +874,7 @@ void Fcat::El2828WriteAllChannelsSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL2828 Write All Channels Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL2828_WRITE_ALL_CHANNELS_CMD; @@ -894,7 +897,7 @@ void Fcat::El2798WriteChannelSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL2798 Write Channel Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL2798_WRITE_CHANNEL_CMD; @@ -911,7 +914,7 @@ void Fcat::El2828WriteChannelSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL2828 Write Channel Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL2828_WRITE_CHANNEL_CMD; @@ -928,7 +931,7 @@ void Fcat::El4102WriteAllChannelsSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL4102 Write All Channels Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL4102_WRITE_ALL_CHANNELS_CMD; @@ -945,7 +948,7 @@ void Fcat::El4102WriteChannelSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling EL4102 Write Channel Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::EL4102_WRITE_CHANNEL_CMD; @@ -962,7 +965,7 @@ void Fcat::FaulterEnableSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling Faulter Enable Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::FAULTER_ENABLE_CMD; @@ -978,7 +981,7 @@ void Fcat::FtsTareSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling FTS Tare Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; cmd.name = request->name; cmd.type = fastcat::FTS_TARE_CMD; @@ -992,7 +995,8 @@ void Fcat::PidActivateSrvCb( const std::shared_ptr request, std::shared_ptr response) { RCLCPP_INFO(this->get_logger(), "Handling PID Activate Command"); - fastcat::DeviceCmd cmd; + fastcat::DeviceCmd cmd{}; + cmd.name = request->name; cmd.type = fastcat::PID_ACTIVATE_CMD; cmd.pid_activate_cmd.setpoint = request->setpoint; cmd.pid_activate_cmd.deadband = request->deadband;