3#include <VirtualRobot/RobotNodeSet.h>
16 for (
const auto& pair : cfg)
18 auto handNodeSet = rtRobot->getRobotNodeSet(pair.first);
19 hands.emplace(pair.first,
20 std::make_unique<HandData>(robotUnit, handNodeSet, pair.second));
27 for (
auto& pair :
hands)
29 pair.second->setTarget();
36 for (
auto& [name, hand] :
hands)
38 hand->targetNonRT = hand->bufferUserToNonRT.getUpToDateReadBuffer();
39 hand->rtsInNonRT = hand->bufferRTToNonRT.getUpToDateReadBuffer();
46 for (
auto& [_, hand] :
hands)
48 hand->rts.deltaT = deltaT;
49 hand->rts.accumulateTime += deltaT;
50 hand->bufferRTToNonRT.getWriteBuffer() = hand->rts;
51 hand->bufferRTToNonRT.commitWrite();
58 for (
const auto& [name, hand_cfg] : cfg)
60 if (hand_cfg.jointPosition.has_value())
62 auto& target =
hands.at(name)->bufferUserToNonRT.getWriteBuffer();
63 target.jointPosition = hand_cfg.jointPosition;
64 hands.at(name)->bufferUserToNonRT.commitWrite();
72 for (
auto& [name, hand] :
hands)
74 cfgToUpdate.at(name) = hand->bufferConfigNonRTToUser.getUpToDateReadBuffer();
81 for (
auto& [name, hand] :
hands)
83 cfgToUpdate.at(name) = hand->targetNonRT;
84 hand->bufferUserToNonRT.reinitAllBuffers(hand->targetNonRT);
85 hand->bufferConfigNonRTToOnPublish.reinitAllBuffers(hand->targetNonRT);
93 auto rtData = hand->bufferConfigNonRTToOnPublish.getUpToDateReadBuffer();
95 if (rtData.jointPosition.has_value())
98 debugObs->setDebugChannel(
"hand_" + hand->kinematicChainName, datafields);
105 for (
auto& pair :
hands)
114 for (
auto& pair :
hands)
116 pair.second->ctrl->activateController();
123 for (
auto& pair :
hands)
125 pair.second->rtPreActivate();
158 for (
unsigned int i = 0; i <
jointNames.size(); i++)
186 const VirtualRobot::RobotNodeSetPtr& robotNodeSet,
190 nJoints(robotNodeSet->getSize())
192 auto controller = robotUnit->getNJointController(cfg.njointControllerName);
194 <<
" is not available in "
196 ctrl = Ice::checkedCast<hand::HandShapeControllerInterfacePrx>(
controller);
201 rts.accumulateTime = 0.0;
203 jointLimMin = Eigen::Map<Eigen::VectorXf>(robotNodeSet->getNodeLimitsLo().data(),
nJoints);
204 jointLimMax = Eigen::Map<Eigen::VectorXf>(robotNodeSet->getNodeLimitsHi().data(),
nJoints);
231 for (
auto i = 0; i <
targetNonRT.jointPosition.value().size(); ++i)
240 <<
" does not exist in hand shape controller";
#define ARMARX_RT_LOGF_INFO(...)
void rtPostDeactivate(HandConfigDict &cfgToUpdate)
void onPublish(const DebugObserverInterfacePrx &debugObs)
std::unique_ptr< HandData > HandPtr
void getConfig(HandConfigDict &cfgToUpdate)
law::arondto::HandStatus HandConfig
void nonRtActivateController()
std::map< std::string, HandPtr > hands
void updateRTStatus(double deltaT)
void limbPublish(HandPtr &hand, const DebugObserverInterfacePrx &debugObs)
HandControlBase(const RobotUnitPtr &robotUnit, const VirtualRobot::RobotPtr &rtRobot, const HandConfigDict &cfg)
std::map< std::string, HandConfig > HandConfigDict
void reinitBuffer(HandConfigDict &cfgToUpdate)
void updateConfig(const HandConfigDict &cfg)
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
std::shared_ptr< class Robot > RobotPtr
void debugEigenVec(StringVariantBaseMap &datafields, const std::string &name, Eigen::VectorXf vec)
This file is part of ArmarX.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::map< std::string, VariantBasePtr > StringVariantBaseMap
IceUtil::Handle< class RobotUnit > RobotUnitPtr
TripleBuffer< HandConfig > bufferUserToNonRT
float deltaJointValueThreshold
hand::HandShapeControllerInterfacePrx ctrl
std::string kinematicChainName
names
std::vector< std::string > jointNames
void validate()
----------------------------------— HandData ------------------------------------------—
TripleBuffer< HandConfig > bufferConfigNonRTToUser
HandConfig prevTargetNonRT
TripleBuffer< HandConfig > bufferConfigNonRTToOnPublish
Eigen::VectorXf jointLimMax
std::map< std::string, float > desiredJointPositionMap
Eigen::VectorXf jointLimMin
double nonRTAccumulateTime
TripleBuffer< RTStatus > bufferRTToNonRT
HandData(const RobotUnitPtr &robotUnit, const VirtualRobot::RobotNodeSetPtr &robotNodeSet, const HandConfig &cfg)