Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 179 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rust-version = "1.85"
optik = { path = "crates/optik" }

# Solver
clarabel = "0.11"
nalgebra = { git = "https://github.com/dimforge/nalgebra", branch = "main", features = [ "rand", "serde-serialize" ] }
nlopt = { git = "https://github.com/kylc/rust-nlopt.git", branch = "optik-patches" }
ordered-float = "4.2"
Expand Down
3 changes: 3 additions & 0 deletions crates/optik-cpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ rust-version.workspace = true
name = "optikcpp"
crate-type = ["staticlib"]

[lints]
workspace = true

[dependencies]
nalgebra.workspace = true
optik.workspace = true
Expand Down
9 changes: 9 additions & 0 deletions crates/optik-cpp/include/optik.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ class Robot final {
bool DoIk(const SolverConfig& config, const Eigen::Isometry3d& target,
const Eigen::VectorXd& x0, Eigen::VectorXd* q) const;

//! Attempts to solve for the velocity `v` which satisfies `v * J(q) = V_WE`.
//!
//! If `true` is returned, then out-parameter `v` will contain the solution
//! joint velocity. Otherwise, the solve has not converged and `v` will be
//! left untouched.
bool DoDiffIk(const Eigen::VectorXd& x0,
const Eigen::Matrix<double, 6, 1>& V_WE,
const Eigen::VectorXd& v_max, Eigen::VectorXd* v) const;

//! Returns the size of the generalized position vector of this robot.
unsigned int num_positions() const noexcept;

Expand Down
17 changes: 17 additions & 0 deletions crates/optik-cpp/src/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ extern double* optik_robot_fk(const optik::detail::robot* robot,
extern double* optik_robot_ik(const optik::detail::robot* robot,
const optik::SolverConfig* config,
const double* target, const double* x0);
extern double* optik_robot_diff_ik(const optik::detail::robot* robot,
const double* x0, const double* V_WE,
const double* v_max);
}

namespace optik {
Expand Down Expand Up @@ -116,6 +119,20 @@ bool Robot::DoIk(const SolverConfig& config, const Eigen::Isometry3d& target,
}
}

bool Robot::DoDiffIk(const Eigen::VectorXd& x0,
const Eigen::Matrix<double, 6, 1>& V_WE,
const Eigen::VectorXd& v_max, Eigen::VectorXd* v) const {
double* v_data =
optik_robot_diff_ik(inner_, x0.data(), V_WE.data(), v_max.data());
if (v_data != nullptr) {
*v = Eigen::Map<Eigen::VectorXd>(v_data, num_positions());
free(v_data);
return true;
} else {
return false;
}
}

unsigned int Robot::num_positions() const noexcept {
return optik_robot_num_positions(inner_);
}
Expand Down
Loading
Loading