This repository was archived by the owner on Nov 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,31 @@ class GetDimension : public Command {
6060 }
6161}; // class GetDimension
6262
63+ // Command getJointNames
64+ class GetJointNames : public Command {
65+ public:
66+ // / Create command and store it in Entity
67+ // / \param entity instance of Entity owning this command
68+ // / \param docstring documentation of the command
69+ GetJointNames (DynamicPinocchio& entity, const std::string& docstring)
70+ : Command(entity, std::vector<Value::Type>(), docstring){}
71+ virtual Value doExecute () {
72+ DynamicPinocchio& robot = static_cast <DynamicPinocchio&>(owner ());
73+ if (robot.m_model == 0x0 ){
74+ SOT_THROW ExceptionDynamic (ExceptionDynamic::GENERIC,
75+ " model has not been initialized." );
76+ }
77+ const std::vector<std::string>& jointNames = robot.m_model ->names ;
78+ // Remove first joint names 'universe'
79+ std::size_t n (jointNames.size ());
80+ assert (n >= 1 );
81+ std::vector<Value> res;
82+ for (std::size_t i=1 ; i<jointNames.size (); ++i) {
83+ res.push_back (Value (jointNames[i]));
84+ }
85+ return Value (res);
86+ }
87+ };
6388} // namespace command
6489} /* namespace sot */
6590} /* namespace dynamicgraph */
Original file line number Diff line number Diff line change @@ -202,6 +202,9 @@ DynamicPinocchio::DynamicPinocchio(const std::string& name)
202202 " string (joint name)" );
203203 addCommand (" createAcceleration" ,
204204 makeCommandVoid2 (*this , &DynamicPinocchio::cmd_createAccelerationSignal, docstring));
205+ docstring=" \n "
206+ " Return robot joint names.\n\n " ;
207+ addCommand (" getJointNames" , new command::GetJointNames (*this , docstring));
205208 }
206209
207210 sphericalJoints.clear ();
You can’t perform that action at this time.
0 commit comments