Closed lucapa17 closed 1 year ago
We are facing a new problem. By the moment that we'd like to access to joints, we should include the corresponding library:
In phase of compilation, we had the following error:
So we tried to adding manually "Joint.hh" (taken from https://github.com/gazebosim/gz-sim/blob/668b757c962e23f33c826487e4f725b3fd4486c5/include/gz/sim/Joint.hh#L32) in the folder in which it should be. The compilation worked, but the execution gave us the following error:
Good ninja move, great attitude! Anyhow, in this specific case just manually copying the gz/sim/Joint.hh
will not work, as the symbols that it refers to are not contained in the symbol table of gz-sim libraries (if you do not know what symbols are, check https://github.com/green7ea/cpp-compilation). So, it is strange that that header is mentioned in the docs and it is not available for you. However, you are right: if we look for that file, it is not part of 7.4.0 (i.e. the latest release), see https://github.com/gazebosim/gz-sim/blob/gz-sim7_7.4.0/include/gz/sim/Joint.hh .
However, if you just need the SensorByName
function, you can look into its implementation and copy locally the implementation (from https://github.com/gazebosim/gz-sim/blob/668b757c962e23f33c826487e4f725b3fd4486c5/src/Joint.cc#LL161C1-L169C1):
Entity Joint::SensorByName(const EntityComponentManager &_ecm,
const std::string &_name) const
{
return _ecm.EntityByComponents(
components::ParentEntity(this->dataPtr->id),
components::Name(_name),
components::Sensor());
}
We succeeded in accessing the ForceTorque sensor and print its name and its parent entity name to the command line (https://github.com/robotology/study-gazebo-garden-yarp-plugins/commit/421480bda8d436f6341a927931149d0afe6fb9f5). Now we are trying to print the Force value and Torque value.
Great!
Okay we should have done (https://github.com/robotology/study-gazebo-garden-yarp-plugins/commit/e547963c094c73373ccf1cad2763006bb8b61a45). We should have printed correctly to the command line FT measures and the simulation time, as the following:
1.426
Force: 0 0 98
Torque: 0 0 0
We couldn't use ForceTorqueSensor such as in ForceTorqueDriver.cpp (gazebo-yarp-plugins) because in Gazebo Garden is not implemented, so we calculated directly the values taking as example ForceTorque.cc.
Tell us if it's okay or if it could have been done in a better way. If everything is okay we can close the issue.
If everything is okay we can close the issue.
Ok for me! I am curious to understand why we can't use the ForceTorque system that seems to be available in 7.4.0 (see https://github.com/gazebosim/gz-sim/blob/gz-sim7_7.4.0/src/systems/force_torque/ForceTorque.cc), but this is for sure a nice achievement!
Note that today gz-sim7 7.5.0 was released: https://github.com/gazebosim/gz-sim/tree/gz-sim7_7.5.0 , so I guess that if you update it yu should get access to the Model::JointByName and Joint::SensorByName methods.
Note that today gz-sim7 7.5.0 was released: https://github.com/gazebosim/gz-sim/tree/gz-sim7_7.5.0 , so I guess that if you update it yu should get access to the Model::JointByName and Joint::SensorByName methods.
Okay done! (https://github.com/robotology/study-gazebo-garden-yarp-plugins/commit/7ff1bbe7d756d5bee7eb14850952ab910ec2acb2)
Given your example, I guess that
Model::JointByName
andJoint::SensorByName
methods may be useful?