All actuation-related files are handled in the move_gun package. The main programs for the static target actuation are move_arm.py and shoot.py.
Before any actuation can be done, several nodes and launch files need to be run. We wrote a custom launch file, moveit.launch with the following files:
First, we listen for the transform between the robot base (/base) and the target position (/target_new). Based on the (X, Y, Z) position of the target, we set the gripper position to be (0.5, Y, Z), which can be visualized by the diagram below. The desired orientation is always fixed so that the gun fires perpendicularly to the robot.
Robot base is represented by the black axes, target position by the red axes, and desired gripper position by the blue axes
if the target cannot be reached by the robot in the y direction, then the gripper moves to the position (0.5, +/-0.15, Z) and rotates to point towards the target position. This can be visualized by the diagram below.
Robot base is represented by the black axes, target position by the red axes, and desired gripper position by the blue axes
To actually move the arm, we use the PathPlanner
class from lab 7 to simplify things. Given a desired position and orientation of the gripper, as described above, the planner object plans the path. If a path is found, then the planner executes the plan. Sometimes, even when the gripper moves to the desired position, the execution "fails", so we loop until the execution succeeds.
When using the gripper, we set the holding force and velocity of the gripper to its maximum setting, to ensure there is enough force to pull the trigger. When the gun needs to shoot, the gripper opens slightly before closing to ensure enough force can be applied. Finally, the gripper opens a bit to allow the gun to be reloaded without the trigger being immediately pulled.