老师好,想请教您一个问题,我在ROS中将一组xyz坐标上传给机器人,我修改的画圆任务代码,如何控制机器人走完这组坐标的时间呢?
我路点的采样频率是125HZ,10几秒采了1400个点,但是规划后运动时间达到了40多秒,1:4降采样后,虽然提升了速度,但是还是没办法控制机器人走完轨迹的具体时间。我想让机器人在精确时间内走完我的采样轨迹,非常期待回复,万分感谢
data=np.loadtxt("data_handjiang.txt")
x=data[0]
y=data[1]
z=data[2]
class MoveItCircleDemo:
def __init__(self):
moveit_commander.roscpp_initialize(sys.argv)
.
.
.
waypoints = []
arm.go()
waypoints.append(target_pose.pose)
for i in range(0,340,1):
target_pose.pose.position.x = x[i]
target_pose.pose.position.y = y[i]
target_pose.pose.position.z = z[i]
wpose = deepcopy(target_pose.pose)
waypoints.append(deepcopy(wpose))
fraction = 0.0
maxtries = 100
attempts = 0
arm.set_start_state_to_current_state()
rate = rospy.Rate(125)
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.")
moveit_commander.roscpp_shutdown()
moveit_commander.os._exit(0)
if __name__ == "__main__":
try:
MoveItCircleDemo()
except rospy.ROSInterruptException:
pass
第三方账号登入
QQ 微博 微信