14 p_tmcl_interpreter_(nullptr)
24 for(uint8_t index = 0; index <
p_motor_.size(); index++)
41 bool b_result =
false;
42 bool b_autostart_mode =
false;
44 uint8_t instruction = 0;
74 firmware_value[0] = (val & 0xFF000000) >> 24;
75 firmware_value[1] = (val & 0x00FF0000) >> 16;
76 firmware_value[2] = (val & 0x0000FF00) >> 8;
77 firmware_value[3] = (val & 0x000000FF);
83 ROS_INFO(
"[%s] Firmware version : %d.%d", __func__, firmware_value[2], firmware_value[3]);
91 b_autostart_mode = val;
102 <<
"secs to autostart TMCL program");
130 bool b_result =
true;
138 const std::string s_ap_name =
s_node_name_ +
"/AP_name";
142 "Check autogenerated YAML if broken or missing. Exiting!");
145 const std::string s_ap_type =
s_node_name_ +
"/AP_type";
149 "Check autogenerated YAML if broken or missing. Exiting!");
156 ROS_ERROR_STREAM(
"[" << __func__ <<
"] Vector size mismatch between AP_name and AP_type. "
157 "Check autogenerated YAML. Exiting!");
161 const std::string s_gp_name =
s_node_name_ +
"/GP_name";
165 "Check autogenerated YAML if broken or missing. Exiting!");
168 const std::string s_gp_type =
s_node_name_ +
"/GP_type";
172 "Check autogenerated YAML if broken or missing. Exiting!");
179 ROS_ERROR_STREAM(
"[" << __func__ <<
"] Vector size mismatch between GP_name and GP_type. "
180 "Check autogenerated YAML. Exiting!");
190 const std::string s_comm_interface =
s_node_name_ +
"/comm_interface";
195 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get comm_interface, setting to default value: "
198 const std::string s_comm_interface_name =
s_node_name_ +
"/comm_interface_name";
203 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get comm_interface_name, setting to default value: "
206 const std::string s_adhoc_mode=
s_node_name_ +
"/adhoc_mode";
211 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get adhoc_mode, setting to default value: "
218 const std::string s_comm_tx_id =
s_node_name_ +
"/comm_tx_id";
223 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get comm_tx_id, setting to default value: "
228 if(param_comm_tx_id_ < 0 || param_comm_tx_id_ >
TXRX_ID_MAX)
232 ROS_WARN_STREAM(
"[" << __func__ <<
"] Set value to comm_tx_id is out of range, "
236 const std::string s_comm_rx_id =
s_node_name_ +
"/comm_rx_id";
241 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get comm_rx_id, setting to default value: "
246 if(param_comm_rx_id_ < 0 || param_comm_rx_id_ >
TXRX_ID_MAX)
250 ROS_WARN_STREAM(
"[" << __func__ <<
"] Set value to comm_rx_id is out of range, "
254 const std::string s_comm_timeout_ms =
s_node_name_ +
"/comm_timeout_ms";
259 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get comm_timeout_ms, setting to default value: "
264 if(param_comm_timeout_ms_ < 0 || param_comm_timeout_ms_ >
TIMEOUT_MS_MAX)
268 ROS_WARN_STREAM(
"[" << __func__ <<
"] Set value to comm_timeout_ms is out of range, "
272 const std::string s_comm_exec_cmd_retries =
s_node_name_ +
"/comm_exec_cmd_retries";
277 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get comm_exec_cmd_retries, setting to default value: "
286 ROS_WARN_STREAM(
"[" << __func__ <<
"] Set value to comm_exec_cmd_retries is out of range, "
290 const std::string s_pub_rate_tmc_info =
s_node_name_ +
"/pub_rate_tmc_info";
295 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get pub_rate_tmc_info, setting to default value: "
300 if(param_pub_rate_tmc_info_ < PUB_RATE_MIN || param_pub_rate_tmc_info_ >
PUB_RATE_MAX)
304 ROS_WARN_STREAM(
"[" << __func__ <<
"] Set value to pub_rate_tmc_info is out of range, "
308 const std::string s_auto_start_additional_delay =
s_node_name_ +
"/auto_start_additional_delay";
313 ROS_WARN_STREAM(
"[" << __func__ <<
"] Failed to get auto_start_additional_delay, setting to default value: "
323 ROS_WARN_STREAM(
"[" << __func__ <<
"] Set value to auto_start_additional_delay is out of range, "
344 const std::string s_en_motors =
s_node_name_ +
"/en_motors";
352 ROS_WARN(
"[%s] Failed to get en_motors, setting to default value: 0", __func__);
363 ROS_WARN(
"[%s] Missing indeces for en_motors, setting missing en_motors value to default: 0", __func__);
371 ROS_WARN(
"[%s] Indeces exceeded total motors available, deleting unused indeces", __func__);
379 ROS_WARN(
"[%s] Set value to en_motors for motor %d is out of range, setting en_motors value to default: %d "
402 ROS_WARN(
"[%s] Motor %d is disabled\n", __func__, index);
411 ROS_INFO_STREAM(
"[" << __func__ <<
"] Detected module for BLDC Motors\n");
423 ROS_WARN(
"[%s] motor %d is disabled\n", __func__, index);
431 ROS_INFO_STREAM(
"[" << __func__ <<
"] Detected module for Stepper Motors\n");
442 ROS_WARN(
"[%s] motor %d is disabled\n", __func__, index);
460 std::string s_custom_cmd_srvname =
s_namespace_ +
"/tmcl_custom_cmd";
461 std::string s_gap_all_srvname =
s_namespace_ +
"/tmcl_gap_all";
462 std::string s_ggp_all_srvname =
s_namespace_ +
"/tmcl_ggp_all";
467 ROS_INFO_STREAM(
"[" << __func__ <<
"] tmcl_custom_cmd server advertised. Service name: " << s_custom_cmd_srvname);
471 ROS_WARN_STREAM(
"[" << __func__ <<
"] tmcl_custom_cmd server failed to advertise.");
477 ROS_INFO_STREAM(
"[" << __func__ <<
"] tmcl_gap_all server advertised. Service name: " << s_gap_all_srvname);
481 ROS_WARN_STREAM(
"[" << __func__ <<
"] tmcl_gap_all server failed to advertise.");
487 ROS_INFO_STREAM(
"[" << __func__ <<
"] tmcl_ggp_all server advertised. Service name: " << s_ggp_all_srvname);
491 ROS_WARN_STREAM(
"[" << __func__ <<
"] tmcl_ggp_all server failed to advertise.");
498 bool b_result =
false;
501 if(req.instruction ==
"SAP")
508 ROS_DEBUG_STREAM(
"[" << __func__ <<
"] Service Done. Set value: " << res.output);
515 else if(req.instruction ==
"GAP")
521 ROS_DEBUG_STREAM(
"[" << __func__ <<
"] Service Done. Get value: " << res.output);
528 else if(req.instruction ==
"SGP")
535 ROS_DEBUG_STREAM(
"[" << __func__ <<
"] Service Done. Set value: " << res.output);
542 else if(req.instruction ==
"GGP")
548 ROS_DEBUG_STREAM(
"[" << __func__ <<
"] Service Done. Get value: " << res.output);
561 res.result = b_result;
567 bool b_result =
true;
593 ROS_ERROR_STREAM(
"[" << __func__ <<
"] Required motor number exceeds to axis available");
595 res.result = b_result;
601 bool b_result =
true;
605 if(req.motor_number == 0)
627 ROS_ERROR_STREAM(
"[" << __func__ <<
"] GGP All Service only accepts value \"0\" as motor number");
629 res.result = b_result;
638 bool b_result =
false;
649 ROS_INFO(
"[%s] Stopped motor %d before shutting down...",__func__, index);
653 ROS_WARN(
"[%s] Timeout reached. Stopping of motor %d failed",__func__, index);
659 ROS_ERROR_STREAM(
"[" << __func__ <<
"] Timeout reached (board unresponsive), skipping motor stop commands");
679 bool b_result =
true;