Skip to content

Commit

Permalink
fix(hesai_hw_interface): remove unused params/variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mojomex committed Mar 14, 2024
1 parent a809559 commit 6004d41
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class HesaiHwInterface : NebulaHwInterfaceBase
/// @brief Initializing tcp_driver for TCP communication
/// @param setup_sensor Whether to also initialize tcp_driver for sensor configuration
/// @return Resulting status
Status InitializeTcpDriver(bool setup_sensor = true);
Status InitializeTcpDriver();
/// @brief Closes the TcpDriver and related resources
/// @return Status result
Status FinalizeTcpDriver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ Status HesaiHwInterface::GetCalibrationConfiguration(
return Status::ERROR_1;
}

Status HesaiHwInterface::InitializeTcpDriver(bool setup_sensor)
Status HesaiHwInterface::InitializeTcpDriver()
{
#ifdef WITH_DEBUG_STDOUT_HESAI_HW_INTERFACE
std::cout << "HesaiHwInterface::InitializeTcpDriver, setup_sensor=" << setup_sensor << std::endl;
std::cout << "HesaiHwInterface::InitializeTcpDriver" << std::endl;
std::cout << "st: tcp_driver_->init_socket" << std::endl;
std::cout << "sensor_configuration_->sensor_ip=" << sensor_configuration_->sensor_ip << std::endl;
std::cout << "sensor_configuration_->host_ip=" << sensor_configuration_->host_ip << std::endl;
Expand Down Expand Up @@ -695,9 +695,7 @@ Status HesaiHwInterface::SetSpinRate(uint16_t rpm)
request_payload.emplace_back((rpm >> 8) & 0xff);
request_payload.emplace_back(rpm & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_SPIN_RATE, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_SPIN_RATE, request_payload);
return Status::OK;
}

Expand All @@ -708,9 +706,7 @@ Status HesaiHwInterface::SetSyncAngle(int sync_angle, int angle)
request_payload.emplace_back((angle >> 8) & 0xff);
request_payload.emplace_back(angle & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_SYNC_ANGLE, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_SYNC_ANGLE, request_payload);
return Status::OK;
}

Expand All @@ -719,9 +715,7 @@ Status HesaiHwInterface::SetTriggerMethod(int trigger_method)
std::vector<unsigned char> request_payload;
request_payload.emplace_back(trigger_method & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_TRIGGER_METHOD, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_TRIGGER_METHOD, request_payload);
return Status::OK;
}

Expand All @@ -730,9 +724,7 @@ Status HesaiHwInterface::SetStandbyMode(int standby_mode)
std::vector<unsigned char> request_payload;
request_payload.emplace_back(standby_mode & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_STANDBY_MODE, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_STANDBY_MODE, request_payload);
return Status::OK;
}

Expand All @@ -741,9 +733,7 @@ Status HesaiHwInterface::SetReturnMode(int return_mode)
std::vector<unsigned char> request_payload;
request_payload.emplace_back(return_mode & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_RETURN_MODE, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_RETURN_MODE, request_payload);
return Status::OK;
}

Expand All @@ -760,9 +750,7 @@ Status HesaiHwInterface::SetDestinationIp(
request_payload.emplace_back((gps_port >> 8) & 0xff);
request_payload.emplace_back(gps_port & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_DESTINATION_IP, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_DESTINATION_IP, request_payload);
return Status::OK;
}

Expand All @@ -787,9 +775,7 @@ Status HesaiHwInterface::SetControlPort(
request_payload.emplace_back((vlan_id >> 8) & 0xff);
request_payload.emplace_back(vlan_id & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_CONTROL_PORT, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_CONTROL_PORT, request_payload);
return Status::OK;
}

Expand All @@ -802,9 +788,7 @@ Status HesaiHwInterface::SetLidarRange(int method, std::vector<unsigned char> da
request_payload.emplace_back(method & 0xff);
request_payload.insert(request_payload.end(), data.begin(), data.end());

auto response_ptr = SendReceive(PTC_COMMAND_SET_LIDAR_RANGE, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_LIDAR_RANGE, request_payload);
return Status::OK;
}

Expand All @@ -821,9 +805,7 @@ Status HesaiHwInterface::SetLidarRange(int start, int end)
request_payload.emplace_back((end >> 8) & 0xff);
request_payload.emplace_back(end & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_LIDAR_RANGE, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_LIDAR_RANGE, request_payload);
return Status::OK;
}

Expand Down Expand Up @@ -859,9 +841,7 @@ Status HesaiHwInterface::SetClockSource(int clock_source)
std::vector<unsigned char> request_payload;
request_payload.emplace_back(clock_source & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_CLOCK_SOURCE, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_CLOCK_SOURCE, request_payload);
return Status::OK;
}

Expand Down Expand Up @@ -894,9 +874,7 @@ Status HesaiHwInterface::SetPtpConfig(
request_payload.emplace_back(switch_type & 0xff);
}

auto response_ptr = SendReceive(PTC_COMMAND_SET_PTP_CONFIG, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_PTP_CONFIG, request_payload);
return Status::OK;
}

Expand Down Expand Up @@ -927,9 +905,7 @@ HesaiPtpConfig HesaiHwInterface::GetPtpConfig()

Status HesaiHwInterface::SendReset()
{
auto response_ptr = SendReceive(PTC_COMMAND_RESET);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_RESET);
return Status::OK;
}

Expand All @@ -938,9 +914,7 @@ Status HesaiHwInterface::SetRotDir(int mode)
std::vector<unsigned char> request_payload;
request_payload.emplace_back(mode & 0xff);

auto response_ptr = SendReceive(PTC_COMMAND_SET_ROTATE_DIRECTION, request_payload);
auto & response = *response_ptr;

SendReceive(PTC_COMMAND_SET_ROTATE_DIRECTION, request_payload);
return Status::OK;
}

Expand Down
4 changes: 2 additions & 2 deletions nebula_ros/src/hesai/hesai_decoder_ros_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Status HesaiDriverRosWrapper::GetParameters(
<< sensor_configuration.sensor_ip << "'");
std::future<void> future = std::async(std::launch::async,
[this, &calibration_configuration, &calibration_file_path_from_sensor, &run_local]() {
if (hw_interface_.InitializeTcpDriver(false) == Status::OK) {
if (hw_interface_.InitializeTcpDriver() == Status::OK) {
auto str = hw_interface_.GetLidarCalibrationString();
auto rt = calibration_configuration.SaveFileFromString(
calibration_file_path_from_sensor, str);
Expand Down Expand Up @@ -394,7 +394,7 @@ Status HesaiDriverRosWrapper::GetParameters(
correction_file_path_from_sensor += correction_file_path.substr(ext_pos, correction_file_path.size() - ext_pos);
}
std::future<void> future = std::async(std::launch::async, [this, &correction_configuration, &correction_file_path_from_sensor, &run_local, &launch_hw]() {
if (launch_hw && hw_interface_.InitializeTcpDriver(false) == Status::OK) {
if (launch_hw && hw_interface_.InitializeTcpDriver() == Status::OK) {
RCLCPP_INFO_STREAM(
this->get_logger(), "Trying to acquire calibration data from sensor");
auto received_bytes = hw_interface_.GetLidarCalibrationBytes();
Expand Down
4 changes: 2 additions & 2 deletions nebula_ros/src/hesai/hesai_hw_interface_ros_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ HesaiHwInterfaceRosWrapper::HesaiHwInterfaceRosWrapper(const rclcpp::NodeOptions
hw_interface_.SetSensorConfiguration(
std::static_pointer_cast<drivers::SensorConfigurationBase>(sensor_cfg_ptr));
#if not defined(TEST_PCAP)
Status rt = hw_interface_.InitializeTcpDriver(this->setup_sensor);
Status rt = hw_interface_.InitializeTcpDriver();
if(this->retry_hw_)
{
int cnt = 0;
Expand All @@ -32,7 +32,7 @@ HesaiHwInterfaceRosWrapper::HesaiHwInterfaceRosWrapper(const rclcpp::NodeOptions
cnt++;
std::this_thread::sleep_for(std::chrono::milliseconds(8000));// >5000
RCLCPP_ERROR_STREAM(this->get_logger(), this->get_name() << " Retry: " << cnt);
rt = hw_interface_.InitializeTcpDriver(this->setup_sensor);
rt = hw_interface_.InitializeTcpDriver();
}
}

Expand Down
2 changes: 1 addition & 1 deletion nebula_ros/src/hesai/hesai_hw_monitor_ros_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ HesaiHwMonitorRosWrapper::HesaiHwMonitorRosWrapper(const rclcpp::NodeOptions & o
hw_interface_.SetLogger(std::make_shared<rclcpp::Logger>(this->get_logger()));
hw_interface_.SetSensorConfiguration(
std::static_pointer_cast<drivers::SensorConfigurationBase>(sensor_cfg_ptr));
while(hw_interface_.InitializeTcpDriver(false) == Status::ERROR_1)
while(hw_interface_.InitializeTcpDriver() == Status::ERROR_1)
{
std::this_thread::sleep_for(std::chrono::milliseconds(8000));// >5000
}
Expand Down

0 comments on commit 6004d41

Please sign in to comment.