How to fix an issue "The following environment does not have an entry for the variable x"?

120 views Asked by At

I find the previous answer in Eric Boehlke's question can't solve my problem.
When I try to inverse a matrix contain symbolic variable which is the output of ManipulatorDynamics(), an runtime error"The following environment does not have an entry for the variable x" happen. I test is in a simple example, the error is the same. Here is the code.
Please tell me how to solve, thank you very much!

from pydrake.all import Variable
from pydrake.all import MultibodyPlant
from underactuated import ManipulatorDynamics
import pydrake.symbolic as sym
import numpy as np

plant = MultibodyPlant(time_step=0)
parser = Parser(plant)
parser.AddModelFromFile(FindResource("models/double_pendulum.urdf"))
plant.Finalize()

# Evaluate the dynamics symbolically
q = [sym.Variable("x"), sym.Variable("y")]
v = [sym.Variable("xd"), sym.Variable("yd")]
(M, Cv, tauG, B, tauExt) = ManipulatorDynamics(plant.ToSymbolic(), q, v)
p = sym.inv(M)
1

There are 1 answers

0
Nicholas Pfaff On

The error message is a bit confusing here. Based on comments in the code, symbolic matrix inversion fails for matrices larger than 4x4.