Skip to content

Commit 889a4aa

Browse files
committed
- modified "ros" directory C++ code.
1 parent 86e6a72 commit 889a4aa

File tree

5 files changed

+59
-0
lines changed

5 files changed

+59
-0
lines changed

ros/include/dynamixel_sdk/packet_handler.h

100644100755
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#define INST_BULK_READ 146 // 0x92
5353
// --- Only for 2.0 --- //
5454
#define INST_REBOOT 8
55+
#define INST_CLEAR 16 // 0x10
5556
#define INST_STATUS 85 // 0x55
5657
#define INST_SYNC_READ 130 // 0x82
5758
#define INST_BULK_WRITE 147 // 0x93
@@ -222,6 +223,19 @@ class WINDECLSPEC PacketHandler
222223
////////////////////////////////////////////////////////////////////////////////
223224
virtual int reboot (PortHandler *port, uint8_t id, uint8_t *error = 0) = 0;
224225

226+
////////////////////////////////////////////////////////////////////////////////
227+
/// @brief The function that reset multi-turn revolution information of Dynamixel
228+
/// @description The function makes an instruction packet with INST_CLEAR,
229+
/// @description transmits the packet with PacketHandler::txRxPacket().
230+
/// @description Applied Products : MX with Protocol 2.0 (Firmware v42 or above),
231+
/// @description Dynamixel X-series (Firmware v42 or above).
232+
/// @param port PortHandler instance
233+
/// @param id Dynamixel ID
234+
/// @param error Dynamixel hardware error
235+
/// @return communication results which come from PacketHandler::txRxPacket()
236+
////////////////////////////////////////////////////////////////////////////////
237+
virtual int clearMultiTurn (PortHandler *port, uint8_t id, uint8_t *error = 0) = 0;
238+
225239
////////////////////////////////////////////////////////////////////////////////
226240
/// @brief The function that makes Dynamixel reset as it was produced in the factory
227241
/// @description The function makes an instruction packet with INST_FACTORY_RESET,

ros/include/dynamixel_sdk/protocol1_packet_handler.h

100644100755
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ class WINDECLSPEC Protocol1PacketHandler : public PacketHandler
178178
////////////////////////////////////////////////////////////////////////////////
179179
int reboot (PortHandler *port, uint8_t id, uint8_t *error = 0);
180180

181+
////////////////////////////////////////////////////////////////////////////////
182+
/// @brief (Available only in Protocol 2.0) The function that reset multi-turn revolution information of Dynamixel
183+
/// @param port PortHandler instance
184+
/// @param id Dynamixel ID
185+
/// @param error Dynamixel hardware error
186+
/// @return COMM_NOT_AVAILABLE
187+
////////////////////////////////////////////////////////////////////////////////
188+
int clearMultiTurn (PortHandler *port, uint8_t id, uint8_t *error = 0);
189+
181190
////////////////////////////////////////////////////////////////////////////////
182191
/// @brief The function that makes Dynamixel reset as it was produced in the factory
183192
/// @description The function makes an instruction packet with INST_FACTORY_RESET,

ros/include/dynamixel_sdk/protocol2_packet_handler.h

100644100755
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,19 @@ class WINDECLSPEC Protocol2PacketHandler : public PacketHandler
186186
////////////////////////////////////////////////////////////////////////////////
187187
int reboot (PortHandler *port, uint8_t id, uint8_t *error = 0);
188188

189+
////////////////////////////////////////////////////////////////////////////////
190+
/// @brief The function that reset multi-turn revolution information of Dynamixel
191+
/// @description The function makes an instruction packet with INST_CLEAR,
192+
/// @description transmits the packet with Protocol2PacketHandler::txRxPacket().
193+
/// @description Applied Products : MX with Protocol 2.0 (Firmware v42 or above),
194+
/// @description Dynamixel X-series (Firmware v42 or above).
195+
/// @param port PortHandler instance
196+
/// @param id Dynamixel ID
197+
/// @param error Dynamixel hardware error
198+
/// @return communication results which come from Protocol2PacketHandler::txRxPacket()
199+
////////////////////////////////////////////////////////////////////////////////
200+
int clearMultiTurn (PortHandler *port, uint8_t id, uint8_t *error = 0);
201+
189202
////////////////////////////////////////////////////////////////////////////////
190203
/// @brief The function that makes Dynamixel reset as it was produced in the factory
191204
/// @description The function makes an instruction packet with INST_FACTORY_RESET,

ros/src/dynamixel_sdk/protocol1_packet_handler.cpp

100644100755
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ int Protocol1PacketHandler::reboot(PortHandler *port, uint8_t id, uint8_t *error
365365
return COMM_NOT_AVAILABLE;
366366
}
367367

368+
int Protocol1PacketHandler::clearMultiTurn(PortHandler *port, uint8_t id, uint8_t *error)
369+
{
370+
return COMM_NOT_AVAILABLE;
371+
}
372+
368373
int Protocol1PacketHandler::factoryReset(PortHandler *port, uint8_t id, uint8_t option, uint8_t *error)
369374
{
370375
uint8_t txpacket[6] = {0};

ros/src/dynamixel_sdk/protocol2_packet_handler.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,24 @@ int Protocol2PacketHandler::reboot(PortHandler *port, uint8_t id, uint8_t *error
612612
return txRxPacket(port, txpacket, rxpacket, error);
613613
}
614614

615+
int Protocol2PacketHandler::clearMultiTurn(PortHandler *port, uint8_t id, uint8_t *error)
616+
{
617+
uint8_t txpacket[15] = {0};
618+
uint8_t rxpacket[11] = {0};
619+
620+
txpacket[PKT_ID] = id;
621+
txpacket[PKT_LENGTH_L] = 8;
622+
txpacket[PKT_LENGTH_H] = 0;
623+
txpacket[PKT_INSTRUCTION] = INST_CLEAR;
624+
txpacket[PKT_PARAMETER0] = 0x01;
625+
txpacket[PKT_PARAMETER0+1] = 0x44;
626+
txpacket[PKT_PARAMETER0+2] = 0x58;
627+
txpacket[PKT_PARAMETER0+3] = 0x4C;
628+
txpacket[PKT_PARAMETER0+4] = 0x22;
629+
630+
return txRxPacket(port, txpacket, rxpacket, error);
631+
}
632+
615633
int Protocol2PacketHandler::factoryReset(PortHandler *port, uint8_t id, uint8_t option, uint8_t *error)
616634
{
617635
uint8_t txpacket[11] = {0};

0 commit comments

Comments
 (0)