Two-wheeled self-balancing robot (Segway) + linear MPC – state definition, actuator model and MuJoCo suitability #3101
Unanswered
hamski211-del
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’m working on a two-wheeled self-balancing robot (Segway-like system) controlled with a linear MPC designed from a linearized model.
My goal is to reproduce the same controller that I previously tested in PyBullet, but now in MuJoCo.
I’m not sure if:
I’m reading the state correctly from MuJoCo
my actuator model is physically consistent
MuJoCo is the right tool for this type of robot (I’ve heard it’s mainly used for manipulators)
So I would really appreciate a sanity check and general advice
My setup
-MuJoCo (latest)
-Python API
-Free joint base
-Two hinge joints for wheels
-Motors with gear and force limits
-Linear MPC designed in continuous time and discretized in Python
[theta_avg,theta_dot,body_pitch,body_pitch_rate,yaw,yaw_rate]
My question
1.This is how I currently read the state from MuJoCo:
--- STATE MEASUREMENT ---
left_pos_idx = m1.joint("joint_left_wheel").qposadr[0]
right_pos_idx = m1.joint("joint_right_wheel").qposadr[0]
left_vel_idx = m1.joint("joint_left_wheel").dofadr[0]
right_vel_idx = m1.joint("joint_right_wheel").dofadr[0]
angle, axis, axis_angle_rad = quaternion_to_axis_angle(d.qpos[3:7])
gyro = d.qvel[3:6]
theta_avg_rad = 0.5 * (d.qpos[left_pos_idx] + d.qpos[right_pos_idx])
theta_dot_rad = 0.5 * (d.qvel[left_vel_idx] + d.qvel[right_vel_idx])
W = 0.4
wheel_radius = 0.15 / 2
phi_odo_rad = (wheel_radius / W) * (
d.qpos[right_pos_idx] - d.qpos[left_pos_idx]
)
phi_dot_rad = gyro[2]
state = np.array([
theta_avg_rad,
theta_dot_rad,
-axis_angle_rad[1],
-gyro[1],
axis_angle_rad[2],
phi_dot_rad
]).reshape(-1, 1)
Does this look correct for a Segway-type robot with a free base?
Is using axis-angle here a good idea, or should I extract pitch/yaw differently?
2.My linear model input is motor voltage, but MuJoCo motors apply torque.
In PyBullet I handled this by scaling: B *= R_dc / k_t whre R_dc is Resistance of the winding of the DC motor and k_t is Torque constant of the DC motor
Is there a recommended way to model DC motor dynamics directly in MuJoCo XML?
For example:
-torque constant
-back-EMF
-resistance
Should this be done via:
-gear
-custom actuator
-joint damping
or something else?
Right now I just send torque:
d.ctrl[0] = tau_l
d.ctrl[1] = tau_r
3.Is MuJoCo a good choice for this?
Most examples I see are:
-manipulators
-legged robots
Is MuJoCo well suited for:
-underactuated
-dynamically unstable
-balancing robots
like a Segway?
4.Model sanity check
General questions:
Is using a free joint for the base correct for this type of robot?
Are my wheel joints defined in the right way?
Any common mistakes for this type of system in MuJoCo?
Minimal model and/or code that explain my question
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions