Skip to content

Commit 6ae113a

Browse files
authored
Merge pull request ROBOTIS-GIT#445 from ROBOTIS-GIT/develop
ROS example
2 parents 7138984 + f823a2d commit 6ae113a

Some content is hidden

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

52 files changed

+370
-59
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 15 additions & 55 deletions

ReleaseNote.md

Lines changed: 6 additions & 0 deletions

c++/src/dynamixel_sdk/port_handler_linux.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,27 @@
5555
// or if you have another good idea that can be an alternatives,
5656
// please give us advice via github issue https://github.com/ROBOTIS-GIT/DynamixelSDK/issues
5757

58+
struct termios2 {
59+
tcflag_t c_iflag; /* input mode flags */
60+
tcflag_t c_oflag; /* output mode flags */
61+
tcflag_t c_cflag; /* control mode flags */
62+
tcflag_t c_lflag; /* local mode flags */
63+
cc_t c_line; /* line discipline */
64+
cc_t c_cc[19]; /* control characters */
65+
speed_t c_ispeed; /* input speed */
66+
speed_t c_ospeed; /* output speed */
67+
};
68+
69+
#ifndef TCGETS2
70+
#define TCGETS2 _IOR('T', 0x2A, struct termios2)
71+
#endif
72+
#ifndef TCSETS2
73+
#define TCSETS2 _IOW('T', 0x2B, struct termios2)
74+
#endif
75+
#ifndef BOTHER
76+
#define BOTHER 0010000
77+
#endif
78+
5879
using namespace dynamixel;
5980

6081
PortHandlerLinux::PortHandlerLinux(const char *port_name)
@@ -207,6 +228,19 @@ bool PortHandlerLinux::setupPort(int cflag_baud)
207228

208229
bool PortHandlerLinux::setCustomBaudrate(int speed)
209230
{
231+
struct termios2 options;
232+
233+
if (ioctl(socket_fd_, TCGETS2, &options) != 01)
234+
{
235+
options.c_cflag &= ~CBAUD;
236+
options.c_cflag |= BOTHER;
237+
options.c_ispeed = speed;
238+
options.c_ospeed = speed;
239+
240+
if (ioctl(socket_fd_, TCSETS2, &options) != -1)
241+
return true;
242+
}
243+
210244
// try to set a custom divisor
211245
struct serial_struct ss;
212246
if(ioctl(socket_fd_, TIOCGSERIAL, &ss) != 0)

c/src/dynamixel_sdk/port_handler_linux.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,27 @@
5656
// or if you have another good idea that can be an alternatives,
5757
// please give us advice via github issue https://github.com/ROBOTIS-GIT/DynamixelSDK/issues
5858

59+
struct termios2 {
60+
tcflag_t c_iflag; /* input mode flags */
61+
tcflag_t c_oflag; /* output mode flags */
62+
tcflag_t c_cflag; /* control mode flags */
63+
tcflag_t c_lflag; /* local mode flags */
64+
cc_t c_line; /* line discipline */
65+
cc_t c_cc[19]; /* control characters */
66+
speed_t c_ispeed; /* input speed */
67+
speed_t c_ospeed; /* output speed */
68+
};
69+
70+
#ifndef TCGETS2
71+
#define TCGETS2 _IOR('T', 0x2A, struct termios2)
72+
#endif
73+
#ifndef TCSETS2
74+
#define TCSETS2 _IOW('T', 0x2B, struct termios2)
75+
#endif
76+
#ifndef BOTHER
77+
#define BOTHER 0010000
78+
#endif
79+
5980
typedef struct
6081
{
6182
int socket_fd;
@@ -263,6 +284,19 @@ uint8_t setupPortLinux(int port_num, int cflag_baud)
263284

264285
uint8_t setCustomBaudrateLinux(int port_num, int speed)
265286
{
287+
struct termios2 options;
288+
289+
if (ioctl(portData[port_num].socket_fd, TCGETS2, &options) != 01)
290+
{
291+
options.c_cflag &= ~CBAUD;
292+
options.c_cflag |= BOTHER;
293+
options.c_ispeed = speed;
294+
options.c_ospeed = speed;
295+
296+
if (ioctl(portData[port_num].socket_fd, TCSETS2, &options) != -1)
297+
return True;
298+
}
299+
266300
// try to set a custom divisor
267301
struct serial_struct ss;
268302
if (ioctl(portData[port_num].socket_fd, TIOCGSERIAL, &ss) != 0)

python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
setup(
66
name='dynamixel_sdk',
7-
version='3.7.31',
7+
version='3.7.41',
88
packages=['dynamixel_sdk'],
99
package_dir={'': 'src'},
1010
license='Apache 2.0',

python/tests/protocol1_0/read_write.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ def getch():
116116
break
117117

118118
# Write goal position
119-
dxl_comm_result, dxl_error = packetHandler.write4ByteTxRx(portHandler, DXL_ID, ADDR_MX_GOAL_POSITION, dxl_goal_position[index])
119+
dxl_comm_result, dxl_error = packetHandler.write2ByteTxRx(portHandler, DXL_ID, ADDR_MX_GOAL_POSITION, dxl_goal_position[index])
120120
if dxl_comm_result != COMM_SUCCESS:
121121
print("%s" % packetHandler.getTxRxResult(dxl_comm_result))
122122
elif dxl_error != 0:
123123
print("%s" % packetHandler.getRxPacketError(dxl_error))
124124

125125
while 1:
126126
# Read present position
127-
dxl_present_position, dxl_comm_result, dxl_error = packetHandler.read4ByteTxRx(portHandler, DXL_ID, ADDR_MX_PRESENT_POSITION)
127+
dxl_present_position, dxl_comm_result, dxl_error = packetHandler.read2ByteTxRx(portHandler, DXL_ID, ADDR_MX_PRESENT_POSITION)
128128
if dxl_comm_result != COMM_SUCCESS:
129129
print("%s" % packetHandler.getTxRxResult(dxl_comm_result))
130130
elif dxl_error != 0:
Lines changed: 6 additions & 0 deletions
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)