Skip to content

Commit 3eff546

Browse files
committed
update following rusty_mujoco
1 parent 9afb5ba commit 3eff546

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

src/physics.rs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub use rusty_mujoco as binding;
2-
pub use binding::{mjModel, mjData, ObjectId, obj, JointObjectId, Joint, mjMAXVAL, mjMINVAL};
2+
pub use binding::{mjModel, mjData, ObjectId, obj, Joint, joint, mjMAXVAL, mjMINVAL};
33

44
use binding::{Obj, mjtObj};
55
use crate::error::Error;
@@ -54,27 +54,13 @@ impl Physics {
5454
rusty_mujoco::mj_resetData(&self.model, &mut self.data);
5555
}
5656

57-
pub fn object_id_of<O: Obj>(&self, name: &str) -> Option<ObjectId<O>> {
58-
binding::mj_name2id::<O>(&self.model, name)
57+
pub fn object_id<O: Obj>(&self, name: &str) -> Option<ObjectId<O>> {
58+
self.model.object_id(name)
5959
}
6060

61-
pub fn object_name_of<O: Obj>(&self, id: ObjectId<O>) -> String {
61+
pub fn object_name<O: Obj>(&self, id: ObjectId<O>) -> String {
6262
binding::mj_id2name::<O>(&self.model, id)
6363
}
64-
65-
pub fn object_count_of<O: Obj>(&self) -> usize {
66-
match O::TYPE {
67-
mjtObj::BODY => self.model.nbody(),
68-
mjtObj::JOINT => self.model.njnt(),
69-
mjtObj::GEOM => self.model.ngeom(),
70-
mjtObj::SITE => self.model.nsite(),
71-
mjtObj::CAMERA => self.model.ncam(),
72-
mjtObj::LIGHT => self.model.nlight(),
73-
mjtObj::TENDON => self.model.ntendon(),
74-
mjtObj::ACTUATOR => self.model.nu(),
75-
_ => 0,
76-
}
77-
}
7864
}
7965

8066
pub struct Actuators<'a> {
@@ -116,17 +102,17 @@ impl Physics {
116102
self.data.set_act(id, value, &self.model)
117103
}
118104

119-
pub fn qpos<J: Joint>(&self, id: JointObjectId<J>) -> J::Qpos {
105+
pub fn qpos<J: Joint>(&self, id: ObjectId<J>) -> J::Qpos {
120106
self.data.qpos(id, &self.model)
121107
}
122-
pub fn set_qpos<J: Joint>(&mut self, id: JointObjectId<J>, qpos: J::Qpos) {
108+
pub fn set_qpos<J: Joint>(&mut self, id: ObjectId<J>, qpos: J::Qpos) {
123109
self.data.set_qpos(id, qpos, &self.model);
124110
}
125111

126-
pub fn qvel<J: Joint>(&self, id: JointObjectId<J>) -> J::Qvel {
112+
pub fn qvel<J: Joint>(&self, id: ObjectId<J>) -> J::Qvel {
127113
self.data.qvel(id, &self.model)
128114
}
129-
pub fn set_qvel<J: Joint>(&mut self, id: JointObjectId<J>, qvel: J::Qvel) {
115+
pub fn set_qvel<J: Joint>(&mut self, id: ObjectId<J>, qvel: J::Qvel) {
130116
self.data.set_qvel(id, qvel, &self.model);
131117
}
132118

0 commit comments

Comments
 (0)