@@ -21,15 +21,10 @@ SimGripper::SimGripper(std::shared_ptr<Sim> sim, const SimGripperConfig &cfg)
2121 }
2222 // this->tendon_id =
2323 // mj_name2id(this->sim->m, mjOBJ_TENDON, ("split_" + id).c_str());
24- this ->joint_id_1 = this ->sim ->m ->jnt_qposadr [mj_name2id (
25- this ->sim ->m , mjOBJ_JOINT, this ->cfg .joint1 .c_str ())];
26- if (this ->joint_id_1 == -1 ) {
27- throw std::runtime_error (std::string (" No joint named " + this ->cfg .joint1 ));
28- }
29- this ->joint_id_2 = this ->sim ->m ->jnt_qposadr [mj_name2id (
30- this ->sim ->m , mjOBJ_JOINT, this ->cfg .joint2 .c_str ())];
31- if (this ->joint_id_2 == -1 ) {
32- throw std::runtime_error (std::string (" No joint named " + this ->cfg .joint2 ));
24+ this ->joint_id = this ->sim ->m ->jnt_qposadr [mj_name2id (
25+ this ->sim ->m , mjOBJ_JOINT, this ->cfg .joint .c_str ())];
26+ if (this ->joint_id == -1 ) {
27+ throw std::runtime_error (std::string (" No joint named " + this ->cfg .joint ));
3328 }
3429 // Collision geoms
3530 this ->add_collision_geoms (this ->cfg .collision_geoms , this ->cgeom , false );
@@ -95,7 +90,7 @@ void SimGripper::set_normalized_width(double width, double force) {
9590double SimGripper::get_normalized_width () {
9691 // TODO: maybe we should use the mujoco sensors? Not sure what the difference
9792 // is between reading out from qpos and reading from the sensors.
98- double width = this ->sim ->d ->qpos [this ->joint_id_1 ] / this ->MAX_JOINT_WIDTH ;
93+ double width = this ->sim ->d ->qpos [this ->joint_id ] / this ->MAX_JOINT_WIDTH ;
9994 // sometimes the joint is slightly outside of the bounds
10095 if (width < 0 ) {
10196 width = 0 ;
@@ -157,8 +152,7 @@ void SimGripper::m_reset() {
157152 this ->state = SimGripperState ();
158153 this ->state .max_unnormalized_width = this ->MAX_WIDTH ;
159154 // reset state hard
160- this ->sim ->d ->qpos [this ->joint_id_1 ] = this ->MAX_JOINT_WIDTH ;
161- this ->sim ->d ->qpos [this ->joint_id_2 ] = this ->MAX_JOINT_WIDTH ;
155+ this ->sim ->d ->qpos [this ->joint_id ] = this ->MAX_JOINT_WIDTH ;
162156 this ->sim ->d ->ctrl [this ->actuator_id ] = this ->MAX_WIDTH ;
163157}
164158
0 commit comments