[英]Spawn and control second arm using OpenManipulator and MoveIt
[英]how to move ur5 robot using the moveit interface?
我目前正在研究 ROS,我的問題是:使用 moveit 界面移動 ur5 機器人的鋤頭? 我編寫了一個代碼,應該讓機器人執行一個簡單的運動:在運行代碼之前,我啟動了 Gazebo 和 Rviz。
#!/usr/bin/env python3
import sys
import copy
import rospy
import moveit_commander
import moveit_msgs.msg
import geometry_msgs.msg
class MoveRobotNode():
"""MoveRobotNode"""
def __init__(self):
moveit_commander.roscpp_initialize(sys.argv)
rospy.init_node("move_robot_node", anonymous=True)
robot = moveit_commander.RobotCommander()
scene = moveit_commander.PlanningSceneInterface()
group_name = "manipulator"
move_group = moveit_commander.MoveGroupCommander(group_name)
def go_to_joint_state(self):
move_group = self.move_group
joint_goal = move_group.get_current_joint_values()
joint_goal[0] = 0
joint_goal[1] = -tau / 8
joint_goal[2] = 0
joint_goal[3] = -tau / 4
joint_goal[4] = 0
joint_goal[5] = tau / 6 # 1/6 of a turn
joint_goal[6] = 0
move_group.go(joint_goal, wait=True)
move_group.stop()
if __name__ == "__main__":
robot_control = MoveRobotNode()
robot_control.go_to_joint_state()
但是當我運行代碼時,我得到了這個錯誤:
maha@ms21:~/catkin_ws/src/move_robot_pkg$ python3 move_robot_node.py
[ INFO] [1662122291.175640005, 1575.932000000]: Loading robot model 'ur5'...
[ WARN] [1662122291.229793210, 1575.986000000]: Kinematics solver doesn't support #attempts anymore, but only a timeout.
Please remove the parameter '/robot_description_kinematics/manipulator/kinematics_solver_attempts' from your configuration.
[ INFO] [1662122292.257776819, 1577.012000000]: Ready to take commands for planning group manipulator.
Traceback (most recent call last):
File "move_robot_node.py", line 47, in <module>
robot_control.go_to_joint_state()
File "move_robot_node.py", line 30, in go_to_joint_state
move_group = self.move_group
AttributeError: 'MoveRobotNode' object has no attribute 'move_group'
在您的__init__
function 中,您將move_group
分配給局部變量而不是class 屬性; 因此,當您嘗試獲取 function 之外的值時,它不可用。 相反,您應該將其分配給self
,如下所示:
self.move_group = moveit_commander.MoveGroupCommander(group_name)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.