-
Notifications
You must be signed in to change notification settings - Fork 364
[Transmissions] Add force
and current
interfaces
#2588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c2546cd
d6a2549
2c88988
4f29e5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -168,12 +168,16 @@ class DifferentialTransmission : public Transmission | |||||
std::vector<JointHandle> joint_velocity_; | ||||||
std::vector<JointHandle> joint_effort_; | ||||||
std::vector<JointHandle> joint_torque_; | ||||||
std::vector<JointHandle> joint_force_; | ||||||
std::vector<JointHandle> joint_curret_; | ||||||
std::vector<JointHandle> joint_absolute_position_; | ||||||
|
||||||
std::vector<ActuatorHandle> actuator_position_; | ||||||
std::vector<ActuatorHandle> actuator_velocity_; | ||||||
std::vector<ActuatorHandle> actuator_effort_; | ||||||
std::vector<ActuatorHandle> actuator_torque_; | ||||||
std::vector<ActuatorHandle> actuator_force_; | ||||||
std::vector<ActuatorHandle> actuator_current_; | ||||||
std::vector<ActuatorHandle> actuator_absolute_position_; | ||||||
}; | ||||||
|
||||||
|
@@ -236,12 +240,16 @@ void DifferentialTransmission::configure( | |||||
get_ordered_handles(joint_handles, joint_names, hardware_interface::HW_IF_VELOCITY); | ||||||
joint_effort_ = get_ordered_handles(joint_handles, joint_names, hardware_interface::HW_IF_EFFORT); | ||||||
joint_torque_ = get_ordered_handles(joint_handles, joint_names, hardware_interface::HW_IF_TORQUE); | ||||||
joint_force_ = get_ordered_handles(joint_handles, joint_names, hardware_interface::HW_IF_FORCE); | ||||||
joint_curret_ = | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
get_ordered_handles(joint_handles, joint_names, hardware_interface::HW_IF_CURRENT); | ||||||
joint_absolute_position_ = | ||||||
get_ordered_handles(joint_handles, joint_names, HW_IF_ABSOLUTE_POSITION); | ||||||
|
||||||
if ( | ||||||
joint_position_.size() != 2 && joint_velocity_.size() != 2 && joint_effort_.size() != 2 && | ||||||
joint_torque_.size() != 2 && joint_absolute_position_.size() != 2) | ||||||
joint_torque_.size() != 2 && joint_force_.size() != 2 && joint_curret_.size() != 2 && | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Comment on lines
249
to
+251
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this means that the handles are mandatory, and not optional. Does this make sense here? Shouldn't this plugin be more general? |
||||||
joint_absolute_position_.size() != 2) | ||||||
{ | ||||||
throw Exception("Not enough valid or required joint handles were presented."); | ||||||
} | ||||||
|
@@ -254,13 +262,17 @@ void DifferentialTransmission::configure( | |||||
get_ordered_handles(actuator_handles, actuator_names, hardware_interface::HW_IF_EFFORT); | ||||||
actuator_torque_ = | ||||||
get_ordered_handles(actuator_handles, actuator_names, hardware_interface::HW_IF_TORQUE); | ||||||
actuator_force_ = | ||||||
get_ordered_handles(actuator_handles, actuator_names, hardware_interface::HW_IF_FORCE); | ||||||
actuator_current_ = | ||||||
get_ordered_handles(actuator_handles, actuator_names, hardware_interface::HW_IF_CURRENT); | ||||||
actuator_absolute_position_ = | ||||||
get_ordered_handles(actuator_handles, actuator_names, HW_IF_ABSOLUTE_POSITION); | ||||||
|
||||||
if ( | ||||||
actuator_position_.size() != 2 && actuator_velocity_.size() != 2 && | ||||||
actuator_effort_.size() != 2 && actuator_torque_.size() != 2 && | ||||||
actuator_absolute_position_.size() != 2) | ||||||
actuator_effort_.size() != 2 && actuator_torque_.size() != 2 && actuator_force_.size() != 2 && | ||||||
actuator_current_.size() != 2 && actuator_absolute_position_.size() != 2) | ||||||
{ | ||||||
throw Exception( | ||||||
fmt::format( | ||||||
|
@@ -273,6 +285,8 @@ void DifferentialTransmission::configure( | |||||
joint_velocity_.size() != actuator_velocity_.size() && | ||||||
joint_effort_.size() != actuator_effort_.size() && | ||||||
joint_torque_.size() != actuator_torque_.size() && | ||||||
joint_force_.size() != actuator_force_.size() && | ||||||
joint_curret_.size() != actuator_current_.size() && | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
joint_absolute_position_.size() != actuator_absolute_position_.size()) | ||||||
{ | ||||||
throw Exception( | ||||||
|
@@ -335,6 +349,28 @@ inline void DifferentialTransmission::actuator_to_joint() | |||||
jr[1] * (act_tor[0].get_value() * ar[0] - act_tor[1].get_value() * ar[1])); | ||||||
} | ||||||
|
||||||
auto & act_for = actuator_force_; | ||||||
auto & joint_for = joint_force_; | ||||||
if (act_for.size() == num_actuators() && joint_for.size() == num_joints()) | ||||||
{ | ||||||
assert(act_for[0] && act_for[1] && joint_for[0] && joint_for[1]); | ||||||
|
||||||
joint_for[0].set_value( | ||||||
jr[0] * (act_for[0].get_value() * ar[0] + act_for[1].get_value() * ar[1])); | ||||||
joint_for[1].set_value( | ||||||
jr[1] * (act_for[0].get_value() * ar[0] - act_for[1].get_value() * ar[1])); | ||||||
} | ||||||
|
||||||
auto & act_cur = actuator_current_; | ||||||
auto & joint_cur = joint_curret_; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (act_cur.size() == num_actuators() && joint_cur.size() == num_joints()) | ||||||
{ | ||||||
assert(act_cur[0] && act_cur[1] && joint_cur[0] && joint_cur[1]); | ||||||
|
||||||
joint_cur[0].set_value(act_cur[0].get_value() + act_cur[1].get_value()); | ||||||
joint_cur[1].set_value(act_cur[0].get_value() - act_cur[1].get_value()); | ||||||
} | ||||||
|
||||||
auto & act_abs_pos = actuator_absolute_position_; | ||||||
auto & joint_abs_pos = joint_absolute_position_; | ||||||
if (act_abs_pos.size() == num_actuators() && joint_abs_pos.size() == num_joints()) | ||||||
|
@@ -404,6 +440,28 @@ inline void DifferentialTransmission::joint_to_actuator() | |||||
act_tor[1].set_value( | ||||||
(joint_tor[0].get_value() / jr[0] - joint_tor[1].get_value() / jr[1]) / (2.0 * ar[1])); | ||||||
} | ||||||
|
||||||
auto & act_for = actuator_force_; | ||||||
auto & joint_for = joint_force_; | ||||||
if (act_for.size() == num_actuators() && joint_for.size() == num_joints()) | ||||||
{ | ||||||
assert(act_for[0] && act_for[1] && joint_for[0] && joint_for[1]); | ||||||
|
||||||
act_for[0].set_value( | ||||||
(joint_for[0].get_value() / jr[0] + joint_for[1].get_value() / jr[1]) / (2.0 * ar[0])); | ||||||
act_for[1].set_value( | ||||||
(joint_for[0].get_value() / jr[0] - joint_for[1].get_value() / jr[1]) / (2.0 * ar[1])); | ||||||
} | ||||||
|
||||||
auto & act_cur = actuator_current_; | ||||||
auto & joint_cur = joint_curret_; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (act_cur.size() == num_actuators() && joint_cur.size() == num_joints()) | ||||||
{ | ||||||
assert(act_cur[0] && act_cur[1] && joint_cur[0] && joint_cur[1]); | ||||||
|
||||||
act_cur[0].set_value((joint_cur[0].get_value() + joint_cur[1].get_value()) / 2.0); | ||||||
act_cur[1].set_value((joint_cur[0].get_value() - joint_cur[1].get_value()) / 2.0); | ||||||
} | ||||||
} | ||||||
|
||||||
std::string DifferentialTransmission::get_handles_info() const | ||||||
|
@@ -415,11 +473,15 @@ std::string DifferentialTransmission::get_handles_info() const | |||||
"Joint velocity: {}, Actuator velocity: {}\n" | ||||||
"Joint effort: {}, Actuator effort: {}\n" | ||||||
"Joint torque: {}, Actuator torque: {}\n" | ||||||
"Joint force: {}, Actuator force: {}\n" | ||||||
"Joint current: {}, Actuator current: {}\n" | ||||||
"Joint absolute position: {}, Actuator absolute position: {}"), | ||||||
to_string(get_names(joint_position_)), to_string(get_names(actuator_position_)), | ||||||
to_string(get_names(joint_velocity_)), to_string(get_names(actuator_velocity_)), | ||||||
to_string(get_names(joint_effort_)), to_string(get_names(actuator_effort_)), | ||||||
to_string(get_names(joint_torque_)), to_string(get_names(actuator_torque_)), | ||||||
to_string(get_names(joint_force_)), to_string(get_names(actuator_force_)), | ||||||
to_string(get_names(joint_curret_)), to_string(get_names(actuator_current_)), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
to_string(get_names(joint_absolute_position_)), | ||||||
to_string(get_names(actuator_absolute_position_))); | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.