Closed abhayraw1 closed 3 years ago
same question here
Which version of the toolbox and Swift are you ruunning? Are you installed off PyPI or from Github? Also try deleting the browser cache.
For me: using python 3.9.2 64-bit
. Swift is directly built from Github.
called by:
import roboticstoolbox as rtb
env = rtb.backends.Swift()
env.launch()
From swift\Swift.py
:
Could not connect to the Swift simulator
From my browser Firefox
instantly:
Error code: 404
Message: File not found.
Error code explanation: HTTPStatus.NOT_FOUND - Nothing matches the given URI.
Tried with firewall off, different browser, PyPI version - nothing changes.
Can you please try this:
Found the bug for my case.
https://github.com/jhavl/swift/blob/84ef2a59c5dc5af4ddecb89e8aff10c037f195bb/swift/Swift.py#L121
As I run the code from a different partition, changing the cwd makes it impossible to find the files. Therefore it should be more something like:
os.chdir(root_dir.anchor)
By the way: big thanks for your work 😃
Having the same issue, tried things posted in this thread but to no avail.
Browser console shows:
Loading module from “http://localhost:52000/js/index.js” was blocked because of a disallowed MIME type (“text/plain”).
Python Python 3.9.0 64-bit
Swift installed via pip
Runtime console error: Could not connect to the Swift simulator
I have the same issue here, I'm on Windows 7 64bit, WinPython 3.8.8.0 and the latest Official "obotics-toolbox-python" 0.9.1.
I can't start the Swift, see my issue report here:
Can't open the Swift simulator in the browser (Windows 7, Python 3.8)
Also, I can't start the vpython backend. I can only show a vpython window in Firefox tab by such command mentioned here vpython · PyPI
from vpython import *
sphere()
So, I guess it is a socket/server error under Windows OS.
Any one has find the solution?
Found the bug for my case.
https://github.com/jhavl/swift/blob/84ef2a59c5dc5af4ddecb89e8aff10c037f195bb/swift/Swift.py#L121
As I run the code from a different partition, changing the cwd makes it impossible to find the files. Therefore it should be more something like:
os.chdir(root_dir.anchor)
By the way: big thanks for your work smiley
Hi, by using this changes, I can view the 3D arm in Swift Simulator(inside Firefox) now. Thanks!
This is the patch to apply the changes to the latest git version:
swift/SwiftRoute.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/swift/SwiftRoute.py b/swift/SwiftRoute.py
index d2f0c28..c826e14 100644
--- a/swift/SwiftRoute.py
+++ b/swift/SwiftRoute.py
@@ -147,7 +147,8 @@ class SwiftServer:
root_dir = Path(sw.__file__).parent / 'out'
# os.chdir(Path.home())
- os.chdir(Path.home().anchor)
+ # os.chdir(Path.home().anchor)
+ os.chdir(root_dir.anchor)
class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
def log_message(self, format, *args):
When I try to use the git version of roboticstoolbox-python
and swift-sim
, I notice that I can't run the swift simulator.
See my report here:
https://github.com/petercorke/robotics-toolbox-python/issues/209#issuecomment-817121300
It looks like when using the git version, the package are pointed by roboticstoolbox-python.egg-link
and swift-sim.egg-link
. Which has the contents like:
E:\code\robotics\robotics-toolbox-python
.
and
E:\code\robotics\swift
.
Which means the packages are points to my local git clone of the packages.
But I see that: E:\code\robotics\robotics-toolbox-python\roboticstoolbox\backends\swift
, in this folder, I only have a single file named __init__.py
, do I have to copy some code to here?
When I try to use the git version of
roboticstoolbox-python
andswift-sim
, I notice that I can't run the swift simulator.See my report here:
petercorke/robotics-toolbox-python#209 (comment)
It looks like when using the git version, the package are pointed by
roboticstoolbox-python.egg-link
andswift-sim.egg-link
. Which has the contents like:E:\code\robotics\robotics-toolbox-python .
and
E:\code\robotics\swift .
Which means the packages are points to my local git clone of the packages.
But I see that:
E:\code\robotics\robotics-toolbox-python\roboticstoolbox\backends\swift
, in this folder, I only have a single file named__init__.py
, do I have to copy some code to here?
OK, I found the solution of this issue now.
When I clone the repo in Windows, the folder name is E:\code\robotics\robotics-toolbox-python\roboticstoolbox\backends\swift
, and the swift
should be changed to Swift
, then the Swift backend works now.
Question:
I see that from the github web address, https://github.com/petercorke/robotics-toolbox-python/tree/master/roboticstoolbox/backends/swift
It also use the wrong folder name, can you fix it?
Thanks.
Sorry for the radio silence on this one. Regarding the most recent comment: the Swift component of RTB was extracted from that repo and put into this one to make it possible for Swift to run standalone. So now it can be usedlike this:
import swift
env = swift.Swift()
For backwards compatibility and symmetry with other backends, it can be also used like this:
from roboticstoolbox.backends import swift
env = swift.Swift()
Where in the latter the folder was renamed to swift
from Swift
to match the first use case and to make the syntax for both uses the same. Hope that makes sense - I'm also trying to remove bugs resulting from the name switch.
@adv4ncr: Regarding the first issue about the directory being wrong since you run code from a different partition. This is especially tricky. On the Python side of things, there is a HTTP server which provides files to the browser to display the robot/whatever meshes need to be displayed. The HTTP server can only serve files in or above where it is rooted. I think I'll have to add an optional keyword argument to Swift to specify where to launch the server for cases such as yours. Any thoughts on this?
Sorry for the radio silence on this one. Regarding the most recent comment: the Swift component of RTB was extracted from that repo and put into this one to make it possible for Swift to run standalone. So now it can be usedlike this:
import swift env = swift.Swift()
For backwards compatibility and symmetry with other backends, it can be also used like this:
from roboticstoolbox.backends import swift env = swift.Swift()
Where in the latter the folder was renamed to
swift
fromSwift
to match the first use case and to make the syntax for both uses the same. Hope that makes sense - I'm also trying to remove bugs resulting from the name switch.
Hi, thanks for your explanation, now you have to fix this line:
from roboticstoolbox.backends.Swift import Swift
This still exist in the latest github master.
Sorry for the radio silence on this one. Regarding the most recent comment: the Swift component of RTB was extracted from that repo and put into this one to make it possible for Swift to run standalone. So now it can be usedlike this:
import swift env = swift.Swift()
For backwards compatibility and symmetry with other backends, it can be also used like this:
from roboticstoolbox.backends import swift env = swift.Swift()
Where in the latter the folder was renamed to
swift
fromSwift
to match the first use case and to make the syntax for both uses the same. Hope that makes sense - I'm also trying to remove bugs resulting from the name switch.Hi, thanks for your explanation, now you have to fix this line:
from roboticstoolbox.backends.Swift import Swift
This still exist in the latest github master.
I change the line to:
roboticstoolbox/robot/Robot.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/roboticstoolbox/robot/Robot.py b/roboticstoolbox/robot/Robot.py
index e47a159e..924359eb 100644
--- a/roboticstoolbox/robot/Robot.py
+++ b/roboticstoolbox/robot/Robot.py
@@ -1201,7 +1201,7 @@ class Robot(ABC, DynamicsMixin, IKMixin):
raise NotImplementedError(
'Plotting in Swift is not implemented for DHRobots yet')
- from roboticstoolbox.backends.Swift import Swift
+ from roboticstoolbox.backends.swift import Swift
env = Swift()
elif backend.lower() == 'pyplot':
@@ -1304,9 +1304,9 @@ class Robot(ABC, DynamicsMixin, IKMixin):
# Add the self to the figure in readonly mode
# Add the self to the figure in readonly mode
if q.shape[0] == 1:
- env.launch(self.name + ' Plot', limits=limits, fig=fig)
+ env.launch(name = self.name + ' Plot', limits=limits, fig=fig)
else:
- env.launch(self.name + ' Trajectory Plot', limits=limits, fig=fig)
+ env.launch(name = self.name + ' Trajectory Plot', limits=limits, fig=fig)
env.add(
self, readonly=True, jointaxes=jointaxes, jointlabels=jointlabels,
But I still can't run the simple test program:
import roboticstoolbox as rp
panda = rp.models.Panda()
panda.plot(q=panda.qr)
I got such error:
runfile('E:/code/robotics/robotics-toolbox-python/roboticstoolbox/examples/mytest.py', wdir='E:/code/robotics/robotics-toolbox-python/roboticstoolbox/examples')
Traceback (most recent call last):
File "E:\code\robotics\robotics-toolbox-python\roboticstoolbox\examples\mytest.py", line 4, in <module>
panda.plot(q=panda.qr)
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\robot\Robot.py", line 1311, in plot
env.add(
TypeError: add() got an unexpected keyword argument 'jointaxes'
I'm a bit sad, because I got running errors here or there.
But I still can't run the simple test program:
import roboticstoolbox as rp panda = rp.models.Panda() panda.plot(q=panda.qr)
I got such error:
runfile('E:/code/robotics/robotics-toolbox-python/roboticstoolbox/examples/mytest.py', wdir='E:/code/robotics/robotics-toolbox-python/roboticstoolbox/examples') Traceback (most recent call last): File "E:\code\robotics\robotics-toolbox-python\roboticstoolbox\examples\mytest.py", line 4, in <module> panda.plot(q=panda.qr) File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\robot\Robot.py", line 1311, in plot env.add( TypeError: add() got an unexpected keyword argument 'jointaxes'
I'm a bit sad, because I got running errors here or there.
I take some time to track down this error, it looks like the commit:
consolidate all plot/teach in robot class · petercorke/robotics-toolbox-python@8bb9ac5
I see that the the backend PyPlot has changed the add()
function prototype, but not the other backends, currently, the vPython
backend still has the function definition like:
def add(self, dhrobot, fig_num=0, name=None, **kwargs):
Hey @asmwarrior, on the latest commits for robotics toolbox and swift (you will need to re-install swift) I can run:
import roboticstoolbox as rp
panda = rp.models.Panda()
panda.plot(q=panda.qr)
Hey @adv4ncr, @asmwarrior,
I've experimented with the recommended change to the server root. It turns out that using root_dir
doesn't break other paths like I expected. Thanks for this recommendation! This change has been pushed to Github and will be in the next PyPI release.
Hey @asmwarrior, on the latest commits for robotics toolbox and swift (you will need to re-install swift) I can run:
import roboticstoolbox as rp panda = rp.models.Panda() panda.plot(q=panda.qr)
I just updated to the latest github version of swift, robotictoolbox, spatial-math, and running this code still gives me errors:
In [1]: runfile('E:/code/robotics/robotics-toolbox-python/roboticstoolbox/examples/mytest2.py', wdir='E:/code/robotics/robotics-toolbox-python/roboticstoolbox/examples')
error parsing URDF file E:\download\sci\Winpython64-3.8.8.0\WPy64-3880\python-3.8.8.amd64\Lib\site-packages\rtbdata\xacro\franka_description\robots\panda_arm_hand.urdf.xacro
Traceback (most recent call last):
File "E:\code\robotics\robotics-toolbox-python\roboticstoolbox\examples\mytest2.py", line 3, in <module>
panda = rp.models.Panda()
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\models\URDF\Panda.py", line 33, in __init__
links, name = self.URDF_read(
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\robot\ERobot.py", line 1213, in URDF_read
raise e
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\robot\ERobot.py", line 1210, in URDF_read
urdf = URDF.loadstr(urdf_string, file_path)
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\tools\urdf\urdf.py", line 1952, in loadstr
return URDF._from_xml(node, path)
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\tools\urdf\urdf.py", line 1980, in _from_xml
return URDF(**kwargs)
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\tools\urdf\urdf.py", line 1767, in __init__
childlink.v = var
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\robot\ELink.py", line 92, in v
self._update_fknm()
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\robot\ELink.py", line 484, in _update_fknm
shape_base, shape_wT, shape_sT, shape_sq = self._get_fknm()
File "e:\code\robotics\robotics-toolbox-python\roboticstoolbox\robot\ELink.py", line 448, in _get_fknm
shape_sq.append(shap._sq)
AttributeError: 'Mesh' object has no attribute '_sq'
In [2]:
Can you have a look? Thanks.
This sounds like you need to be running the github version of spatialgeometry
This sounds like you need to be running the github version of spatialgeometry
Good, this solved the problem. I think I have 4 github version of the repo: "robotics-toolbox-python, spatialgeometry, spatialmath-python and swift". I think this should be stated in some document/front page, so other guys can't meet the same issue as mine. Thanks.
I am trying to launch the swift simulator with the Panda manipulator. I have a simple jupyter notebook with the following code (as mentioned in the readme):
On execution, a new tab opens up in my browser with a small box on the top right corner displaying the timestamp and FPS and nothing happens after this. On the notebook side I get an excpetion, about 5-10 seconds after executing the cell. Here is the stacktrace for that:
Browser Window:
I'm running this on a conda environment in Windows 10 with python
3.7.7
PS: I tried disabling the firewall but that didn't help either.