Skip to content

Commit cae2fbb

Browse files
author
Shota Aoki
authored
サーボの速度、電流、入力電圧、温度を取得する機能を追加 (#3)
* for-loopをconst 参照に書き換えて、不要なコピーと値の書き換えを防ぐ * サーボの速度、電流、電圧、温度をsync_readする機能を実装 * READMEの更新 * S17のread_preset_valuesサンプル追加 * ライブラリ:関数名の誤記修正 * サンプル:ID、ジョイント名で��ラメータを読み取るサンプルを追加
1 parent 1fc7fd4 commit cae2fbb

File tree

10 files changed

+844
-38
lines changed

10 files changed

+844
-38
lines changed

‎rt_manipulators_lib/include/hardware.hpp‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ class Hardware {
4747
bool get_position(const uint8_t id, double& position);
4848
bool get_position(const std::string& joint_name, double& position);
4949
bool get_positions(const std::string& group_name, std::vector<double>& positions);
50+
bool get_velocity(const uint8_t id, double& velocity);
51+
bool get_velocity(const std::string& joint_name, double& velocity);
52+
bool get_velocities(const std::string& group_name, std::vector<double>& velocities);
53+
bool get_current(const uint8_t id, double& current);
54+
bool get_current(const std::string& joint_name, double& current);
55+
bool get_currents(const std::string& group_name, std::vector<double>& currents);
56+
bool get_voltage(const uint8_t id, double& voltage);
57+
bool get_voltage(const std::string& joint_name, double& voltage);
58+
bool get_voltages(const std::string& group_name, std::vector<double>& voltages);
59+
bool get_temperature(const uint8_t id, int8_t& temperature);
60+
bool get_temperature(const std::string& joint_name, int8_t& temperature);
61+
bool get_temperatures(const std::string& group_name, std::vector<int8_t>& temperatures);
5062
bool set_position(const uint8_t id, const double position);
5163
bool set_position(const std::string& joint_name, const double position);
5264
bool set_positions(const std::string& group_name, std::vector<double>& positions);
@@ -86,6 +98,9 @@ class Hardware {
8698
const int dxl_comm_result, const uint8_t dxl_packet_error);
8799
bool parse_dxl_error(const std::string& func_name, const int dxl_comm_result);
88100
double dxl_pos_to_radian(const int32_t position);
101+
double dxl_velocity_to_rps(const int32_t velocity) const;
102+
double dxl_current_to_ampere(const int16_t current) const;
103+
double dxl_voltage_to_volt(const int16_t voltage) const;
89104
uint32_t radian_to_dxl_pos(const double position);
90105
uint32_t to_dxl_acceleration(const double acceleration_rpss);
91106
uint32_t to_dxl_velocity(const double velocity_rps);
@@ -97,7 +112,11 @@ class Hardware {
97112
std::map<uint8_t, std::shared_ptr<joint::Joint>> all_joints_ref_from_id_;
98113
std::map<JointGroupName, std::shared_ptr<dynamixel::GroupSyncRead>> sync_read_groups_;
99114
std::map<JointGroupName, std::shared_ptr<dynamixel::GroupSyncWrite>> sync_write_groups_;
100-
std::map<JointGroupName, uint16_t> address_indirect_present_position_;
115+
std::map<JointGroupName, uint16_t> addr_sync_read_position_;
116+
std::map<JointGroupName, uint16_t> addr_sync_read_velocity_;
117+
std::map<JointGroupName, uint16_t> addr_sync_read_current_;
118+
std::map<JointGroupName, uint16_t> addr_sync_read_voltage_;
119+
std::map<JointGroupName, uint16_t> addr_sync_read_temperature_;
101120
std::map<JointGroupName, uint16_t> address_indirect_goal_position_;
102121
bool thread_enable_;
103122
std::shared_ptr<std::thread> read_write_thread_;

‎rt_manipulators_lib/include/joint.hpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,26 @@ class Joint {
2727
uint8_t id() const;
2828
uint8_t operating_mode() const;
2929
void set_present_position(const double position_radian);
30+
void set_present_velocity(const double velocity_rps);
31+
void set_present_current(const double current_ampere);
32+
void set_present_voltage(const double voltage_volt);
33+
void set_present_temperature(const int8_t temperature_degree);
3034
double get_present_position() const;
35+
double get_present_velocity() const;
36+
double get_present_current() const;
37+
double get_present_voltage() const;
38+
int8_t get_present_temperature() const;
3139
void set_goal_position(const double position_radian);
3240
double get_goal_position() const;
3341

3442
private:
3543
uint8_t id_;
3644
uint8_t operating_mode_;
3745
double present_position_;
46+
double present_velocity_;
47+
double present_current_;
48+
double present_voltage_;
49+
int8_t present_temperature_;
3850
double goal_position_;
3951
};
4052

@@ -47,6 +59,7 @@ class JointGroup {
4759
bool sync_read_position_enabled() const;
4860
bool sync_read_velocity_enabled() const;
4961
bool sync_read_current_enabled() const;
62+
bool sync_read_voltage_enabled() const;
5063
bool sync_read_temperature_enabled() const;
5164
bool sync_write_position_enabled() const;
5265
bool sync_write_velocity_enabled() const;
@@ -57,6 +70,7 @@ class JointGroup {
5770
bool sync_read_position_enabled_;
5871
bool sync_read_velocity_enabled_;
5972
bool sync_read_current_enabled_;
73+
bool sync_read_voltage_enabled_;
6074
bool sync_read_temperature_enabled_;
6175
bool sync_write_position_enabled_;
6276
bool sync_write_velocity_enabled_;

0 commit comments

Comments
 (0)