Skip to content

Commit 707e8d7

Browse files
author
Shota Aoki
authored
XH430、XH540、PH42クラスを追加 (#22)
* xh430, xh540クラスを追加 * ジョイントクラスにXHシリーズのインスタンス生成を追加 * PH42クラスを追加 * dynamixel_pのテストを追加
1 parent 17b384b commit 707e8d7

15 files changed

+1131
-0
lines changed
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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_P_HPP_
16+
#define RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_P_HPP_
17+
18+
#include <string>
19+
#include <vector>
20+
21+
#include "dynamixel_base.hpp"
22+
23+
namespace dynamixel_p {
24+
25+
class DynamixelP : public dynamixel_base::DynamixelBase {
26+
public:
27+
explicit DynamixelP(const uint8_t id, const int home_position = 0);
28+
29+
bool read_operating_mode(const dynamixel_base::comm_t & comm, uint8_t & mode);
30+
bool write_operating_mode(const dynamixel_base::comm_t & comm, const uint8_t mode);
31+
bool read_current_limit(const dynamixel_base::comm_t & comm, double & limit_ampere);
32+
bool read_max_position_limit(const dynamixel_base::comm_t & comm, double & limit_radian);
33+
bool read_min_position_limit(const dynamixel_base::comm_t & comm, double & limit_radian);
34+
35+
bool write_torque_enable(const dynamixel_base::comm_t & comm, const bool enable);
36+
37+
bool write_velocity_i_gain(const dynamixel_base::comm_t & comm, const unsigned int gain);
38+
bool write_velocity_p_gain(const dynamixel_base::comm_t & comm, const unsigned int gain);
39+
bool write_position_d_gain(const dynamixel_base::comm_t & comm, const unsigned int gain);
40+
bool write_position_i_gain(const dynamixel_base::comm_t & comm, const unsigned int gain);
41+
bool write_position_p_gain(const dynamixel_base::comm_t & comm, const unsigned int gain);
42+
43+
bool write_profile_acceleration(
44+
const dynamixel_base::comm_t & comm, const double acceleration_rpss);
45+
bool write_profile_velocity(
46+
const dynamixel_base::comm_t & comm, const double velocity_rps);
47+
48+
unsigned int to_profile_acceleration(const double acceleration_rpss);
49+
unsigned int to_profile_velocity(const double velocity_rps);
50+
double to_position_radian(const int position);
51+
double to_velocity_rps(const int velocity);
52+
double to_current_ampere(const int current);
53+
double to_voltage_volt(const int voltage);
54+
unsigned int from_position_radian(const double position_rad);
55+
unsigned int from_velocity_rps(const double velocity_rps);
56+
unsigned int from_current_ampere(const double current_ampere);
57+
58+
bool auto_set_indirect_address_of_present_position(const dynamixel_base::comm_t & comm);
59+
bool auto_set_indirect_address_of_present_velocity(const dynamixel_base::comm_t & comm);
60+
bool auto_set_indirect_address_of_present_current(const dynamixel_base::comm_t & comm);
61+
bool auto_set_indirect_address_of_present_input_voltage(const dynamixel_base::comm_t & comm);
62+
bool auto_set_indirect_address_of_present_temperature(const dynamixel_base::comm_t & comm);
63+
bool auto_set_indirect_address_of_goal_position(const dynamixel_base::comm_t & comm);
64+
bool auto_set_indirect_address_of_goal_velocity(const dynamixel_base::comm_t & comm);
65+
bool auto_set_indirect_address_of_goal_current(const dynamixel_base::comm_t & comm);
66+
67+
unsigned int indirect_addr_of_present_position(void);
68+
unsigned int indirect_addr_of_present_velocity(void);
69+
unsigned int indirect_addr_of_present_current(void);
70+
unsigned int indirect_addr_of_present_input_voltage(void);
71+
unsigned int indirect_addr_of_present_temperature(void);
72+
unsigned int indirect_addr_of_goal_position(void);
73+
unsigned int indirect_addr_of_goal_velocity(void);
74+
unsigned int indirect_addr_of_goal_current(void);
75+
76+
unsigned int start_address_for_indirect_read(void);
77+
unsigned int length_of_indirect_data_read(void);
78+
unsigned int next_indirect_addr_read(void) const;
79+
80+
unsigned int start_address_for_indirect_write(void);
81+
unsigned int length_of_indirect_data_write(void);
82+
unsigned int next_indirect_addr_write(void) const;
83+
84+
bool extract_present_position_from_sync_read(
85+
const dynamixel_base::comm_t & comm, const std::string & group_name,
86+
double & position_rad);
87+
bool extract_present_velocity_from_sync_read(
88+
const dynamixel_base::comm_t & comm, const std::string & group_name,
89+
double & velocity_rps);
90+
bool extract_present_current_from_sync_read(
91+
const dynamixel_base::comm_t & comm, const std::string & group_name,
92+
double & current_ampere);
93+
bool extract_present_input_voltage_from_sync_read(
94+
const dynamixel_base::comm_t & comm, const std::string & group_name,
95+
double & voltage_volt);
96+
bool extract_present_temperature_from_sync_read(
97+
const dynamixel_base::comm_t & comm, const std::string & group_name,
98+
int & temperature_deg);
99+
100+
void push_back_position_for_sync_write(
101+
const double position_rad, std::vector<uint8_t> & write_data);
102+
void push_back_velocity_for_sync_write(
103+
const double velocity_rps, std::vector<uint8_t> & write_data);
104+
void push_back_current_for_sync_write(
105+
const double current_ampere, std::vector<uint8_t> & write_data);
106+
107+
protected:
108+
int HOME_POSITION_;
109+
unsigned int total_length_of_indirect_addr_read_;
110+
unsigned int total_length_of_indirect_addr_write_;
111+
uint16_t indirect_addr_of_present_position_;
112+
uint16_t indirect_addr_of_present_velocity_;
113+
uint16_t indirect_addr_of_present_current_;
114+
uint16_t indirect_addr_of_present_input_voltage_;
115+
uint16_t indirect_addr_of_present_temperature_;
116+
uint16_t indirect_addr_of_goal_position_;
117+
uint16_t indirect_addr_of_goal_velocity_;
118+
uint16_t indirect_addr_of_goal_current_;
119+
120+
bool set_indirect_address_read(
121+
const dynamixel_base::comm_t & comm, const uint16_t addr, const uint16_t len,
122+
uint16_t & indirect_addr);
123+
bool set_indirect_address_write(
124+
const dynamixel_base::comm_t & comm, const uint16_t addr, const uint16_t len,
125+
uint16_t & indirect_addr);
126+
};
127+
128+
} // namespace dynamixel_p
129+
130+
#endif // RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_P_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_PH42_HPP_
16+
#define RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_PH42_HPP_
17+
18+
#include "dynamixel_p.hpp"
19+
20+
namespace dynamixel_ph42 {
21+
22+
class DynamixelPH42 : public dynamixel_p::DynamixelP {
23+
public:
24+
explicit DynamixelPH42(const uint8_t id);
25+
};
26+
27+
} // namespace dynamixel_ph42
28+
29+
#endif // RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_PH42_HPP_
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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_XH430_HPP_
16+
#define RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XH430_HPP_
17+
18+
#include "dynamixel_x.hpp"
19+
20+
namespace dynamixel_xh430 {
21+
22+
class DynamixelXH430 : public dynamixel_x::DynamixelX {
23+
public:
24+
explicit DynamixelXH430(const uint8_t id);
25+
double to_current_ampere(const int current) override;
26+
unsigned int from_current_ampere(const double current_ampere) override;
27+
};
28+
29+
} // namespace dynamixel_xh430
30+
31+
#endif // RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XH430_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_XH540_HPP_
16+
#define RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XH540_HPP_
17+
18+
#include "dynamixel_x.hpp"
19+
20+
namespace dynamixel_xh540 {
21+
22+
class DynamixelXH540 : public dynamixel_x::DynamixelX {
23+
public:
24+
explicit DynamixelXH540(const uint8_t id);
25+
};
26+
27+
} // namespace dynamixel_xh540
28+
29+
#endif // RT_MANIPULATORS_LIB_INCLUDE_DYNAMIXEL_XH540_HPP_

rt_manipulators_lib/src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ add_library(${library_name}
1515
dynamixel_x.cpp
1616
dynamixel_xm430.cpp
1717
dynamixel_xm540.cpp
18+
dynamixel_xh430.cpp
19+
dynamixel_xh540.cpp
20+
dynamixel_p.cpp
21+
dynamixel_ph42.cpp
1822
)
1923
set_target_properties(${library_name} PROPERTIES VERSION 1.1.0 SOVERSION 1)
2024

0 commit comments

Comments
 (0)