Skip to content

Commit 48ef9f7

Browse files
committed
removed cbf experiments and cleaned up code
1 parent 4723a4a commit 48ef9f7

File tree

61 files changed

+68
-9208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+68
-9208
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ There is a base controller that communicate with the hardware interface of the r
88
For now only a cartesian impedance controller is implemented but also other type of controllers like for example an admittance controller can be easily added.
99

1010
Check out their use in the KUKA LBR example [here](https://github.com/idra-lab/kuka_impedance)!
11-
This repo also contains a CoppeliaSim hardware interface and scene to test our controllers with simulated Franka robots.
1211

1312
The structure of the code and some libraries have been taken from the repo [Cartesian Controllers](https://github.com/fzi-forschungszentrum-informatik/cartesian_controllers).

cartesian_impedance_controller/include/cartesian_impedance_controller/cartesian_impedance_controller.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
#include <controller_interface/controller_interface.hpp>
77

88
#include "controller_interface/controller_interface.hpp"
9+
#include "debug_msg/msg/debug.hpp"
910
#include "effort_controller_base/Utility.h"
1011
#include "geometry_msgs/msg/pose_stamped.hpp"
1112
#include "geometry_msgs/msg/wrench_stamped.hpp"
12-
#include "debug_msg/msg/debug.hpp"
13+
#define DEBUG 0
1314

1415
namespace cartesian_impedance_controller {
1516

@@ -38,7 +39,7 @@ namespace cartesian_impedance_controller {
3839
*/
3940
class CartesianImpedanceController
4041
: public virtual effort_controller_base::EffortControllerBase {
41-
public:
42+
public:
4243
CartesianImpedanceController();
4344

4445
virtual LifecycleNodeInterface::CallbackReturn on_init() override;
@@ -52,34 +53,33 @@ class CartesianImpedanceController
5253
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn
5354
on_deactivate(const rclcpp_lifecycle::State &previous_state) override;
5455

55-
controller_interface::return_type
56-
update(const rclcpp::Time &time, const rclcpp::Duration &period) override;
56+
controller_interface::return_type update(
57+
const rclcpp::Time &time, const rclcpp::Duration &period) override;
5758

5859
ctrl::VectorND computeTorque();
5960

6061
using Base = effort_controller_base::EffortControllerBase;
6162

6263
ctrl::Matrix6D m_cartesian_stiffness;
63-
// ctrl::Matrix6D m_cartesian_damping;
64+
// ctrl::Matrix6D m_cartesian_damping;
6465
double m_null_space_stiffness;
6566
double m_null_space_damping;
6667
ctrl::Vector6D m_target_wrench;
6768

68-
private:
69+
private:
6970
ctrl::Vector6D compensateGravity();
7071

7172
void targetWrenchCallback(
7273
const geometry_msgs::msg::WrenchStamped::SharedPtr wrench);
73-
void
74-
targetFrameCallback(const geometry_msgs::msg::PoseStamped::SharedPtr target);
74+
void targetFrameCallback(
75+
const geometry_msgs::msg::PoseStamped::SharedPtr target);
7576
ctrl::Vector6D computeMotionError();
7677

7778
rclcpp::Subscription<geometry_msgs::msg::WrenchStamped>::SharedPtr
7879
m_target_wrench_subscriber;
7980
rclcpp::Subscription<geometry_msgs::msg::PoseStamped>::SharedPtr
8081
m_target_frame_subscriber;
81-
rclcpp::Publisher<debug_msg::msg::Debug>::SharedPtr
82-
m_data_publisher;
82+
rclcpp::Publisher<debug_msg::msg::Debug>::SharedPtr m_data_publisher;
8383
KDL::Frame m_target_frame;
8484
ctrl::Vector6D m_ft_sensor_wrench;
8585
std::string m_ft_sensor_ref_link;
@@ -103,6 +103,6 @@ class CartesianImpedanceController
103103
bool m_hand_frame_control;
104104
};
105105

106-
} // namespace cartesian_impedance_controller
106+
} // namespace cartesian_impedance_controller
107107

108108
#endif

cartesian_impedance_controller/package.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66
<description>The cartesian_impedance_controller package</description>
77
<maintainer email="luca.beber@unitn.it">Luca Beber</maintainer>
88
<license>BSD</license>
9-
<url type="repository">https://github.com/lucabeber/effort_controllers</url>
10-
<author email="luca.beber@unitn.it">Luca Beber</author>
9+
<url type="repository">https://github.com/lucabeber/effort_controllers</url>
10+
<author email="luca.beber@unitn.it">Luca Beber</author>
1111

1212
<buildtool_depend>ament_cmake</buildtool_depend>
1313

1414
<depend>rclcpp</depend>
1515
<depend>effort_controller_base</depend>
1616
<depend>controller_interface</depend>
17+
<depend>debug_msg</depend>
1718

1819
<export>
1920
<build_type>ament_cmake</build_type>
20-
<controller_interface plugin="${prefix}/cartesian_impedance_controller_plugin.xml"/>
21+
<controller_interface plugin="${prefix}/cartesian_impedance_controller_plugin.xml" />
2122
</export>
22-
</package>
23+
</package>

cartesian_impedance_controller/src/cartesian_impedance_controller.cpp

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,8 @@ CartesianImpedanceController::on_deactivate(
154154
CallbackReturn::SUCCESS;
155155
}
156156

157-
controller_interface::return_type
158-
CartesianImpedanceController::update(const rclcpp::Time &time,
159-
const rclcpp::Duration &period) {
157+
controller_interface::return_type CartesianImpedanceController::update(
158+
const rclcpp::Time &time, const rclcpp::Duration &period) {
160159
// Update joint states
161160
Base::updateJointStates();
162161

@@ -184,7 +183,7 @@ ctrl::Vector6D CartesianImpedanceController::computeMotionError() {
184183
// Use Rodrigues Vector for a compact representation of orientation errors
185184
// Only for angles within [0,Pi)
186185
KDL::Vector rot_axis = KDL::Vector::Zero();
187-
double angle = error_kdl.M.GetRotAngle(rot_axis); // rot_axis is normalized
186+
double angle = error_kdl.M.GetRotAngle(rot_axis); // rot_axis is normalized
188187
double distance = error_kdl.p.Normalize();
189188

190189
// Clamp maximal tolerated error.
@@ -263,18 +262,11 @@ ctrl::VectorND CartesianImpedanceController::computeTorque() {
263262
for (int i = 5; i < 6; i++) {
264263
D_d(i, i) = D_d(i, i) + damping_correction(3);
265264
}
266-
267-
// Compute the task torque
268-
Eigen::VectorXd Force = (K_d * motion_error - (D_d * (jac * q_dot)));
269-
tau_task = jac.transpose() * Force;
270-
271265
Eigen::VectorXd stiffness_torque = jac.transpose() * (K_d * motion_error);
272266
Eigen::VectorXd damping_torque = jac.transpose() * -(D_d * (jac * q_dot));
273267

274-
// // add damping force for orientation
275-
// Eigen::VectorXd damping_force = (4 * K_d.cwiseSqrt() * (jac * q_dot));
276-
// damping_force.head(3) << 0, 0, 0;
277-
// Force = Force - damping_force;
268+
// Compute the task torque
269+
tau_task = stiffness_torque + damping_torque;
278270

279271
KDL::JntArray tau_coriolis(Base::m_joint_number),
280272
tau_gravity(Base::m_joint_number);
@@ -303,16 +295,10 @@ ctrl::VectorND CartesianImpedanceController::computeTorque() {
303295
jac.transpose() * Lambda * jac_dot_q_dot_eigen;
304296
tau = tau + j_tran_lambda_jdot_qdot;
305297
}
306-
// datas.data.push_back(tau(0) + j_tran_lambda_jdot_qdot(0));
307-
// datas.data.push_back(tau(0));
308-
309-
// add norm of j_tran_lambda_jdot_qdot
310-
// datas.data.push_back(j_tran_lambda_jdot_qdot.norm());
311298

312299
// Compute the null space torque
313300
q_null_space = m_q_starting_pose;
314301
if (m_null_space_stiffness > 1e-6) {
315-
316302
// Compute dynamically consistent null space projector
317303
tau_null =
318304
(m_identity - jac.transpose() * Lambda * jac * M.data.inverse()) *
@@ -322,6 +308,8 @@ ctrl::VectorND CartesianImpedanceController::computeTorque() {
322308
tau_null = ctrl::VectorND::Zero(Base::m_joint_number);
323309
}
324310

311+
#if DEBUG
312+
Eigen::VectorXd Force = K_d * motion_error - D_d * (jac * q_dot);
325313
for (int i = 0; i < 7; i++) {
326314
debug_msg.stiffness_torque[i] = stiffness_torque(i);
327315
debug_msg.damping_torque[i] = damping_torque(i);
@@ -331,12 +319,12 @@ ctrl::VectorND CartesianImpedanceController::computeTorque() {
331319
debug_msg.impedance_force[i] = Force(i);
332320
}
333321
}
334-
322+
m_data_publisher->publish(debug_msg);
323+
#endif
335324
// Compute the torque to achieve the desired force
336325
tau_ext = jac.transpose() * m_target_wrench;
337326

338327
tau += tau_task + tau_null + tau_ext;
339-
m_data_publisher->publish(debug_msg);
340328

341329
return tau;
342330
}
@@ -377,7 +365,7 @@ void CartesianImpedanceController::targetFrameCallback(
377365
KDL::Vector(target->pose.position.x, target->pose.position.y,
378366
target->pose.position.z));
379367
}
380-
} // namespace cartesian_impedance_controller
368+
} // namespace cartesian_impedance_controller
381369

382370
// Pluginlib
383371
#include <pluginlib/class_list_macros.hpp>

cbf_cartesian_impedance_controller/CMakeLists.txt

Lines changed: 0 additions & 102 deletions
This file was deleted.

cbf_cartesian_impedance_controller/README.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

cbf_cartesian_impedance_controller/cbf_cartesian_impedance_controller_plugin.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)