Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control HC10DTP using an Xbox 360 joystick in real-time #554

Closed
tall1 opened this issue Jun 15, 2023 · 0 comments
Closed

Control HC10DTP using an Xbox 360 joystick in real-time #554

tall1 opened this issue Jun 15, 2023 · 0 comments

Comments

@tall1
Copy link

tall1 commented Jun 15, 2023

Hi,
I want to use a joystick to teleoperate the robot (real-time operation).

I wrote my own node (with the help of ChatGPT) that subscribes to the /joy topic and moves the pose in x and y when something is published to joy:

joystick_teleop.py
#!/usr/bin/env python

import rospy
from sensor_msgs.msg import Joy
from moveit_commander import RobotCommander, MoveGroupCommander
from geometry_msgs.msg import Pose


class JoystickTeleop:
    def __init__(self):
        rospy.init_node('joystick_teleop')
        rospy.logwarn("started teleop node")

        # Subscribe to the joystick topic
        rospy.Subscriber("joy", Joy, self.joy_callback)

        # Create a RobotCommander for the robot
        self.robot = RobotCommander()

        # Create a MoveGroupCommander for the desired planning group
        self.move_group = MoveGroupCommander("arm")  # Replace with your move group name

        # Initialize the target pose
        self.target_pose = Pose()

    def joy_callback(self, data):
        rospy.loginfo("callback executed")
        # Map joystick input to robot motion commands
        # Example: Control the end effector position of a robot arm
        if data.axes[0] != 0 or data.axes[1] != 0:
            print(data)
            # Update the target pose based on the joystick input
            self.target_pose.position.x += data.axes[0] * 0.1
            self.target_pose.position.y += data.axes[1] * 0.1

            # Set the target pose for the move group
            self.move_group.set_pose_target(self.target_pose)
            self.move_group.set_planning_time(5)  # Increase the planning time to 5 seconds
            # Plan and execute the motion
            self.move_group.go(wait=True)


if __name__ == '__main__':
    try:
        joystick_teleop = JoystickTeleop()
        rospy.spin()
    except rospy.ROSInterruptException:
        pass

For some reason the robot does not react to the node. I'm getting the following errors:

[ERROR] [1686832400.868134914] [/move_group]: arm/arm: Unable to sample any valid states for goal tree
[ INFO] [1686832400.868209984] [/move_group]: arm/arm: Created 1 states (1 start + 0 goal)
[ INFO] [1686832400.868454296] [/move_group]: No solution found after 5.003464 seconds
[ WARN] [1686832400.868512755] [/move_group]: Timed out
[ INFO] [1686832400.884523583] [/move_group]: Unable to solve the planning problem
[ INFO] [1686832402.538878936] [/move_group]: Combined planning and execution request received for MoveGroup action. Forwarding to planning and execution pipeline.
[ INFO] [1686832402.538982584] [/move_group]: Planning attempt 1 of at most 1

This is from the info from the joystick_teleop.py:
[ INFO] [1686832400.885087394] [/moveit_python_wrappers_1686832320279744835]: ABORTED: TIMED_OUT

@ros-industrial ros-industrial locked and limited conversation to collaborators Jun 15, 2023
@gavanderhoorn gavanderhoorn converted this issue into discussion #555 Jun 15, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Development

No branches or pull requests

1 participant