fix errors appearing when using Py3.5

This commit is contained in:
Brian Delhaisse
2019-06-13 22:33:39 +02:00
parent 54a9a80e83
commit 80c372da11
4 changed files with 16 additions and 5 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
import os
import numpy as np
from legged_robot import QuadrupedRobot
from pyrobolearn.robots.legged_robot import QuadrupedRobot
__author__ = "Brian Delhaisse"
__copyright__ = "Copyright 2018, PyRoboLearn"
+5
View File
@@ -6,11 +6,16 @@ Dependencies:
- `pyrobolearn.utils`
"""
import sys
import copy
from pyrobolearn.simulators import Simulator
from pyrobolearn.utils.transformation import get_rpy_from_quaternion, get_matrix_from_quaternion
# define long for Python 3.x
if int(sys.version[0]) == 3:
long = int
__author__ = "Brian Delhaisse"
__copyright__ = "Copyright 2018, PyRoboLearn"
+1 -1
View File
@@ -9,7 +9,7 @@ from .bullet import Bullet
from .bullet import Bullet as BulletSim # alias # TODO: remove that alias
# dart simulator
from .dart import Dart
# from .dart import Dart
# # PyBullet simulator
# import pybullet
+9 -3
View File
@@ -4,12 +4,17 @@
This includes notably the joint positions, velocities, and force/torque states.
"""
import sys
from abc import ABCMeta, abstractmethod
from pyrobolearn.states.state import State
from pyrobolearn.worlds import World
from pyrobolearn.robots import Body
# define long for Python 3.x
if int(sys.version[0]) == 3:
long = int
__author__ = "Brian Delhaisse"
__copyright__ = "Copyright 2018, PyRoboLearn"
@@ -49,9 +54,10 @@ class BodyState(State):
"""
super(BodyState, self).__init__(window_size=window_size, axis=axis, ticks=ticks)
if not isinstance(body, (Body, int)):
raise TypeError("Expecting an instance of Body, or an identifier from the simulator/world.")
if isinstance(body, int):
if not isinstance(body, (Body, int, long)):
raise TypeError("Expecting an instance of Body, or an identifier from the simulator/world, instead got: "
"{}".format(type(body)))
if isinstance(body, (int, long)):
if not isinstance(world, World):
# try to look for the world in global variables
if 'world' in globals() and isinstance(globals()['world'], World): # O(1)