-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pass through joint torque feedback controller.
Showing
7 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...lude/franka-interface/feedback_controller/pass_through_joint_torque_feedback_controller.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef FRANKA_INTERFACE_FEEDBACK_CONTROLLER_PASSTHROUGH_JOINT_TORQUE_FEEDBACK_CONTROLLER_H_ | ||
#define FRANKA_INTERFACE_FEEDBACK_CONTROLLER_PASSTHROUGH_JOINT_TORQUE_FEEDBACK_CONTROLLER_H_ | ||
|
||
#include "franka-interface/feedback_controller/feedback_controller.h" | ||
|
||
// A passthrough feedback controller that just uses the desired joint | ||
// torques from the sensor subscriber and passes it to the robot | ||
class PassThroughJointTorqueFeedbackController : public FeedbackController { | ||
public: | ||
using FeedbackController::FeedbackController; | ||
|
||
void parse_parameters() override; | ||
|
||
void initialize_controller(FrankaRobot *robot) override; | ||
|
||
void get_next_step(const franka::RobotState &robot_state, | ||
TrajectoryGenerator *traj_generator) override; | ||
|
||
void parse_sensor_data(const franka::RobotState &robot_state) override; | ||
|
||
private: | ||
JointTorqueFeedbackControllerMessage joint_torque_feedback_params_; | ||
JointTorqueControllerSensorMessage joint_torque_sensor_msg_; | ||
const franka::Model *model_; | ||
|
||
std::array<double, 7> S_= {}; | ||
std::array<double, 7> desired_joint_torques_= {}; | ||
|
||
}; | ||
|
||
#endif // FRANKA_INTERFACE_FEEDBACK_CONTROLLER_PASSTHROUGH_JOINT_TORQUE_FEEDBACK_CONTROLLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
franka-interface/src/feedback_controller/pass_through_joint_torque_feedback_controller.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Created by Kevin on 9/13/24. | ||
// | ||
|
||
#include "franka-interface/feedback_controller/pass_through_joint_torque_feedback_controller.h" | ||
|
||
#include "franka-interface/trajectory_generator/impulse_trajectory_generator.h" | ||
|
||
void PassThroughJointTorqueFeedbackController::parse_parameters() { | ||
// pass | ||
} | ||
|
||
void PassThroughJointTorqueFeedbackController::initialize_controller(FrankaRobot *robot) { | ||
model_ = robot->getModel(); | ||
} | ||
|
||
void PassThroughJointTorqueFeedbackController::parse_sensor_data(const franka::RobotState &robot_state) { | ||
SensorDataManagerReadStatus sensor_msg_status = sensor_data_manager_->readFeedbackControllerSensorMessage(joint_torque_sensor_msg_); | ||
if (sensor_msg_status == SensorDataManagerReadStatus::SUCCESS) { | ||
for (int i = 0; i < 7; i++) { | ||
S_[i] = std::min(std::max(joint_torque_sensor_msg_.selection(i), 0.), 1.); | ||
desired_joint_torques_[i] = joint_torque_sensor_msg_.joint_torques(i); | ||
} | ||
} | ||
} | ||
|
||
void PassThroughJointTorqueFeedbackController::get_next_step(const franka::RobotState &robot_state, | ||
TrajectoryGenerator *traj_generator) { | ||
|
||
std::array<double, 7> gravity = model_->gravity(robot_state); | ||
|
||
for (int i = 0; i < 7; i++) { | ||
if (S_[i] == 1){ | ||
tau_d_array_[i] = desired_joint_torques_[i] - gravity[i]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters