Skip to content

Commit

Permalink
Implemented Robot.currentJointState and Robot.currentJointVelocities
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSchneider42 committed May 28, 2024
1 parent 21616cc commit 6ba96d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion include/franky/robot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#include "franky/scope_guard.hpp"
#include "franky/control_signal_type.hpp"
#include "franky/util.hpp"
#include "relative_dynamics_factor.hpp"
#include "franky/relative_dynamics_factor.hpp"
#include "franky/joint_state.hpp"

namespace franky {

Expand Down Expand Up @@ -136,8 +137,12 @@ class Robot : public franka::Robot {
RobotVelocity(franka::CartesianVelocities(s.O_dP_EE_c, s.delbow_c))};
}

[[nodiscard]] JointState currentJointState();

[[nodiscard]] Vector7d currentJointPositions();

[[nodiscard]] Vector7d currentJointVelocities();

[[nodiscard]] franka::RobotState state();

[[nodiscard]] RelativeDynamicsFactor relative_dynamics_factor();
Expand Down
2 changes: 2 additions & 0 deletions python/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ PYBIND11_MODULE(_franky, m) {
.def_property_readonly("current_pose", &Robot::currentPose)
.def_property_readonly("current_cartesian_velocity", &Robot::currentCartesianVelocity)
.def_property_readonly("current_cartesian_state", &Robot::currentCartesianState)
.def_property_readonly("current_joint_state", &Robot::currentJointState)
.def_property_readonly("current_joint_velocities", &Robot::currentJointVelocities)
.def_property_readonly("current_joint_positions", &Robot::currentJointPositions)
.def_property_readonly("state", &Robot::state)
.def_property_readonly("is_in_control", &Robot::is_in_control)
Expand Down
11 changes: 10 additions & 1 deletion src/robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,17 @@ bool Robot::recoverFromErrors() {
return !hasErrors();
}

JointState Robot::currentJointState() {
auto s = state();
return {Eigen::Map<const Vector7d>(state().q.data()), Eigen::Map<const Vector7d>(state().dq.data())};
}

Vector7d Robot::currentJointPositions() {
return Eigen::Map<const Vector7d>(state().q.data());
return currentJointState().position();
}

Vector7d Robot::currentJointVelocities() {
return currentJointState().velocity();
}

Affine Robot::forwardKinematics(const Vector7d &q) {
Expand Down

0 comments on commit 6ba96d3

Please sign in to comment.