robotlearn / pyrobolearn

PyRoboLearn: a Python framework for Robot Learning
Apache License 2.0
400 stars 63 forks source link

Something Error when try to connect with ros #35

Closed TFLQW closed 4 years ago

TFLQW commented 4 years ago

When I try to run the file pyrobolearn/examples/middlewares/bullet_ros_publisher.py, some errors occur, File "/pyrobolearn/pyrobolearn/utils/parsers/robots/urdf_parser.py", line 39, in init super().init(filename) TypeError: super() takes at least 1 argument (0 given) so I have changed to super(URDFParser, self).init(filename) another error occurs when I try to load the kuka_iiwa model in bullet_ros_publisher.py in file /pyrobolearn/pyrobolearn/simulators/middlewares/robots/iiwa14.py if self.is_publishing: q = self.subscriber.get_joint_positions() dq = self.subscriber.get_joint_velocities() tau = self.subscriber.get_joint_torques() if q is None: # +++++ return 0 # +++++ if len(q) > 0: q_indices = None if joint_ids is None else self.q_indices[joint_ids] if q_indices is not None: q[q_indices] = positions if velocities is not None: dq[q_indices] = velocities the symbol '+++++' part is added to solve the problem of if q is None, the NoneType has no len()

TFLQW commented 4 years ago

Two problems: [pyrobolearn/utils/parsers/robots/urdf_parser.py] def init(self, filename=None): super(URDFParser, self).init(filename)

[pyrobolearn/simulators/middlewares/robots/ur5.py] q_indices = None if joint_ids is None else self.q_indices[joint_ids] if q_indices is None: q_indices = np.array(range(len(self.msg_joint_names))) positions = positions[:len(self.msg_joint_names)] q_indices = q_indices[q_indices < len(self.msg_joint_names)] positions = positions[q_indices] args = np.array(['Joint' + str(i+1) for i in range(len(self.msg_joint_names))]) kwargs = dict(zip(args[q_indices], positions)) velocity_scale = 0.1 # 1 = max velocity, 0 = don't move duration_time = 10 # 10 secs response = self.reset_joint_service(scale=velocity_scale, time=duration_time, **kwargs)

TFLQW commented 4 years ago

If you use the pycharm IDE you need to set the ros settings: in the pycharm.desktop file need to edit this term as: Exec=bash -i /home/.../opt/pycharm-community-2020.1.2/bin/pycharm.sh

TFLQW commented 4 years ago

to sovle this problem :rospkg.common.ResourceNotFound: roslaunch

HongminWu commented 4 years ago

@TFLQW did you fix this problem with the following error? response = self.reset_joint_service(**kwargs, scale=velocity_scale, time=duration_time) SyntaxError: invalid syntax