Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBowman committed Nov 16, 2024
1 parent 1ac12a9 commit 6375b4a
Show file tree
Hide file tree
Showing 6 changed files with 490 additions and 20 deletions.
10 changes: 8 additions & 2 deletions libraries/YarpPlugins/KdlSolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ endif()

yarp_prepare_plugin(KdlSolver
CATEGORY device
TYPE roboticslab::KdlSolver
TYPE KdlSolver
INCLUDE KdlSolver.hpp
DEFAULT ON
DEPENDS "ENABLE_ScrewTheoryLib;ENABLE_KdlVectorConverterLib;orocos_kdl_FOUND")
DEPENDS "ENABLE_ScrewTheoryLib;ENABLE_KdlVectorConverterLib;orocos_kdl_FOUND"
GENERATE_PARSER)

if(NOT SKIP_KdlSolver)

Expand All @@ -23,6 +24,11 @@ if(NOT SKIP_KdlSolver)
LogComponent.hpp
LogComponent.cpp)

if(YARP_VERSION VERSION_GREATER_EQUAL 3.10)
target_sources(KdlSolver PRIVATE KdlSolver_ParamsParser.h
KdlSolver_ParamsParser.cpp)
endif()

target_link_libraries(KdlSolver YARP::YARP_os
YARP::YARP_dev
${orocos_kdl_LIBRARIES}
Expand Down
6 changes: 6 additions & 0 deletions libraries/YarpPlugins/KdlSolver/DeviceDriverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ namespace

bool KdlSolver::open(yarp::os::Searchable & config)
{
if (!parseParams(config))
{
yCError(KDLS) << "Failed to parse parameters";
return false;
}

isQuiet = config.check("quiet", "disable logging");

//-- kinematics
Expand Down
31 changes: 13 additions & 18 deletions libraries/YarpPlugins/KdlSolver/KdlSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <mutex>

#include <yarp/conf/version.h>
#include <yarp/dev/DeviceDriver.h>

#include <kdl/chain.hpp>
Expand All @@ -14,26 +15,29 @@

#include "ICartesianSolver.h"
#include "LogComponent.hpp"

namespace roboticslab
{
#if YARP_VERSION_COMPARE(>=, 3, 10, 0)
#include "KdlSolver_ParamsParser.h"
#endif

/**
* @ingroup YarpPlugins
* @defgroup KdlSolver
*
* @brief Contains roboticslab::KdlSolver.
* @brief Contains KdlSolver.
*/

/**
* @ingroup KdlSolver
* @brief The KdlSolver class implements ICartesianSolver.
*/
class KdlSolver : public yarp::dev::DeviceDriver,
public ICartesianSolver
#if YARP_VERSION_COMPARE(>=, 3, 10, 0)
public KdlSolver_ParamsParser,
#endif
public roboticslab::ICartesianSolver
{
public:
// -- ICartesianSolver declarations. Implementation in ICartesianSolverImpl.cpp--
// -- ICartesianSolver declarations. Implementation in ICartesianSolverImpl.cpp --

// Get number of joints for which the solver has been configured.
int getNumJoints() override;
Expand All @@ -48,9 +52,7 @@ class KdlSolver : public yarp::dev::DeviceDriver,
bool restoreOriginalChain() override;

// Change reference frame.
bool changeOrigin(const std::vector<double> &x_old_obj,
const std::vector<double> &x_new_old,
std::vector<double> &x_new_obj) override;
bool changeOrigin(const std::vector<double> &x_old_obj, const std::vector<double> &x_new_old, std::vector<double> &x_new_obj) override;

// Perform forward kinematics.
bool fwdKin(const std::vector<double> &q, std::vector<double> &x) override;
Expand All @@ -59,12 +61,10 @@ class KdlSolver : public yarp::dev::DeviceDriver,
bool poseDiff(const std::vector<double> &xLhs, const std::vector<double> &xRhs, std::vector<double> &xOut) override;

// Perform inverse kinematics.
bool invKin(const std::vector<double> &xd, const std::vector<double> &qGuess, std::vector<double> &q,
reference_frame frame) override;
bool invKin(const std::vector<double> &xd, const std::vector<double> &qGuess, std::vector<double> &q, reference_frame frame) override;

// Perform differential inverse kinematics.
bool diffInvKin(const std::vector<double> &q, const std::vector<double> &xdot, std::vector<double> &qdot,
reference_frame frame) override;
bool diffInvKin(const std::vector<double> &q, const std::vector<double> &xdot, std::vector<double> &qdot, reference_frame frame) override;

// Perform inverse dynamics.
bool invDyn(const std::vector<double> &q, std::vector<double> &t) override;
Expand All @@ -84,10 +84,7 @@ class KdlSolver : public yarp::dev::DeviceDriver,

mutable std::mutex mtx;

/** The chain. **/
KDL::Chain chain;

/** To store a copy of the original chain. **/
KDL::Chain originalChain;

KDL::ChainFkSolverPos * fkSolverPos {nullptr};
Expand All @@ -98,6 +95,4 @@ class KdlSolver : public yarp::dev::DeviceDriver,
bool isQuiet;
};

} // namespace roboticslab

#endif // __KDL_SOLVER_HPP__
Loading

0 comments on commit 6375b4a

Please sign in to comment.