Move Arm to Wait Position¶
MoveIt!’s
moveit_cpp
API allows us to move the robot in various ways. With aPlanningComponent
object, it is possible to create motion plans to move to a desired joint position, Cartesian goal or a predefined pose created with the Setup Assistant. Then we can use aMoveItCpp
object to execute that plan. In this exercise, we will move the robot to a predefined joint pose.
Locate Function¶
In the main program, locate the method call to
application.moveToWaitPosition()
.Go to the source file of that function by clicking in any part of the function and pressing F2 in QtCreator.
Alternatively, browse to the file at
[workspace source directory]/pick_and_place_application/src/tasks/move_to_wait_position.cpp
Remove the first line containing the following
RCLCPP_ERROR ...
so that the program runs.
Complete Code¶
Find every line that begins with the comment
Fill Code:
and read the description. Then, replace every instance of the commentUNCOMMENT AND COMPLETE
with the appropriate line of code./* Fill Code: . . . */ /* UNCOMMENT AND COMPLETE: ... */
The name of the predefined “wait” pose was saved in the global variable
cfg.WAIT_POSE_NAME
during initialization.Calling plan() provides a solution trajectory stored in a
PlanSolution
objectThe execute() method sends a motion plan to the robot.
Build Code and Run¶
Compile the pick and place node:
In QTCreator:
Alternatively, in a terminal:
cd ~/perception_driven_ws colcon build
In a terminal, launch the supporting nodes:
source ~/perception_driven_ws/install/setup.bash ros2 launch pick_and_place_application application_setup.launch.py
In another terminal, launch the application node:
source ~/perception_driven_ws/install/setup.bash ros2 launch pick_and_place_application application_run.launch.py
If the robot is not already in the wait position, it should move to it.
In the terminal, you should see something like this:
[INFO] [1400553673.460328538] [pick_and_place_node]: Move wait Succeeded
[ERROR] [1400553673.460434627] [pick_and_place_node]: actuateGripper is not implemented yet. Aborting.