ros-industrial / motoman

ROS-Industrial Motoman support (http://wiki.ros.org/motoman)
143 stars 194 forks source link

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

Closed tall1 closed 1 year ago

tall1 commented 1 year ago

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 ```python #!/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