finding difficult to move the quadruped robot #2449
Unanswered
AchyuthGS
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
Uh oh!
There was an error while loading. Please reload this page.
-
Intro
Hi!
I am a graduate student, I use MuJoCo for my research on quadruped robot.
My setup
import mujoco as mj
from mujoco.glfw import glfw
import numpy as np
import os
from curve import bezier_curve
from scipy.spatial.transform import Rotation as R
xml_path = 'quadrap1.xml'
simend = 100 #simulation time
print_camera_config = 0
For callback functions
button_left = False
button_middle = False
button_right = False
lastx = 0
lasty = 0
def quat2euler(quat_mujoco):
#mujocoy quat is constant,x,y,z,
#scipy quaut is x,y,z,constant
quat_scipy = np.array([quat_mujoco[3],quat_mujoco[0],quat_mujoco[1],quat_mujoco[2]])
def init_controller(model,data):
#initialize the controller here. This function is called once, in the beginning
pass
def controller(model, data):
#put the controller here. This function is called inside the simulation.
#pass
data.ctrl[0] = 0
data.ctrl[1] = 0.3
data.ctrl[2] = -0.5
data.ctrl[3] = 0
data.ctrl[4] = 0.3
data.ctrl[5] = -0.5
data.ctrl[6] = 0
data.ctrl[7] = 0.3
data.ctrl[8] = -0.5
data.ctrl[9] = 0
data.ctrl[10] = 0.3
data.ctrl[11] = -0.5
def keyboard(window, key, scancode, act, mods):
if act == glfw.PRESS and key == glfw.KEY_BACKSPACE:
mj.mj_resetData(model, data)
mj.mj_forward(model, data)
def mouse_button(window, button, act, mods):
# update button state
global button_left
global button_middle
global button_right
def mouse_move(window, xpos, ypos):
# compute mouse displacement, save
global lastx
global lasty
global button_left
global button_middle
global button_right
def scroll(window, xoffset, yoffset):
action = mj.mjtMouse.mjMOUSE_ZOOM
mj.mjv_moveCamera(model, action, 0.0, -0.05 *
yoffset, scene, cam)
#get the full path
dirname = os.path.dirname(file)
abspath = os.path.join(dirname + "/" + xml_path)
xml_path = abspath
MuJoCo data structures
model = mj.MjModel.from_xml_path(xml_path) # MuJoCo model
data = mj.MjData(model) # MuJoCo data
cam = mj.MjvCamera() # Abstract camera
opt = mj.MjvOption() # visualization options
Init GLFW, create window, make OpenGL context current, request v-sync
glfw.init()
window = glfw.create_window(1200, 900, "Demo", None, None)
glfw.make_context_current(window)
glfw.swap_interval(1)
initialize visualization data structures
mj.mjv_defaultCamera(cam)
mj.mjv_defaultOption(opt)
scene = mj.MjvScene(model, maxgeom=10000)
context = mj.MjrContext(model, mj.mjtFontScale.mjFONTSCALE_150.value)
install GLFW mouse and keyboard callbacks
glfw.set_key_callback(window, keyboard)
glfw.set_cursor_pos_callback(window, mouse_move)
glfw.set_mouse_button_callback(window, mouse_button)
glfw.set_scroll_callback(window, scroll)
Example on how to set camera configuration
cam.azimuth = 3.5976562500001448 ; cam.elevation = -26.478125000000013 ; cam.distance = 3.4990578128076946
cam.lookat =np.array([ 0.0 , 0.0 , 0.0 ])
#initialize the controller
init_controller(model,data)
data.ctrl[0] = 0
data.ctrl[1] = 0
data.ctrl[2] = 0
data.ctrl[3] = 0
data.ctrl[4] = 0
data.ctrl[5] = 0
data.ctrl[6] = 0
data.ctrl[7] = 0
data.ctrl[8] = 0
data.ctrl[9] = 0
data.ctrl[10] = 0
data.ctrl[11] = 0
#set the controller
mj.set_mjcb_control(controller)
while not glfw.window_should_close(window):
time_prev = data.time
glfw.terminate()
My question
i am able to control the joints of the bot but unable to move that. i am unable to figure it out how the controller should be setup
Minimal model and/or code that explain my question
No response
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions