Skip to content

Commit 402b645

Browse files
pac48adlarkin
andauthored
Add force and velocity hardware interfaces (Kinovarobotics#204)
Signed-off-by: Paul Gesel <[email protected]> Co-authored-by: Ashton Larkin <[email protected]>
1 parent cbfb28e commit 402b645

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

kortex_driver/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# ROS 2 Kortex Driver
2+
The ROS 2 Kortex driver implements the `ros2_control` hardware interface for a `SystemInterface`.
3+
4+
### Command interfaces
5+
This driver exports commands interfaces for position, velocity, and effort interfaces for each joint defined in the URDF.
6+
Additionally, twist interfaces are exported for the end effector for operational space control.
7+
Several additional interfaces are exported, including `set_gripper_max_velocity`, `set_gripper_max_effort` for the gripper joint,
8+
`reset_fault/command`, and `reset_fault/async_success` for fault management.
9+
10+
### State interfaces
11+
This driver exports position and velocity state interfaces for joint defined in the URDF.
12+
13+
Additionally, one state interface `reset_fault/internal_fault` is used for determining the robot's fault state.

kortex_driver/include/kortex_driver/hardware_interface.hpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ class KortexMultiInterfaceHardware : public hardware_interface::SystemInterface
144144

145145
// Gripper
146146
k_api::GripperCyclic::MotorCommand * gripper_motor_command_;
147-
double gripper_command_position_;
148-
double gripper_command_max_velocity_;
149-
double gripper_command_max_force_;
150-
double gripper_position_;
151-
double gripper_velocity_;
147+
double gripper_command_position_ = 0.0;
148+
double gripper_command_max_velocity_ = 0.0;
149+
double gripper_command_max_force_ = 0.0;
150+
double gripper_position_ = 0.0;
151+
double gripper_velocity_ = 0.0;
152+
double gripper_force_command_ = 0.0;
153+
double gripper_speed_command_ = 0.0;
152154

153155
rclcpp::Time controller_switch_time_;
154156
std::atomic<bool> block_write = false;

kortex_driver/src/hardware_interface.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,13 @@ KortexMultiInterfaceHardware::export_command_interfaces()
341341
{
342342
command_interfaces.emplace_back(hardware_interface::CommandInterface(
343343
info_.joints[i].name, hardware_interface::HW_IF_POSITION, &gripper_command_position_));
344+
345+
command_interfaces.emplace_back(hardware_interface::CommandInterface(
346+
info_.joints[i].name, "set_gripper_max_velocity", &gripper_speed_command_));
347+
gripper_speed_command_ = gripper_command_max_velocity_;
348+
command_interfaces.emplace_back(hardware_interface::CommandInterface(
349+
info_.joints[i].name, "set_gripper_max_effort", &gripper_force_command_));
350+
gripper_force_command_ = gripper_command_max_force_;
344351
}
345352
else
346353
{
@@ -671,9 +678,9 @@ CallbackReturn KortexMultiInterfaceHardware::on_activate(
671678
base_command_.mutable_interconnect()->mutable_command_id()->set_identifier(0);
672679
gripper_motor_command_ =
673680
base_command_.mutable_interconnect()->mutable_gripper_command()->add_motor_cmd();
674-
gripper_motor_command_->set_position(gripper_initial_position); // % position
675-
gripper_motor_command_->set_velocity(gripper_command_max_velocity_); // % speed
676-
gripper_motor_command_->set_force(gripper_command_max_force_); // % torque
681+
gripper_motor_command_->set_position(gripper_initial_position); // % position
682+
gripper_motor_command_->set_velocity(gripper_speed_command_); // % speed
683+
gripper_motor_command_->set_force(gripper_force_command_); // % force
677684

678685
// Send a first frame
679686
base_feedback = base_cyclic_.Refresh(base_command_);
@@ -864,8 +871,7 @@ return_type KortexMultiInterfaceHardware::write(
864871

865872
// gripper control
866873
sendGripperCommand(
867-
arm_mode_, gripper_command_position_, gripper_command_max_velocity_,
868-
gripper_command_max_force_);
874+
arm_mode_, gripper_command_position_, gripper_speed_command_, gripper_force_command_);
869875
// read after write in twist mode
870876
feedback_ = base_cyclic_.RefreshFeedback();
871877
}
@@ -877,8 +883,7 @@ return_type KortexMultiInterfaceHardware::write(
877883

878884
// gripper control
879885
sendGripperCommand(
880-
arm_mode_, gripper_command_position_, gripper_command_max_velocity_,
881-
gripper_command_max_force_);
886+
arm_mode_, gripper_command_position_, gripper_speed_command_, gripper_force_command_);
882887

883888
if (joint_based_controller_running_)
884889
{

0 commit comments

Comments
 (0)