-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcom_tracking_data.cc
More file actions
48 lines (39 loc) · 1.76 KB
/
Copy pathcom_tracking_data.cc
File metadata and controls
48 lines (39 loc) · 1.76 KB
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
43
44
45
46
47
48
#include "com_tracking_data.h"
using Eigen::MatrixXd;
using Eigen::Vector3d;
using Eigen::VectorXd;
using std::string;
using std::vector;
using drake::multibody::JacobianWrtVariable;
using drake::multibody::MultibodyPlant;
using drake::systems::Context;
namespace dairlib::systems::controllers {
/**** ComTrackingData ****/
ComTrackingData::ComTrackingData(const string& name, const MatrixXd& K_p,
const MatrixXd& K_d, const MatrixXd& W,
const MultibodyPlant<double>& plant_w_spr,
const MultibodyPlant<double>& plant_wo_spr)
: OptionsTrackingData(name, kSpaceDim, kSpaceDim, K_p, K_d, W, plant_w_spr,
plant_wo_spr) {
}
void ComTrackingData::UpdateY(const VectorXd& x_w_spr,
const Context<double>& context_w_spr) {
y_ = plant_w_spr_.CalcCenterOfMassPositionInWorld(context_w_spr);
}
void ComTrackingData::UpdateYdot(const VectorXd& x_w_spr,
const Context<double>& context_w_spr) {
ydot_ = plant_w_spr_.CalcCenterOfMassTranslationalVelocityInWorld(
context_w_spr);
}
void ComTrackingData::UpdateJ(const VectorXd& x_wo_spr,
const Context<double>& context_wo_spr) {
J_ = MatrixXd::Zero(kSpaceDim, plant_wo_spr_.num_velocities());
plant_wo_spr_.CalcJacobianCenterOfMassTranslationalVelocity(
context_wo_spr, JacobianWrtVariable::kV, world_w_spr_, world_w_spr_, &J_);
}
void ComTrackingData::UpdateJdotV(const VectorXd& x_wo_spr,
const Context<double>& context_wo_spr) {
JdotV_ = plant_wo_spr_.CalcBiasCenterOfMassTranslationalAcceleration(
context_wo_spr, JacobianWrtVariable::kV, world_wo_spr_, world_wo_spr_);
}
}