Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
wiki:tutorials:single-arm-joint-move-python [2019/09/20 07:49]
simon [Running The Code]
wiki:tutorials:single-arm-joint-move-python [2019/09/20 07:55] (current)
simon [The Code Explained]
Line 69: Line 69:
 =====The Code Explained===== =====The Code Explained=====
 <code python> <code python>
-def joint_space_client():+def execute_joint_goal():
     # Creates the SimpleActionClient,​ passing the type of the action     # Creates the SimpleActionClient,​ passing the type of the action
     # (MoveAction) to the constructor.     # (MoveAction) to the constructor.
-    client = actionlib.SimpleActionClient("/​qp_controller/​command",​ MoveAction)+    client = actionlib.SimpleActionClient("/​giskardpy/​command",​ MoveAction)
  
     # Waits until the action server has started up and started     # Waits until the action server has started up and started
     # listening for goals.     # listening for goals.
 +    print('​waiting for giskard'​)
     client.wait_for_server()     client.wait_for_server()
 +    print('​connected to giskard'​)
 </​code>​ </​code>​
-First, we create a simple action client and wait for the actionserver. The server listens for MoveActions on the ///qp_controller/command// topic.+First, we create a simple action client and wait for the actionserver. The server listens for MoveActions on the ///giskardpy/command// topic.
  
 <code python> <code python>
 +# Creates a goal to send to the action server.
 +    action_goal = MoveGoal()
 +    action_goal.type = MoveGoal.PLAN_AND_EXECUTE
  
-    ​# Creates a goal to send to the action server. +    goal = MoveCmd()
-    ​goal = MoveGoal() +
-    movecommand ​= MoveCmd() +
-    controller = Controller()+
  
-    ​goal.type ​MoveGoal.PLAN_AND_EXECUTE+    ​joint_goal ​JointConstraint()
  
-    ​controller.type = Controller.JOINT +    ​joint_goal.type = JointConstraint.JOINT 
-    ​controller.root_link = "​torso_lift_link"​ +    ​# this can be any subset of the robots joints 
-    controller.tip_link = "​l_gripper_tool_frame"​ +    ​joint_goal.goal_state.name = ["​l_upper_arm_roll_joint",​ "​l_shoulder_pan_joint",​ "​l_shoulder_lift_joint",​ 
-    controller.p_gain = 1 +                                  ​"​l_forearm_roll_joint",​ "​l_elbow_flex_joint",​ "​l_wrist_flex_joint",​ 
-    controller.weight = 1 +                                  ​"​l_wrist_roll_joint"​] 
-    controller.goal_pose.header.frame_id = "​base_link"​ +    ​joint_goal.goal_state.position = [1, 0.5, 0.2, 0, -0.8, -1, 0] 
-    ​controller.goal_state.name = ["​l_upper_arm_roll_joint", ​ "​l_shoulder_pan_joint",​ "​l_shoulder_lift_joint",​ "​l_forearm_roll_joint",​ "​l_elbow_flex_joint",​ "​l_wrist_flex_joint",​ "​l_wrist_roll_joint"​] ​  ​ + 
-    ​controller.goal_state.position = [1, 0.5, 0.2, 0, -0.8, -1, 0] +    ​goal.joint_constraints.append(joint_goal
-  +    ​action_goal.cmd_seq.append(goal)
-    ​movecommand.controllers.append(controller+
-    ​goal.cmd_seq.append(movecommand)+
  
     # Sends the goal to the action server.     # Sends the goal to the action server.
-    client.send_goal(goal)+    client.send_goal(action_goal)
  
     # Waits for the server to finish performing the action.     # Waits for the server to finish performing the action.
     client.wait_for_result()     client.wait_for_result()
  
-    ​return ​client.get_result()+    ​result = client.get_result() #type: MoveResult 
 +    if result.error_code == MoveResult.SUCCESS:​ 
 +        print('​giskard returned success'​) 
 +    else: 
 +        print('​something went wrong')
 </​code>​ </​code>​
-A MoveAction contains a list of MoveCommands ​which are executed sequentially. Each Movecommand ​contains a list of Controllers and each controller defines different movement ​goals for the robot. For example there could be a controller ​that sets a position goal for a certain link of the robot while another ​controller ​sets the goal joint position of a certain joint. Giskard tries to achieve ​every movement goal in a Movecommand ​at the same time. In this case we only have one movement goal that sets joint goal positions for various joints ​of the robot.+A MoveAction contains a list of MoveCmds ​which are executed sequentially. Each MoveCmd ​contains a list of goals, which affect ​the robot motion. For example there could be a goal that sets a position goal for a certain link of the robot while another ​goal sets the goal joint position of a certain joint. Giskard tries to achieve ​all goals at once, more on that later. In this case we only have one movement goal that sets goal positions for a subset ​of the robots joints.
  
 =====Running The Code===== =====Running The Code=====