46 if (
scene_->get_num_velocities() > 0)
49 N =
scene_->get_num_state_derivative();
54 N =
scene_->GetKinematicTree().GetNumControlledJoints();
65 if (phi.rows() !=
N)
ThrowNamed(
"Wrong size of phi!");
67 const Eigen::MatrixXd& limits =
scene_->GetKinematicTree().GetJointLimits();
68 const Eigen::VectorXd& low_limits = limits.col(0);
69 const Eigen::VectorXd& high_limits = limits.col(1);
70 const Eigen::VectorXd tau = 0.5 *
safe_percentage_ * (high_limits - low_limits);
73 phi = (q.array() < (low_limits + tau).array()).
select(q - low_limits - tau, phi);
75 phi = (q.array() > (high_limits - tau).array()).
select(q - high_limits + tau, phi);
80 if (jacobian.rows() !=
N || jacobian.cols() !=
N)
ThrowNamed(
"Wrong size of jacobian! " <<
N);
84 const Eigen::MatrixXd& limits =
scene_->GetKinematicTree().GetJointLimits();
85 const Eigen::VectorXd& low_limits = limits.col(0);
86 const Eigen::VectorXd& high_limits = limits.col(1);
87 const Eigen::VectorXd tau = 0.5 *
safe_percentage_ * (high_limits - low_limits);
88 for (
int i = 0; i <
N; i++)
90 if (q(i) >= low_limits(i) + tau(i) && q(i) <= high_limits(i) - tau(i))
103 if (hessian.size() !=
N)
ThrowNamed(
"Wrong size of hessian! " <<
N);
110 if (phi.rows() !=
N)
ThrowNamed(
"Wrong size of phi!");
113 Eigen::VectorXd low_limits(
N), high_limits(
N);
115 const Eigen::MatrixXd& limits =
scene_->GetKinematicTree().GetJointLimits();
116 low_limits.head(
scene_->get_num_positions()) = limits.col(0);
117 high_limits.head(
scene_->get_num_positions()) = limits.col(1);
119 low_limits.tail(
scene_->get_num_velocities()) = -
scene_->GetKinematicTree().GetVelocityLimits();
120 high_limits.tail(
scene_->get_num_velocities()) =
scene_->GetKinematicTree().GetVelocityLimits();
122 const Eigen::VectorXd tau = 0.5 *
safe_percentage_ * (high_limits - low_limits);
125 phi = (
x.array() < (low_limits + tau).array()).
select(
x - low_limits - tau, phi);
127 phi = (
x.array() > (high_limits - tau).array()).
select(
x - high_limits + tau, phi);
132 if (dphi_dx.rows() !=
N || dphi_dx.cols() !=
N)
ThrowNamed(
"Wrong size of dphi_dx! " <<
N);
133 if (phi.rows() !=
N)
ThrowNamed(
"Wrong size of phi!");
136 Eigen::VectorXd low_limits(
N), high_limits(
N);
138 const Eigen::MatrixXd& limits =
scene_->GetKinematicTree().GetJointLimits();
139 low_limits.head(
scene_->get_num_positions()) = limits.col(0);
140 high_limits.head(
scene_->get_num_positions()) = limits.col(1);
142 low_limits.tail(
scene_->get_num_velocities()) = -
scene_->GetKinematicTree().GetVelocityLimits();
143 high_limits.tail(
scene_->get_num_velocities()) =
scene_->GetKinematicTree().GetVelocityLimits();
145 const Eigen::VectorXd tau = 0.5 *
safe_percentage_ * (high_limits - low_limits);
148 phi = (
x.array() < (low_limits + tau).array()).
select(
x - low_limits - tau, phi);
150 phi = (
x.array() > (high_limits - tau).array()).
select(
x - high_limits + tau, phi);
152 for (
int i = 0; i <
N; i++)
154 if (
x(i) >= low_limits(i) + tau(i) &&
x(i) <= high_limits(i) - tau(i))
168 Update(
x, u, phi, dphi_dx, dphi_du);