Skip to content

Commit a7258fa

Browse files
committed
FastSyncRead, FastBulkRead implementation
1 parent ef7ae1f commit a7258fa

20 files changed

+552
-153
lines changed

c++/include/dynamixel_sdk/dynamixel_sdk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "group_bulk_write.h"
2828
#include "group_sync_read.h"
2929
#include "group_sync_write.h"
30+
#include "group_fast_sync_read.h"
31+
#include "group_fast_bulk_read.h"
3032
#include "packet_handler.h"
3133
#include "port_handler.h"
3234

c++/include/dynamixel_sdk/group_bulk_read.h

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,28 @@
2323
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPBULKREAD_H_
2424

2525

26-
#include <map>
27-
#include <vector>
2826
#include "port_handler.h"
2927
#include "packet_handler.h"
28+
#include "group_handler.h"
3029

3130
namespace dynamixel
3231
{
3332

3433
////////////////////////////////////////////////////////////////////////////////
3534
/// @brief The class for reading multiple Dynamixel data from different addresses with different lengths at once
3635
////////////////////////////////////////////////////////////////////////////////
37-
class WINDECLSPEC GroupBulkRead
36+
class WINDECLSPEC GroupBulkRead : public GroupHandler
3837
{
39-
private:
40-
PortHandler *port_;
41-
PacketHandler *ph_;
38+
protected:
39+
std::map<uint8_t, uint16_t> address_list_; // <id, start_address>
40+
std::map<uint8_t, uint16_t> length_list_; // <id, data_length>
41+
std::map<uint8_t, uint8_t *> error_list_; // <id, error>
4242

43-
std::vector<uint8_t> id_list_;
44-
std::map<uint8_t, uint16_t> address_list_; // <id, start_address>
45-
std::map<uint8_t, uint16_t> length_list_; // <id, data_length>
46-
std::map<uint8_t, uint8_t *> data_list_; // <id, data>
47-
std::map<uint8_t, uint8_t *> error_list_; // <id, error>
43+
bool last_result_;
4844

49-
bool last_result_;
50-
bool is_param_changed_;
45+
void makeParam();
5146

52-
uint8_t *param_;
53-
54-
void makeParam();
55-
56-
public:
47+
public:
5748
////////////////////////////////////////////////////////////////////////////////
5849
/// @brief The function that Initializes instance for Bulk Read
5950
/// @param port PortHandler instance
@@ -66,18 +57,6 @@ class WINDECLSPEC GroupBulkRead
6657
////////////////////////////////////////////////////////////////////////////////
6758
~GroupBulkRead() { clearParam(); }
6859

69-
////////////////////////////////////////////////////////////////////////////////
70-
/// @brief The function that returns PortHandler instance
71-
/// @return PortHandler instance
72-
////////////////////////////////////////////////////////////////////////////////
73-
PortHandler *getPortHandler() { return port_; }
74-
75-
////////////////////////////////////////////////////////////////////////////////
76-
/// @brief The function that returns PacketHandler instance
77-
/// @return PacketHandler instance
78-
////////////////////////////////////////////////////////////////////////////////
79-
PacketHandler *getPacketHandler() { return ph_; }
80-
8160
////////////////////////////////////////////////////////////////////////////////
8261
/// @brief The function that adds id, start_address, data_length to the Bulk Read list
8362
/// @param id Dynamixel ID

c++/include/dynamixel_sdk/group_bulk_write.h

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,27 @@
2323
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPBULKWRITE_H_
2424

2525

26-
#include <map>
27-
#include <vector>
2826
#include "port_handler.h"
2927
#include "packet_handler.h"
28+
#include "group_handler.h"
3029

3130
namespace dynamixel
3231
{
3332

3433
////////////////////////////////////////////////////////////////////////////////
3534
/// @brief The class for writing multiple Dynamixel data from different addresses with different lengths at once
3635
////////////////////////////////////////////////////////////////////////////////
37-
class WINDECLSPEC GroupBulkWrite
36+
class WINDECLSPEC GroupBulkWrite : public GroupHandler
3837
{
39-
private:
40-
PortHandler *port_;
41-
PacketHandler *ph_;
38+
private:
39+
std::map<uint8_t, uint16_t> address_list_; // <id, start_address>
40+
std::map<uint8_t, uint16_t> length_list_; // <id, data_length>
4241

43-
std::vector<uint8_t> id_list_;
44-
std::map<uint8_t, uint16_t> address_list_; // <id, start_address>
45-
std::map<uint8_t, uint16_t> length_list_; // <id, data_length>
46-
std::map<uint8_t, uint8_t *> data_list_; // <id, data>
42+
uint16_t param_length_;
4743

48-
bool is_param_changed_;
44+
void makeParam();
4945

50-
uint8_t *param_;
51-
uint16_t param_length_;
52-
53-
void makeParam();
54-
55-
public:
46+
public:
5647
////////////////////////////////////////////////////////////////////////////////
5748
/// @brief The function that Initializes instance for Bulk Write
5849
/// @param port PortHandler instance
@@ -65,18 +56,6 @@ class WINDECLSPEC GroupBulkWrite
6556
////////////////////////////////////////////////////////////////////////////////
6657
~GroupBulkWrite() { clearParam(); }
6758

68-
////////////////////////////////////////////////////////////////////////////////
69-
/// @brief The function that returns PortHandler instance
70-
/// @return PortHandler instance
71-
////////////////////////////////////////////////////////////////////////////////
72-
PortHandler *getPortHandler() { return port_; }
73-
74-
////////////////////////////////////////////////////////////////////////////////
75-
/// @brief The function that returns PacketHandler instance
76-
/// @return PacketHandler instance
77-
////////////////////////////////////////////////////////////////////////////////
78-
PacketHandler *getPacketHandler() { return ph_; }
79-
8059
////////////////////////////////////////////////////////////////////////////////
8160
/// @brief The function that adds id, start_address, data_length to the Bulk Write list
8261
/// @param id Dynamixel ID
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*******************************************************************************
2+
* Copyright 2017 ROBOTIS CO., LTD.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
17+
////////////////////////////////////////////////////////////////////////////////
18+
/// @file The file for Dynamixel Fast Bulk Read
19+
/// @author Honghyun Kim
20+
////////////////////////////////////////////////////////////////////////////////
21+
22+
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPFASTBULKREAD_H
23+
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPFASTBULKREAD_H
24+
25+
26+
#include "group_bulk_read.h"
27+
28+
namespace dynamixel
29+
{
30+
31+
class WINDECLSPEC GroupFastBulkRead : public GroupBulkRead
32+
{
33+
public:
34+
GroupFastBulkRead(PortHandler *port, PacketHandler *ph);
35+
~GroupFastBulkRead() { clearParam(); }
36+
37+
int txPacket();
38+
int rxPacket();
39+
int txRxPacket();
40+
41+
private:
42+
void makeParam();
43+
};
44+
45+
}
46+
47+
48+
#endif // DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPFASTBULKREAD_H
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*******************************************************************************
2+
* Copyright 2017 ROBOTIS CO., LTD.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
17+
////////////////////////////////////////////////////////////////////////////////
18+
/// @file The file for Dynamixel Fast Sync Read
19+
/// @author Honghyun Kim
20+
////////////////////////////////////////////////////////////////////////////////
21+
22+
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPFASTSYNCREAD_H
23+
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPFASTSYNCREAD_H
24+
25+
26+
#include "group_sync_read.h"
27+
28+
namespace dynamixel
29+
{
30+
31+
class WINDECLSPEC GroupFastSyncRead : public GroupSyncRead
32+
{
33+
public:
34+
GroupFastSyncRead(PortHandler *port, PacketHandler *ph, uint16_t start_address, uint16_t data_length);
35+
~GroupFastSyncRead() { clearParam(); }
36+
37+
int txPacket();
38+
int rxPacket();
39+
int txRxPacket();
40+
};
41+
42+
}
43+
44+
45+
#endif // DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPFASTSYNCREAD_H
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*******************************************************************************
2+
* Copyright 2017 ROBOTIS CO., LTD.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
17+
////////////////////////////////////////////////////////////////////////////////
18+
/// @file The file for Group Handler
19+
/// @author Honghyun Kim
20+
////////////////////////////////////////////////////////////////////////////////
21+
22+
#ifndef DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPHANDLER_H
23+
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPHANDLER_H
24+
25+
26+
#include <map>
27+
#include <vector>
28+
#include "port_handler.h"
29+
#include "packet_handler.h"
30+
31+
namespace dynamixel
32+
{
33+
34+
class WINDECLSPEC GroupHandler
35+
{
36+
public:
37+
GroupHandler(PortHandler *port, PacketHandler *ph);
38+
39+
PortHandler *getPortHandler() { return port_; }
40+
PacketHandler *getPacketHandler() { return ph_; }
41+
42+
protected:
43+
PortHandler *port_;
44+
PacketHandler *ph_;
45+
46+
std::vector<uint8_t> id_list_;
47+
std::map<uint8_t, uint8_t *> data_list_; // <id, data>
48+
49+
bool is_param_changed_;
50+
51+
uint8_t *param_;
52+
};
53+
54+
}
55+
56+
57+
#endif // DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPHANDLER_H

c++/include/dynamixel_sdk/group_sync_read.h

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,29 @@
2323
#define DYNAMIXEL_SDK_INCLUDE_DYNAMIXEL_SDK_GROUPSYNCREAD_H_
2424

2525

26-
#include <map>
27-
#include <vector>
2826
#include "port_handler.h"
2927
#include "packet_handler.h"
28+
#include "group_handler.h"
3029

3130
namespace dynamixel
3231
{
3332

3433
////////////////////////////////////////////////////////////////////////////////
3534
/// @brief The class for reading multiple Dynamixel data from same address with same length at once
3635
////////////////////////////////////////////////////////////////////////////////
37-
class WINDECLSPEC GroupSyncRead
36+
class WINDECLSPEC GroupSyncRead : public GroupHandler
3837
{
39-
private:
40-
PortHandler *port_;
41-
PacketHandler *ph_;
38+
protected:
39+
std::map<uint8_t, uint8_t *> error_list_; // <id, error>
4240

43-
std::vector<uint8_t> id_list_;
44-
std::map<uint8_t, uint8_t *> data_list_; // <id, data>
45-
std::map<uint8_t, uint8_t *> error_list_; // <id, error>
41+
bool last_result_;
4642

47-
bool last_result_;
48-
bool is_param_changed_;
43+
uint16_t start_address_;
44+
uint16_t data_length_;
4945

50-
uint8_t *param_;
51-
uint16_t start_address_;
52-
uint16_t data_length_;
46+
void makeParam();
5347

54-
void makeParam();
55-
56-
public:
48+
public:
5749
////////////////////////////////////////////////////////////////////////////////
5850
/// @brief The function that Initializes instance for Sync Read
5951
/// @param port PortHandler instance
@@ -68,18 +60,6 @@ class WINDECLSPEC GroupSyncRead
6860
////////////////////////////////////////////////////////////////////////////////
6961
~GroupSyncRead() { clearParam(); }
7062

71-
////////////////////////////////////////////////////////////////////////////////
72-
/// @brief The function that returns PortHandler instance
73-
/// @return PortHandler instance
74-
////////////////////////////////////////////////////////////////////////////////
75-
PortHandler *getPortHandler() { return port_; }
76-
77-
////////////////////////////////////////////////////////////////////////////////
78-
/// @brief The function that returns PacketHandler instance
79-
/// @return PacketHandler instance
80-
////////////////////////////////////////////////////////////////////////////////
81-
PacketHandler *getPacketHandler() { return ph_; }
82-
8363
////////////////////////////////////////////////////////////////////////////////
8464
/// @brief The function that adds id, start_address, data_length to the Sync Read list
8565
/// @param id Dynamixel ID

0 commit comments

Comments
 (0)