3#include <VirtualRobot/Robot.h>
4#include <VirtualRobot/RobotNodeSet.h>
17 NJointControllerRegistration<NJointZeroTorqueOrVelocityWithFTController>
19 "NJointZeroTorqueOrVelocityWithFTController");
24 return "NJointZeroTorqueOrVelocityWithFTController";
29 const NJointZeroTorqueOrVelocityWithFTControllerConfigPtr& config,
33 RobotUnitPtr robotUnit = RobotUnitPtr::dynamicCast(prov);
39 for (
auto& robotNodeSetName : config->robotNodeSetList)
41 VirtualRobot::RobotNodeSetPtr rtRns =
rtGetRobot()->getRobotNodeSet(robotNodeSetName);
44 for (
size_t i = 0; i < rtRns->getSize(); i++)
46 std::string jointName = rtRns->getNode(i)->getName();
47 if (jointName.find(
"wri") != std::string::npos and
48 config->useZeroVelocityModeForWrist)
53 targetsVel.push_back(ct->
asA<ControlTarget1DoFActuatorZeroVelocity>());
73 target.targetTorqueOrVelocity = Ice::FloatSeq(numJoints, 0.0f);
76 ik.reset(
new VirtualRobot::DifferentialIK(
77 rtRns, rtRns->getRobot()->getRootNode(), VirtualRobot::JacobiProvider::eSVDDamped));
80 I = Eigen::MatrixXf::Identity(numOfJoints, numOfJoints);
88 target.targetTorqueOrVelocity = Ice::FloatSeq(numJoints, 0.0f);
94 const IceUtil::Time& timeSinceLastIteration)
98 ik->getJacobianMatrix(rtTCP, VirtualRobot::IKSolver::CartesianSelection::All);
99 rtStatus.jacobi.block(0, 0, 3, rtStatus.numJoints) =
100 0.001 * rtStatus.jacobi.block(0, 0, 3, rtStatus.numJoints);
105 ik->computePseudoInverseJacobianMatrix(rtStatus.jacobi.transpose(), lambda);
106 rtStatus.jpinv = ik->computePseudoInverseJacobianMatrix(rtStatus.jacobi, lambda);
111 size_t torqueIndex = 0;
140 const std::map<std::string, ConstControlDevicePtr>& controlDevices,
141 const std::map<std::string, ConstSensorDevicePtr>&)
147 ::armarx::WidgetDescription::WidgetSeq widgets;
148 auto addSlider = [&](
const std::string& label,
float min,
float max,
float defaultValue)
150 widgets.emplace_back(
new Label(
false, label));
155 c_x->defaultValue = defaultValue;
157 widgets.emplace_back(c_x);
162 LabelPtr label =
new Label;
163 label->text =
"Robot Node Sets";
164 layout->children.emplace_back(label);
166 StringComboBoxPtr box =
new StringComboBox;
167 box->name =
"robotNodeSetSelector";
168 box->defaultIndex = 0;
169 box->multiSelect =
true;
170 box->options.push_back(
"LeftArm");
171 box->options.push_back(
"RightArm");
172 layout->children.emplace_back(box);
178 CheckBoxPtr checkBox =
new CheckBox;
179 checkBox->name =
"useZeroVelocityModeForWrist";
180 checkBox->label =
"Wrist ZeroVelocity";
181 checkBox->defaultValue =
true;
183 addSlider(
"maxTorque", 0, 100, 10);
184 addSlider(
"maxVeloicty", 0, 3.14, 2.0);
186 layout->children.insert(layout->children.end(), widgets.begin(), widgets.end());
190 NJointZeroTorqueOrVelocityWithFTControllerConfigPtr
194 auto varNodeSets = VariantPtr::dynamicCast(values.at(
"robotNodeSetSelector"));
200 values.at(
"useZeroVelocityModeForWrist")->getBool(),
201 values.at(
"maxTorque")->getFloat(),
202 values.at(
"maxVeloicty")->getFloat()};
int Label(int n[], int size, int *curLabel, MiscLib::Vector< std::pair< int, size_t > > *labels)
Brief description of class JointControlTargetBase.
const VirtualRobot::RobotPtr & useSynchronizedRtRobot(bool updateCollisionModel=false)
Requests a VirtualRobot for use in rtRun *.
const VirtualRobot::RobotPtr & rtGetRobot()
TODO make protected and use attorneys.
ControlTargetBase * useControlTarget(const std::string &deviceName, const std::string &controlMode)
Declares to calculate the ControlTarget for the given ControlDevice in the given ControlMode when rtR...
const NJointZeroTorqueOrVelocityWithFTControllerTarget & rtGetControlStruct() const
MutexType controlDataMutex
std::lock_guard< std::recursive_mutex > LockGuardType
void writeControlStruct()
NJointZeroTorqueOrVelocityWithFTControllerTarget & getWriterControlStruct()
void reinitTripleBuffer(const NJointZeroTorqueOrVelocityWithFTControllerTarget &initial)
The SingleTypeVariantList class is a subclass of VariantContainer and is comparable to a std::vector<...
void onPublish(const SensorAndControl &, const DebugDrawerInterfacePrx &, const DebugObserverInterfacePrx &) override
static WidgetDescription::WidgetPtr GenerateConfigDescription(const VirtualRobot::RobotPtr &, const std::map< std::string, ConstControlDevicePtr > &, const std::map< std::string, ConstSensorDevicePtr > &)
std::vector< ControlTarget1DoFActuatorZeroVelocity * > targetsVel
void setControllerTarget(const Ice::FloatSeq &, const Ice::Current &) override
NJointZeroTorqueOrVelocityWithFTController(RobotUnitPtr prov, const NJointZeroTorqueOrVelocityWithFTControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
std::vector< ControlTarget1DoFActuatorZeroTorque * > targetsTorque
static NJointZeroTorqueOrVelocityWithFTControllerConfigPtr GenerateConfigFromVariants(const StringVariantBaseMap &values)
void rtPostDeactivateController() override
This function is called after the controller is deactivated.
void rtRun(const IceUtil::Time &sensorValuesTimestamp, const IceUtil::Time &timeSinceLastIteration) override
TODO make protected and use attorneys.
std::string getClassName(const Ice::Current &) const override
void rtPreActivateController() override
This function is called before the controller is activated.
std::vector< bool > torqueControlled
static double LimitTo(double value, double absThreshold)
Brief description of class targets.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#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...
std::shared_ptr< class Robot > RobotPtr
NJointControllerRegistration< NJointZeroTorqueOrVelocityWithFTController > registrationControllerNJointZeroTorqueOrVelocityWithFTController("NJointZeroTorqueOrVelocityWithFTController")
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
std::map< std::string, VariantBasePtr > StringVariantBaseMap
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
IceUtil::Handle< class RobotUnit > RobotUnitPtr
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
detail::ControlThreadOutputBufferEntry SensorAndControl
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)