Skip to content
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

Unable to connect to move_group action server 'move_group' within allotted time (5s) #277

Open
mf093087 opened this issue Jan 18, 2022 · 0 comments

Comments

@mf093087
Copy link

I use a python script to control the iiwa robot. However, when I run the python code, I receive this error.
image

#!/usr/bin/env python

-- coding: utf-8 --

import rospy, sys
import moveit_commander
from moveit_commander import MoveGroupCommander
from geometry_msgs.msg import Pose
from copy import deepcopy

class MoveItCartesianDemo:
def init(self):

    moveit_commander.roscpp_initialize(sys.argv)


    rospy.init_node('moveit_cartesian_demo', anonymous=True)


    arm = MoveGroupCommander('manipulator')


    arm.allow_replanning(True)


    arm.set_pose_reference_frame('iiwa_link_0')


    arm.set_goal_position_tolerance(0.001)
    arm.set_goal_orientation_tolerance(0.001)


    arm.set_max_acceleration_scaling_factor(0.5)
    arm.set_max_velocity_scaling_factor(0.5)


    end_effector_link = arm.get_end_effector_link()


    start_pose = arm.get_current_pose(end_effector_link).pose


    waypoints = []



    waypoints.append(start_pose)


    wpose = deepcopy(start_pose)
    wpose.position.z -= 0.2
    waypoints.append(deepcopy(wpose))

    wpose.position.x += 0.1
    waypoints.append(deepcopy(wpose))

    wpose.position.y += 0.075
    waypoints.append(deepcopy(wpose))

    wpose.position.y -= 0.075
    waypoints.append(deepcopy(wpose))

    wpose.position.x -= 0.1
    waypoints.append(deepcopy(wpose))

    wpose.position.x += 0.05
    wpose.position.y += 0.075
    waypoints.append(deepcopy(wpose))

    wpose.position.y -= 0.15
    waypoints.append(deepcopy(wpose))

    wpose.position.x -= 0.05
    wpose.position.y += 0.075
    waypoints.append(deepcopy(wpose))

    wpose.position.x -= 0.03
    wpose.position.y -= 0.075
    waypoints.append(deepcopy(wpose))

    fraction = 0.0  
    maxtries = 100 
    attempts = 0 


    arm.set_start_state_to_current_state()

   
    while fraction < 1.0 and attempts < maxtries:
        (plan, fraction) = arm.compute_cartesian_path(
            waypoints, 
            0.01,  
            0.0,  
            True)  


    attempts += 1


    if attempts % 10 == 0:
        rospy.loginfo("Still trying after " + str(attempts) + " attempts...")


    if fraction == 1.0:
        rospy.loginfo("Path computed successfully. Moving the arm.")
        arm.execute(plan)
        rospy.loginfo("Path execution complete.")

    else:
        rospy.loginfo(
            "Path planning failed with only " + str(fraction) + " success after " + str(maxtries) + " attempts.")

        rospy.sleep(1)


    moveit_commander.roscpp_shutdown()
    moveit_commander.os._exit(0)

if name == "main":
try:
MoveItCartesianDemo()
except rospy.ROSInterruptException:
pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant