Skip to content

giskardpy import error when I use giskardpy interface #328

Description

@TahaTabatabaei

Hello,

I guess the way pycram imports GiskardWrappr is deprecated. Please check it.

The error I get:

[grasp_listener-2] Exception in thread Thread-4 (send_goal_to_giskard):
[grasp_listener-2] Traceback (most recent call last):
[grasp_listener-2]   File "/usr/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
[grasp_listener-2]     self.run()
[grasp_listener-2]   File "/usr/lib/python3.12/threading.py", line 1010, in run
[grasp_listener-2]     self._target(*self._args, **self._kwargs)
[grasp_listener-2]   File "/home/tahaos/Code/Projects/acrambly2/workspace/ros/install/my_playground/lib/python3.12/site-packages/my_playground/grasp_listener.py", line 62, in send_goal_to_giskard
[grasp_listener-2]     giskard.achieve_cartesian_goal(goal_pose=goal_pose,
[grasp_listener-2]   File "/home/tahaos/Code/Projects/acrambly2/workspace/ros/build/pycram/src/pycram/external_interfaces/giskard.py", line 63, in wrapper
[grasp_listener-2]     from giskardpy.python_interface.old_python_interface import OldGiskardWrapper as GiskardWrapper
[grasp_listener-2] ModuleNotFoundError: No module named 'giskardpy.python_interface'

My script:

import rclpy
import rclpy.executors
from rclpy.node import Node
print("Importing rclpy done")
from geometry_msgs.msg import PoseStamped
import sys
import traceback

import threading

# from pycram.worlds.bullet_world import BulletWorld
# print("Importing BulletWorld done")
# from pycram.world_concepts.world_object import Object
# print("Importing Object done")
# from pycram.datastructures.enums import ObjectType
# print("Importing ObjectType done")
from pycram.external_interfaces import giskard
print("Importing giskard done")
from pycram.datastructures.pose import Pose
print("Importing Pose done")


class GraspListener(Node):
    def __init__(self):
        super().__init__('grasp_listener')
        print("Starting GraspListener Node ...")

        self.subscriber = self.create_subscription(
            PoseStamped,
            'grasp_pose',
            self.callback,
            10
        )
        print('Listening on topic grasp_pose')


    def callback(self, msg):
        print("Callback triggered")

        print(
            f'Received grasp at time {msg.header.stamp.sec}.{msg.header.stamp.nanosec}'
        )
        print(
            f'Pose: Position({msg.pose.position.x}, {msg.pose.position.y}, {msg.pose.position.z}), '
            f'Orientation({msg.pose.orientation.x}, {msg.pose.orientation.y}, {msg.pose.orientation.z}, {msg.pose.orientation.w})'
        )


        threading.Thread(target=self.send_goal_to_giskard, args=(msg,)).start()


    def send_goal_to_giskard(self, pose_stamped):

        print(f"Preparing to send goal to Giskard: {pose_stamped}")
        goal_pose = Pose(
            position=pose_stamped.pose.position,
            orientation=pose_stamped.pose.orientation
        )
        print(f"Sending goal to Giskard")
        giskard.achieve_cartesian_goal(goal_pose=goal_pose,
                                        root_link='world',
                                        tip_link='ee_link')

I use ros2 jazzy.
The pycram was downloaded from dev branch by following the installation guide.
The giskardpy was downloaded from the giskard_library branch.

I can solve it if I change the line 63 in this file:
src/pycram/external_interfaces/giskard.py
from:
from giskardpy.python_interface.old_python_interface import OldGiskardWrapper as GiskardWrapper
to:
from giskardpy.user_interface import GiskardWrapper

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions