Skip to content

Commit ea714c4

Browse files
authored
Merge pull request #664 from ROBOTIS-GIT/feature-api-update
Dynamixel Easy SDK update in cpp linux 64bit
2 parents 54cabbf + 693076c commit ea714c4

File tree

92 files changed

+7588
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7588
-10
lines changed

.github/workflows/ros-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ name: CI
44
# Specifies the events that trigger the workflow
55
on:
66
push:
7-
branches: [ main, humble ]
7+
branches: [ main, humble, jazzy ]
88
pull_request:
9-
branches: [ main, humble ]
9+
branches: [ main, humble, jazzy ]
1010

1111
# Defines a set of jobs to be run as part of the workflow
1212
jobs:

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "DynamixelSDK c++"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 3.8.4
41+
PROJECT_NUMBER = 4.0.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

ReleaseNote.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Dynamixel SDK Release Notes
22

3+
4.0.0 (2025-10-14)
4+
------------------
5+
* Update Dynamixel Easy SDK in C++ Linux 64bit
6+
* Contributors: Hyungyu Kim
7+
38
3.8.4 (2025-05-28)
49
------------------
510
* Deprecate ament_include_dependency usage in CMakeLists.txt

c++/build/linux64/Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ SYMLINK = ln -s
3535
MKDIR = mkdir
3636
CC = gcc
3737
CX = g++
38-
CCFLAGS = -O2 -O3 -DLINUX -D_GNU_SOURCE -Wall -c $(INCLUDES) $(FORMAT) -fPIC -g
39-
CXFLAGS = -O2 -O3 -DLINUX -D_GNU_SOURCE -Wall -c $(INCLUDES) $(FORMAT) -fPIC -g
38+
CONTROL_TABLE_PATH_FLAG = -DCONTROL_TABLE_PATH=\"$(INSTALL_ROOT)/share/dynamixel_sdk/control_table\"
39+
CCFLAGS = -O2 -O3 -DLINUX -D_GNU_SOURCE -Wall -c $(INCLUDES) $(FORMAT) -fPIC -g $(CONTROL_TABLE_PATH_FLAG)
40+
CXFLAGS = -O2 -O3 -DLINUX -D_GNU_SOURCE -Wall -c $(INCLUDES) $(FORMAT) -fPIC -g $(CONTROL_TABLE_PATH_FLAG)
4041
FORMAT = -m64
4142
INCLUDES += -I$(DIR_DXL)/include/dynamixel_sdk
43+
INCLUDES += -I$(DIR_DXL)/include
4244

4345
#---------------------------------------------------------------------
4446
# Required external libraries
@@ -60,6 +62,11 @@ SOURCES = src/dynamixel_sdk/group_bulk_read.cpp \
6062
src/dynamixel_sdk/protocol1_packet_handler.cpp \
6163
src/dynamixel_sdk/protocol2_packet_handler.cpp \
6264
src/dynamixel_sdk/port_handler_linux.cpp \
65+
src/dynamixel_easy_sdk/connector.cpp \
66+
src/dynamixel_easy_sdk/control_table.cpp \
67+
src/dynamixel_easy_sdk/motor.cpp \
68+
src/dynamixel_easy_sdk/dynamixel_error.cpp \
69+
src/dynamixel_easy_sdk/group_executor.cpp
6370

6471

6572
OBJECTS=$(addsuffix .o,$(addprefix $(DIR_OBJS)/,$(basename $(notdir $(SOURCES)))))
@@ -89,6 +96,13 @@ install: $(TARGET)
8996
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/include/dynamixel_sdk || $(MKDIR) $(INSTALL_ROOT)/include/dynamixel_sdk
9097
$(CP_ALL) $(DIR_DXL)/include/dynamixel_sdk/* $(INSTALL_ROOT)/include/dynamixel_sdk
9198

99+
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/include/dynamixel_easy_sdk || $(MKDIR) $(INSTALL_ROOT)/include/dynamixel_easy_sdk
100+
$(CP_ALL) $(DIR_DXL)/include/dynamixel_easy_sdk/* $(INSTALL_ROOT)/include/dynamixel_easy_sdk
101+
102+
# copy the control_table directory into the share directory
103+
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/share/dynamixel_sdk || $(MKDIR) -p $(INSTALL_ROOT)/share/dynamixel_sdk
104+
$(CP_ALL) $(DIR_DXL)/../control_table $(INSTALL_ROOT)/share/dynamixel_sdk/
105+
92106
$(LD_CONFIG)
93107

94108
uninstall:
@@ -99,6 +113,8 @@ uninstall:
99113

100114
$(RM) $(INSTALL_ROOT)/include/dynamixel_sdk/dynamixel_sdk.h
101115
$(RM_ALL) $(INSTALL_ROOT)/include/dynamixel_sdk/*
116+
$(RM_ALL) $(INSTALL_ROOT)/include/dynamixel_easy_sdk/*
117+
$(RM_ALL) $(INSTALL_ROOT)/share/dynamixel_sdk/control_table
102118

103119
reinstall: uninstall install
104120

@@ -119,6 +135,9 @@ $(DIR_OBJS)/%.o: $(DIR_DXL)/src/dynamixel_sdk/%.c
119135
$(DIR_OBJS)/%.o: $(DIR_DXL)/src/dynamixel_sdk/%.cpp
120136
$(CX) $(CXFLAGS) -c $? -o $@
121137

138+
$(DIR_OBJS)/%.o: $(DIR_DXL)/src/dynamixel_easy_sdk/%.cpp
139+
$(CX) $(CXFLAGS) -c $? -o $@
140+
122141
#---------------------------------------------------------------------
123142
# END OF MAKEFILE
124143
#---------------------------------------------------------------------
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2025 ROBOTIS CO., LTD.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// Author: Hyungyu Kim
16+
17+
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_CONNECTOR_HPP_
18+
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_CONNECTOR_HPP_
19+
20+
#include <memory>
21+
#include <string>
22+
#include <vector>
23+
24+
#include "dynamixel_sdk/dynamixel_sdk.h"
25+
#include "dynamixel_easy_sdk/dynamixel_error.hpp"
26+
#include "dynamixel_easy_sdk/motor.hpp"
27+
#include "dynamixel_easy_sdk/group_executor.hpp"
28+
29+
namespace dynamixel
30+
{
31+
class Connector
32+
{
33+
public:
34+
Connector(const std::string & port_name, int baud_rate);
35+
36+
virtual ~Connector();
37+
38+
std::unique_ptr<Motor> createMotor(uint8_t id);
39+
std::vector<std::unique_ptr<Motor>> createAllMotors(int start_id = 0, int end_id = 252);
40+
std::unique_ptr<GroupExecutor> createGroupExecutor();
41+
42+
Result<void, DxlError> write1ByteData(uint8_t id, uint16_t address, uint8_t value);
43+
Result<void, DxlError> write2ByteData(uint8_t id, uint16_t address, uint16_t value);
44+
Result<void, DxlError> write4ByteData(uint8_t id, uint16_t address, uint32_t value);
45+
46+
Result<uint8_t, DxlError> read1ByteData(uint8_t id, uint16_t address);
47+
Result<uint16_t, DxlError> read2ByteData(uint8_t id, uint16_t address);
48+
Result<uint32_t, DxlError> read4ByteData(uint8_t id, uint16_t address);
49+
50+
Result<void, DxlError> reboot(uint8_t id);
51+
Result<uint16_t, DxlError> ping(uint8_t id);
52+
Result<void, DxlError> factoryReset(uint8_t id, uint8_t option);
53+
54+
PortHandler * getPortHandler() const {return port_handler_.get();}
55+
PacketHandler * getPacketHandler() const {return packet_handler_;}
56+
57+
private:
58+
std::unique_ptr<PortHandler> port_handler_;
59+
PacketHandler * packet_handler_;
60+
};
61+
} // namespace dynamixel
62+
#endif /* DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_CONNECTOR_HPP_ */
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2025 ROBOTIS CO., LTD.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// Author: Hyungyu Kim
16+
17+
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_CONTROL_TABLE_HPP_
18+
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_CONTROL_TABLE_HPP_
19+
20+
#include <cstdint>
21+
#include <fstream>
22+
#include <iostream>
23+
#include <map>
24+
#include <sstream>
25+
#include <string>
26+
27+
#include "dynamixel_easy_sdk/dynamixel_error.hpp"
28+
29+
namespace dynamixel
30+
{
31+
struct ControlTableItem
32+
{
33+
uint16_t address;
34+
uint8_t size;
35+
};
36+
37+
class ControlTable
38+
{
39+
public:
40+
static const std::map<uint16_t, std::string> ParsingModelList();
41+
static const std::string getModelName(uint16_t model_number);
42+
static const std::map<std::string, ControlTableItem> & getControlTable(uint16_t model_number);
43+
};
44+
} // namespace dynamixel
45+
#endif /* DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_CONTROL_TABLE_HPP_ */
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2025 ROBOTIS CO., LTD.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// Author: Hyungyu Kim
16+
17+
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_DYNAMIXEL_EASY_SDK_HPP_
18+
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_DYNAMIXEL_EASY_SDK_HPP_
19+
20+
21+
#include "dynamixel_easy_sdk/connector.hpp"
22+
#include "dynamixel_easy_sdk/dynamixel_error.hpp"
23+
#include "dynamixel_easy_sdk/motor.hpp"
24+
#include "dynamixel_easy_sdk/group_executor.hpp"
25+
26+
#endif /* DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_DYNAMIXEL_EASY_SDK_HPP_ */
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// Copyright 2025 ROBOTIS CO., LTD.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
// Author: Hyungyu Kim
16+
17+
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_DYNAMIXEL_ERROR_HPP_
18+
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_DYNAMIXEL_ERROR_HPP_
19+
20+
#include <variant>
21+
#include <stdexcept>
22+
#include <string>
23+
24+
namespace dynamixel
25+
{
26+
enum class DxlError
27+
{
28+
SDK_COMM_SUCCESS = 0, // tx or rx packet communication success
29+
SDK_COMM_PORT_BUSY = -1000, // Port is busy (in use)
30+
SDK_COMM_TX_FAIL = -1001, // Failed transmit instruction packet
31+
SDK_COMM_RX_FAIL = -1002, // Failed get status packet
32+
SDK_COMM_TX_ERROR = -2000, // Incorrect instruction packet
33+
SDK_COMM_RX_WAITING = -3000, // Now receiving status packet
34+
SDK_COMM_RX_TIMEOUT = -3001, // There is no status packet
35+
SDK_COMM_RX_CORRUPT = -3002, // Incorrect status packet
36+
SDK_COMM_NOT_AVAILABLE = -9000,
37+
SDK_ERRNUM_RESULT_FAIL = 1, // Failed to process the instruction packet.
38+
SDK_ERRNUM_INSTRUCTION = 2, // Instruction error
39+
SDK_ERRNUM_CRC = 3, // CRC check error
40+
SDK_ERRNUM_DATA_RANGE = 4, // Data range error
41+
SDK_ERRNUM_DATA_LENGTH = 5, // Data length error
42+
SDK_ERRNUM_DATA_LIMIT = 6, // Data limit error
43+
SDK_ERRNUM_ACCESS = 7, // Access error
44+
EASY_SDK_FUNCTION_NOT_SUPPORTED = 11, // API does not support this function
45+
EASY_SDK_MOTOR_TORQUE_OFF = 12, // Motor torque is off
46+
EASY_SDK_OPERATING_MODE_MISMATCH = 13, // Operating mode is not appropriate for this function
47+
EASY_SDK_ADD_PARAM_FAIL = 21, // Failed to add parameter
48+
EASY_SDK_COMMAND_IS_EMPTY = 22, // No command to execute
49+
EASY_SDK_DUPLICATE_ID = 23, // Duplicate ID in staged commands
50+
EASY_SDK_FAIL_TO_GET_DATA = 24 // Failed to get data from motor
51+
};
52+
53+
template<typename T, typename E>
54+
class Result
55+
{
56+
private:
57+
std::variant<T, E> result;
58+
59+
public:
60+
Result() = default;
61+
Result(const T & return_value)
62+
: result(return_value)
63+
{}
64+
65+
Result(const E & error)
66+
: result(error)
67+
{}
68+
69+
bool isSuccess() const
70+
{
71+
return std::holds_alternative<T>(result);
72+
}
73+
74+
T & value()
75+
{
76+
if (!isSuccess()) {throw std::logic_error("Result has no value.");}
77+
return std::get<T>(result);
78+
}
79+
const T & value() const
80+
{
81+
if (!isSuccess()) {throw std::logic_error("Result has no value.");}
82+
return std::get<T>(result);
83+
}
84+
85+
E & error()
86+
{
87+
if (isSuccess()) {throw std::logic_error("Result has no error.");}
88+
return std::get<E>(result);
89+
}
90+
91+
const E & error() const
92+
{
93+
if (isSuccess()) {throw std::logic_error("Result has no error.");}
94+
return std::get<E>(result);
95+
}
96+
};
97+
98+
template<typename E>
99+
class Result<void, E>
100+
{
101+
private:
102+
std::variant<std::monostate, E> result;
103+
104+
public:
105+
Result()
106+
: result(std::monostate{})
107+
{}
108+
109+
Result(const E & error)
110+
: result(error)
111+
{}
112+
113+
bool isSuccess() const
114+
{
115+
return std::holds_alternative<std::monostate>(result);
116+
}
117+
118+
E & error()
119+
{
120+
if (!std::holds_alternative<E>(result)) {
121+
throw std::logic_error("Result has no error.");
122+
}
123+
return std::get<E>(result);
124+
}
125+
126+
const E & error() const
127+
{
128+
if (!std::holds_alternative<E>(result)) {
129+
throw std::logic_error("Result has no error.");
130+
}
131+
return std::get<E>(result);
132+
}
133+
};
134+
135+
class DxlRuntimeError : public std::runtime_error
136+
{
137+
public:
138+
explicit DxlRuntimeError(const std::string & message)
139+
: std::runtime_error(message) {}
140+
};
141+
142+
std::string getErrorMessage(DxlError error_code);
143+
} // namespace dynamixel
144+
145+
#endif /* DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_EASY_SDK_DYNAMIXEL_ERROR_HPP_ */

0 commit comments

Comments
 (0)