Skip to content

Commit 65bc609

Browse files
author
Shota Aoki
authored
Dynamixelクラスの追加 (#17)
* Lintでdynamixelディレクトリをチェックする * dynamixelクラスを追加し、hardwareクラスに組み込む * ライブラリのREADMEにファイルの説明を追加 * sample01のREADMEのコンフィグファイルにdynamixel情報を追加 * 各コンフィグファイルにDynamixel情報を追加 * ライブラリのバージョンを1.1.0に更新 * includeを修正 * 親ディレクトリのincludeが発生していたため、dynamixelフォルダを削除した * README修正 * ADDR_TORQUE_ENABLEをhardwareから削除 * 使用していない定数を削除
1 parent 06e5e17 commit 65bc609

32 files changed

+484
-165
lines changed

rt_manipulators_lib/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ $ ./uninstall_library.bash
7070
- `hardware_communicator.hpp/cpp` : `Hardware`クラスのうち、Dynamixelとの通信機能を実装しています
7171
- `hardware_joints.hpp/cpp` : `Hardware`クラスのうち、ジョイント情報を扱う機能を実装しています
7272
- `joints.hpp/cpp` : ジョイント情報を定義しています
73+
- `config_file_parser.hpp/cpp` : コンフィグファイルの読み取りを担います
74+
- `dynamixel_*` : 各Dynamixelと通信するためのデータ変換を担います
7375

7476
### 運動学関連
7577

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2022 RT Corporation
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+
#ifndef RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_BASE_HPP_
16+
#define RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_BASE_HPP_
17+
18+
#include <memory>
19+
#include <string>
20+
21+
#include "hardware_communicator.hpp"
22+
23+
namespace dynamixel_base {
24+
25+
using comm_t = std::shared_ptr<hardware_communicator::Communicator>;
26+
27+
class DynamixelBase {
28+
public:
29+
explicit DynamixelBase(const uint8_t id) : id_(id), name_("base") {}
30+
~DynamixelBase() {}
31+
32+
uint8_t get_id() const { return id_; }
33+
std::string get_name() const { return name_; }
34+
virtual bool write_torque_enable(
35+
const dynamixel_base::comm_t & comm, const bool enable) { return false; }
36+
37+
protected:
38+
uint8_t id_;
39+
std::string name_;
40+
};
41+
42+
} // namespace dynamixel_base
43+
44+
#endif // RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_BASE_HPP_
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2022 RT Corporation
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+
#ifndef RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM_HPP_
16+
#define RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM_HPP_
17+
18+
#include "dynamixel_base.hpp"
19+
20+
namespace dynamixel_xm {
21+
22+
class DynamixelXM : public dynamixel_base::DynamixelBase {
23+
public:
24+
explicit DynamixelXM(const uint8_t id);
25+
bool write_torque_enable(const dynamixel_base::comm_t & comm, const bool enable);
26+
};
27+
28+
} // namespace dynamixel_xm
29+
30+
#endif // RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM_HPP_
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2022 RT Corporation
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+
#ifndef RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM430_HPP_
16+
#define RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM430_HPP_
17+
18+
#include "dynamixel_xm.hpp"
19+
20+
namespace dynamixel_xm430 {
21+
22+
class DynamixelXM430 : public dynamixel_xm::DynamixelXM {
23+
public:
24+
explicit DynamixelXM430(const uint8_t id);
25+
};
26+
27+
} // namespace dynamixel_xm430
28+
29+
#endif // RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM430_HPP_
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2022 RT Corporation
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+
#ifndef RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM540_HPP_
16+
#define RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM540_HPP_
17+
18+
#include "dynamixel_xm.hpp"
19+
20+
namespace dynamixel_xm540 {
21+
22+
class DynamixelXM540 : public dynamixel_xm::DynamixelXM {
23+
public:
24+
explicit DynamixelXM540(const uint8_t id);
25+
};
26+
27+
} // namespace dynamixel_xm540
28+
29+
#endif // RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XM540_HPP_

rt_manipulators_lib/include/hardware.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ class Hardware {
8686
const uint16_t i);
8787

8888
protected:
89-
bool write_byte_data_to_group(const std::string& group_name, const uint16_t address,
90-
const uint8_t write_data);
9189
bool write_word_data_to_group(const std::string& group_name, const uint16_t address,
9290
const uint16_t write_data);
9391
bool write_double_word_data_to_group(const std::string& group_name, const uint16_t address,

rt_manipulators_lib/include/joint.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
#define RT_MANIPULATORS_LIB_INCLUDE_JOINT_HPP_
1717

1818
#include <cstdint>
19+
#include <memory>
1920
#include <string>
2021
#include <vector>
2122

23+
#include "dynamixel_base.hpp"
24+
2225
namespace joint {
2326

2427
class Joint {
2528
public:
2629
Joint(const uint8_t id, const uint8_t operating_mode);
30+
Joint(const uint8_t id, const uint8_t operating_mode, const std::string dynamixel_name);
2731
uint8_t id() const;
2832
uint8_t operating_mode() const;
2933
void set_position_limit_margin(const double position_radian);
@@ -50,6 +54,8 @@ class Joint {
5054
double get_goal_velocity() const;
5155
double get_goal_current() const;
5256

57+
std::shared_ptr<dynamixel_base::DynamixelBase> dxl;
58+
5359
private:
5460
uint8_t id_;
5561
uint8_t operating_mode_;

rt_manipulators_lib/src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ add_library(${library_name}
1212
kinematics.cpp
1313
kinematics_utils.cpp
1414
config_file_parser.cpp
15+
dynamixel_xm.cpp
16+
dynamixel_xm430.cpp
17+
dynamixel_xm540.cpp
1518
)
16-
set_target_properties(${library_name} PROPERTIES VERSION 1.0.0 SOVERSION 1)
19+
set_target_properties(${library_name} PROPERTIES VERSION 1.1.0 SOVERSION 1)
1720

1821
target_include_directories(${library_name} PUBLIC
1922
${PROJECT_SOURCE_DIR}/include

rt_manipulators_lib/src/config_file_parser.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,21 @@ bool parse(const std::string& config_yaml, hardware_joints::Joints & parsed_join
6464
joint_names.push_back(joint_name);
6565
auto joint_id = config[joint_name]["id"].as<int>();
6666
auto ope_mode = config[joint_name]["operating_mode"].as<int>();
67+
std::string dynamixel_name = "";
6768
double position_limit_margin = 0;
6869
double current_limit_margin = 0;
70+
71+
if (config[joint_name]["dynamixel"]) {
72+
dynamixel_name = config[joint_name]["dynamixel"].as<std::string>();
73+
}
6974
if (config[joint_name]["pos_limit_margin"]) {
7075
position_limit_margin = config[joint_name]["pos_limit_margin"].as<double>();
7176
}
7277
if (config[joint_name]["current_limit_margin"]) {
7378
current_limit_margin = config[joint_name]["current_limit_margin"].as<double>();
7479
}
7580

76-
auto joint = joint::Joint(joint_id, ope_mode);
81+
auto joint = joint::Joint(joint_id, ope_mode, dynamixel_name);
7782
joint.set_position_limit_margin(position_limit_margin);
7883
joint.set_current_limit_margin(current_limit_margin);
7984
parsed_joints.append_joint(joint_name, joint);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2022 RT Corporation
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+
16+
#include "dynamixel_xm.hpp"
17+
18+
19+
namespace dynamixel_xm {
20+
21+
const uint16_t ADDR_TORQUE_ENABLE = 64;
22+
23+
DynamixelXM::DynamixelXM(const uint8_t id)
24+
: dynamixel_base::DynamixelBase(id) {
25+
name_ = "XM";
26+
}
27+
28+
bool DynamixelXM::write_torque_enable(const dynamixel_base::comm_t & comm, const bool enable) {
29+
return comm->write_byte_data(id_, ADDR_TORQUE_ENABLE, enable);
30+
}
31+
32+
} // namespace dynamixel_xm

0 commit comments

Comments
 (0)