Having trouble running code in the tutorial of motion planning section
Opened this issue · 0 comments
Could you suggest me any solutions to the following 2 issues?
Note:
*I installed dependencies and klampt files in miniconda's virtual environment and run programs
**I created different directories in Klampt for tutorials in the Python API page and modified script so that they can locate necessary files.
(1)
For Motion Planning for Articulated Robots, the following code is provided:
import klampt
from klampt.plan import cspace, robotplanning
from klampt.io import resource
import time
world = klampt.WorldModel()
world.readFile("../Klampt-examples/data/tx90cuptable.xml")
robot = world.robot(0)
this is the CSpace that will be used. Standard collision and joint limit constraints
will be checked
space = robotplanning.make_space(world, robot, edgeCheckResolution=0.05)
fire up a visual editor to get some start and goal configurations
qstart = robot.getConfig()
qgoal = robot.getConfig()
save, qstart = resource.edit("Start config", qstart, "Config", world=world)
it's worthwile to make sure that it's feasible
while save and not space.feasible(qstart):
print("Start configuration isn't feasible, please pick one that is collision-free")
save, qstart = resource.edit("Start config", qstart, "Config", world=world)
save, qgoal = resource.edit("Goal config", qgoal, "Config", world=world)
while save and not space.feasible(qgoal):
print("Goal configuration isn't feasible, please pick one that is collision-free")
save, qgoal = resource.edit("Goal config", qgoal, "Config", world=world)
But this gives the following error after setting a start position and click ok to save:
Traceback (most recent call last):
File "/Klampt/4_Motion-Planning/motioin-planning-for-articulated-robots.py", line 20, in /miniconda3/envs/klampt-env/lib/python3.7/site-packages/klampt/plan/cspaceutils.py", line 414, in feasible
while save and not space.feasible(qstart):
File "
return self.ambientspace.feasible(self.lift(x))
File "~/miniconda3/envs/klampt-env/lib/python3.7/site-packages/klampt/plan/cspaceutils.py", line 393, in lift
raise ValueError("Invalid length of embedded space vector: %d should be %d"%(len(xemb),self.m))
ValueError: Invalid length of embedded space vector: 12 should be 7
klampt.vis: ... dialog done
#########################################
GLPluginProgram.pushPlugin called after window was initialized, some actions may not be available
Returning from editor to window 0
######### QGLWidget setProgram ###############
vis.editors.run(): Result True return value [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.048014007722364006, 0.048014007722364006, -0.048014007722364006, 0.048014007722364006]
Visualization thread closing and cleaning up Qt...
######### QGLWidget close ###############
QObject::~QObject: Timers cannot be stopped from another thread
Process finished with exit code 1
(2)
For C-space-level example, the following code of feasibility test should fix the collision problem, but it didn't make any difference. I inserted it in the CircleObstacleCSpace class and commented out the original feasible. Am I supposed to change something else in the script?
def feasible(self,q):
#the radius of the robot r is 0.05
#bounds test
# We should decrease the size of the bound due to the radius of the mobile robot
self.bound = [(0.05,0.95),(0.05,0.95)]
if not CSpace.feasible(self,q):
return False
#make sure center point at least distance r from obstacles
for o in self.obstacles:
if o.contains(q): return False
return True