紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
ROS运行报错 AttributeError: module 'moveit_commander' has no attribute 'MoveGroupCommander'
-
如题,我使用一个机器人最近从ros melodic升级到noetic后,不知道为什么连示例代码都无法运行,会报错,但是这个机器人是已经支持noetic版本的。
import rospy import moveit_commander import geometry_msgs.msg import rosnode import actionlib from tf.transformations import quaternion_from_euler from control_msgs.msg import (GripperCommandAction, GripperCommandGoal) def main(): rospy.init_node("sciurus17_pick_and_place_controller") robot = moveit_commander.RobotCommander() arm = moveit_commander.MoveGroupCommander("r_arm_waist_group") arm.set_max_velocity_scaling_factor(0.1) gripper = actionlib.SimpleActionClient("/sciurus17/controller1/right_hand_controller/gripper_cmd", GripperCommandAction) gripper.wait_for_server() gripper_goal = GripperCommandGoal() gripper_goal.command.max_effort = 2.0 rospy.sleep(1.0) print("Group names:") print(robot.get_group_names()) print("Current state:") print(robot.get_current_state()) # アーム初期ポーズを表示 arm_initial_pose = arm.get_current_pose().pose print("Arm initial pose:") print(arm_initial_pose) # 何かを掴んでいた時のためにハンドを開く gripper_goal.command.position = 0.9 gripper.send_goal(gripper_goal) gripper.wait_for_result(rospy.Duration(1.0)) # SRDFに定義されている"home"の姿勢にする arm.set_named_target("r_arm_waist_init_pose") arm.go() gripper_goal.command.position = 0.0 gripper.send_goal(gripper_goal) gripper.wait_for_result(rospy.Duration(1.0)) # 掴む準備をする target_pose = geometry_msgs.msg.Pose() target_pose.position.x = 0.25 target_pose.position.y = 0.0 target_pose.position.z = 0.3 q = quaternion_from_euler(3.14/2.0, 0.0, 0.0) # 上方から掴みに行く場合 target_pose.orientation.x = q[0] target_pose.orientation.y = q[1] target_pose.orientation.z = q[2] target_pose.orientation.w = q[3] arm.set_pose_target(target_pose) # 目標ポーズ設定 arm.go() # 実行 # ハンドを開く gripper_goal.command.position = 0.7 gripper.send_goal(gripper_goal) gripper.wait_for_result(rospy.Duration(1.0)) # 掴みに行く target_pose = geometry_msgs.msg.Pose() target_pose.position.x = 0.25 target_pose.position.y = 0.0 target_pose.position.z = 0.13 q = quaternion_from_euler(3.14/2.0, 0.0, 0.0) # 上方から掴みに行く場合 target_pose.orientation.x = q[0] target_pose.orientation.y = q[1] target_pose.orientation.z = q[2] target_pose.orientation.w = q[3] arm.set_pose_target(target_pose) # 目標ポーズ設定 arm.go() # 実行 # ハンドを閉じる gripper_goal.command.position = 0.4 gripper.send_goal(gripper_goal) gripper.wait_for_result(rospy.Duration(1.0)) # 持ち上げる target_pose = geometry_msgs.msg.Pose() target_pose.position.x = 0.25 target_pose.position.y = 0.0 target_pose.position.z = 0.3 q = quaternion_from_euler(3.14/2.0, 0.0, 0.0) # 上方から掴みに行く場合 target_pose.orientation.x = q[0] target_pose.orientation.y = q[1] target_pose.orientation.z = q[2] target_pose.orientation.w = q[3] arm.set_pose_target(target_pose) # 目標ポーズ設定 arm.go() # 実行 # 移動する target_pose = geometry_msgs.msg.Pose() target_pose.position.x = 0.4 target_pose.position.y = 0.0 target_pose.position.z = 0.3 q = quaternion_from_euler(3.14/2.0, 0.0, 0.0) # 上方から掴みに行く場合 target_pose.orientation.x = q[0] target_pose.orientation.y = q[1] target_pose.orientation.z = q[2] target_pose.orientation.w = q[3] arm.set_pose_target(target_pose) # 目標ポーズ設定 arm.go() # 実行 # 下ろす target_pose = geometry_msgs.msg.Pose() target_pose.position.x = 0.4 target_pose.position.y = 0.0 target_pose.position.z = 0.13 q = quaternion_from_euler(3.14/2.0, 0.0, 0.0) # 上方から掴みに行く場合 target_pose.orientation.x = q[0] target_pose.orientation.y = q[1] target_pose.orientation.z = q[2] target_pose.orientation.w = q[3] arm.set_pose_target(target_pose) # 目標ポーズ設定 arm.go() # 実行 # ハンドを開く gripper_goal.command.position = 0.7 gripper.send_goal(gripper_goal) gripper.wait_for_result(rospy.Duration(1.0)) # 少しだけハンドを持ち上げる target_pose = geometry_msgs.msg.Pose() target_pose.position.x = 0.4 target_pose.position.y = 0.0 target_pose.position.z = 0.2 q = quaternion_from_euler(3.14/2.0, 0.0, 0.0) # 上方から掴みに行く場合 target_pose.orientation.x = q[0] target_pose.orientation.y = q[1] target_pose.orientation.z = q[2] target_pose.orientation.w = q[3] arm.set_pose_target(target_pose) # 目標ポーズ設定 arm.go() # 実行 # SRDFに定義されている"home"の姿勢にする arm.set_named_target("r_arm_waist_init_pose") arm.go() print("done") if __name__ == '__main__': try: if not rospy.is_shutdown(): main() except rospy.ROSInterruptException: pass