Why mocap can not specify the manipulator's initial pose #2272
Unanswered
DuYi-angle
asked this question in
Asking for Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Intro
.
My setup
Mujoco3.26, python, ubuntu20.04
My question
I am adding mocap to the end of a Kinova Gen3 in mujoco to control a robotic arm. When I initialize the robotic arm, it works fine. But when the simulation starts, the robotic arm immediately returns to zero and then moves under the control of the mocap. I want to know why this is happening.This is my running code:
import mujoco
import mujoco.viewer
import numpy as np
import time
from copy import deepcopy
class KinovaControl:
def init(self, filename, init_position='home', is_show=True):
self.model = mujoco.MjModel.from_xml_path(filename)
self.data = mujoco.MjData(self.model)
def set_init(self, init_position):
self.cnt = 0
self.init_qpos = np.array([0, 0.26179939, 3.14159265, -2.26892803, 0, 0.95993109, 1.57079633])
self.data.qpos = self.init_qpos
mujoco.mj_forward(self.model, self.data)
def controller(self, model, data):
tmp = deepcopy(self.init_qpos)
tmp[-1] += 0.01 * self.cnt
self.cnt += 1
# self.data.ctrl = tmp
self.data.mocap_pos[0][1] -= 0.0001
self.data.mocap_quat[0] = [1, 0, 0, 0]
# print(self.data.body('bracelet_link'))
def main(self):
while True:
mujoco.mj_step(self.model, self.data)
if self.viewer.is_running():
self.viewer.sync()
time.sleep(0.01)
def keyboard_cb(self, keycode):
if chr(keycode) == ' ':
mujoco.mj_resetData(self.model, self.data)
mujoco.mj_forward(self.model, self.data)
self.set_init('home')
if name == "main":
xml_path = "/home/zhangsl/DualArmControl/kinova_gen3/scene.xml"
kinova_control = KinovaControl(xml_path, 'home')
kinova_control.main()
My xml is modified from mujoco_menagerie
kinova_gen3.zip
test.mp4
Minimal model and/or code that explain my question
If you encountered the issue in a complex model, please simplify it as much as possible (while still reproducing the issue).
Model:
minimal XML
Code:
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions