-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
iiwa_common.cc
42 lines (35 loc) · 1.46 KB
/
iiwa_common.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "drake/examples/kuka_iiwa_arm/iiwa_common.h"
#include <cmath>
namespace drake {
namespace examples {
namespace kuka_iiwa_arm {
void SetPositionControlledIiwaGains(Eigen::VectorXd* Kp,
Eigen::VectorXd* Ki,
Eigen::VectorXd* Kd) {
// All the gains are for acceleration, not directly responsible for generating
// torques. These are set to high values to ensure good tracking. These gains
// are picked arbitrarily.
Kp->resize(7);
*Kp << 100, 100, 100, 100, 100, 100, 100;
Kd->resize(Kp->size());
for (int i = 0; i < Kp->size(); i++) {
// Critical damping gains.
(*Kd)[i] = 2 * std::sqrt((*Kp)[i]);
}
*Ki = Eigen::VectorXd::Zero(7);
}
void SetTorqueControlledIiwaGains(Eigen::VectorXd* stiffness,
Eigen::VectorXd* damping_ratio) {
// All the gains are for directly generating torques. These gains are set
// according to the values in the drake-iiwa-driver repository:
// https://github.com/RobotLocomotion/drake-iiwa-driver/blob/master/kuka-driver/sunrise_1.11/DrakeFRITorqueDriver.java NOLINT
// The spring stiffness in Nm/rad.
stiffness->resize(7);
*stiffness << 1000, 1000, 1000, 500, 500, 500, 500;
// A dimensionless damping ratio. See KukaTorqueController for details.
damping_ratio->resize(stiffness->size());
damping_ratio->setConstant(1.0);
}
} // namespace kuka_iiwa_arm
} // namespace examples
} // namespace drake