Skip to content

Commit dd57c4c

Browse files
committed
fix: Removed Boost dependency
1 parent b981138 commit dd57c4c

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

include/dynamixel_hardware_interface/dynamixel/dynamixel_info.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@
1919

2020
#include <cmath>
2121
#include <cstring>
22+
#include <cstdint>
2223

2324
#include <fstream>
2425
#include <iostream>
2526
#include <map>
2627
#include <string>
2728
#include <vector>
2829

29-
#include <boost/algorithm/string.hpp>
30-
3130
namespace dynamixel_hardware_interface
3231
{
3332

src/dynamixel/dynamixel_info.cpp

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,24 @@
1818
#include <string>
1919
#include <utility>
2020
#include <vector>
21+
#include <sstream>
2122

2223
namespace dynamixel_hardware_interface
2324
{
2425

26+
// Helper function to split string by delimiter
27+
std::vector<std::string> split_string(const std::string& str, char delimiter) {
28+
std::vector<std::string> tokens;
29+
std::string token;
30+
std::istringstream token_stream(str);
31+
while (std::getline(token_stream, token, delimiter)) {
32+
if (!token.empty()) { // Skip empty tokens
33+
tokens.push_back(token);
34+
}
35+
}
36+
return tokens;
37+
}
38+
2539
void DynamixelInfo::SetDxlModelFolderPath(const char * path)
2640
{
2741
dxl_model_file_dir = std::string(path);
@@ -80,21 +94,22 @@ void DynamixelInfo::ReadDxlModelFile(uint8_t id, uint16_t model_num)
8094
break;
8195
}
8296

83-
std::vector<std::string> strs;
84-
boost::split(strs, line, boost::is_any_of("\t"));
85-
86-
if (strs.at(0) == "value_of_zero_radian_position") {
87-
temp_dxl_info.value_of_zero_radian_position = static_cast<int32_t>(stoi(strs.at(1)));
88-
} else if (strs.at(0) == "value_of_max_radian_position") {
89-
temp_dxl_info.value_of_max_radian_position = static_cast<int32_t>(stoi(strs.at(1)));
90-
} else if (strs.at(0) == "value_of_min_radian_position") {
91-
temp_dxl_info.value_of_min_radian_position = static_cast<int32_t>(stoi(strs.at(1)));
92-
} else if (strs.at(0) == "min_radian") {
93-
temp_dxl_info.min_radian = static_cast<double>(stod(strs.at(1)));
94-
} else if (strs.at(0) == "max_radian") {
95-
temp_dxl_info.max_radian = static_cast<double>(stod(strs.at(1)));
96-
} else if (strs.at(0) == "torque_constant") {
97-
temp_dxl_info.torque_constant = static_cast<double>(stod(strs.at(1)));
97+
std::vector<std::string> strs = split_string(line, '\t');
98+
99+
if (!strs.empty()) {
100+
if (strs.at(0) == "value_of_zero_radian_position") {
101+
temp_dxl_info.value_of_zero_radian_position = static_cast<int32_t>(stoi(strs.at(1)));
102+
} else if (strs.at(0) == "value_of_max_radian_position") {
103+
temp_dxl_info.value_of_max_radian_position = static_cast<int32_t>(stoi(strs.at(1)));
104+
} else if (strs.at(0) == "value_of_min_radian_position") {
105+
temp_dxl_info.value_of_min_radian_position = static_cast<int32_t>(stoi(strs.at(1)));
106+
} else if (strs.at(0) == "min_radian") {
107+
temp_dxl_info.min_radian = static_cast<double>(stod(strs.at(1)));
108+
} else if (strs.at(0) == "max_radian") {
109+
temp_dxl_info.max_radian = static_cast<double>(stod(strs.at(1)));
110+
} else if (strs.at(0) == "torque_constant") {
111+
temp_dxl_info.torque_constant = static_cast<double>(stod(strs.at(1)));
112+
}
98113
}
99114
}
100115

@@ -105,14 +120,15 @@ void DynamixelInfo::ReadDxlModelFile(uint8_t id, uint16_t model_num)
105120
break;
106121
}
107122

108-
std::vector<std::string> strs;
109-
boost::split(strs, line, boost::is_any_of("\t"));
123+
std::vector<std::string> strs = split_string(line, '\t');
110124

111-
ControlItem temp;
112-
temp.address = static_cast<uint16_t>(stoi(strs.at(0)));
113-
temp.size = static_cast<uint8_t>(stoi(strs.at(1)));
114-
temp.item_name = strs.at(2);
115-
temp_dxl_info.item.push_back(temp);
125+
if (!strs.empty()) {
126+
ControlItem temp;
127+
temp.address = static_cast<uint16_t>(stoi(strs.at(0)));
128+
temp.size = static_cast<uint8_t>(stoi(strs.at(1)));
129+
temp.item_name = strs.at(2);
130+
temp_dxl_info.item.push_back(temp);
131+
}
116132
}
117133

118134
dxl_info_[id] = temp_dxl_info;

0 commit comments

Comments
 (0)