Difference between revisions of "Capstone Dev"

From Mech
Jump to navigationJump to search
(Replaced content with "See Mobile Manipulation Capstone.")
 
(120 intermediate revisions by the same user not shown)
Line 1: Line 1:
See [[Mobile Manipulation Capstone]].
[[image:youbot-capstone.png|right|x250px]]

This page describes the Capstone Project for the Coursera "Modern Robotics" Specialization. This project forms the sixth and final course of the Specialization: "Modern Robotics, Course 6: Capstone Project, Mobile Manipulation." This project draws on pieces of Courses 1 to 5.

[https://youtu.be/Q1CekpBW6Js '''A video summary of this project is given in this YouTube video'''].

Depending on your experience with programming, this project should take approximately 20 hours, broken down into three intermediate milestones and your final submission.

You should use the Modern Robotics code library to help you complete this project.

=== Introduction ===

In your capstone project, you will write software that plans a trajectory for the youBot mobile manipulator (a mobile base with four mecanum wheels and a 5R robot arm), performs odometry as the chassis moves, and performs feedback control as the youBot picks up a block at a specified location, carries it to a desired location, and puts it down.

The final output of your software will be a comma separated values (csv) text file that specifies the configurations of the chassis and the arm, the angles of the four wheels, and the state of the gripper (open or closed) as a function of time. This specification of the position-controlled youBot will then be "played" on the V-REP simulator to see if your trajectory succeeds in solving the task.

[[V-REP_Introduction#Scene_6:_CSV_Mobile_Manipulation_youBot|'''This project uses the CSV Mobile Manipulation youBot scene''']]. You should download it and test it with the sample csv file, to see what a solution looks like.

Unlike previous projects, where we used V-REP to simply visualize the robot's motion, in this project V-REP will use a physics simulator to simulate the interaction of the youBot with the block. In other words, if the gripper closes on the block in the wrong position or orientation, the block may simply slide out of the grasp.

The V-REP scene drives the chassis configuration according to the sequence of chassis configurations in your csv file. For the robot arm, simulated high-gain controllers at the arm joints cause the arm to closely follow the configurations in your csv file.

The interaction between the robot and the block is governed by a physics simulator, often called a "physics engine," which approximately accounts for friction, mass, inertial, and other properties. V-REP has different physics engines which you can select, including Bullet and ODE.

The time between each successive configuration in your csv file is 0.01 seconds (10 milliseconds). A typical line of your csv file would be something like

-0.75959, -0.47352, 0.058167, 0.80405, -0.91639, -0.011436, 0.054333, 0.00535, 1.506, -1.3338, 1.5582, 1.6136, 0

i.e., thirteen values separated by commas, representing

chassis phi, chassis x, chassis y, J1, J2, J3, J4, J5, W1, W2, W3, W4, gripper state

where J1 to J5 are the arm joint angles and W1 to W4 are the four wheel angles.

[[image:youbot-top-view.png|right|x150px]]

Wheels 1 to 4 are numbered as shown in the image to the right. The ten angles (phi for the chassis, five arm joint angles, and four wheel angles) are in radians and the two chassis position coordinates (x,y) are in meters. A gripper state of 0 indicates that you want the gripper to be open, and a gripper state of 1 indicates that you want the gripper to be closed. In practice, the transition from open to closed (or from closed to open) takes up to one second, so any transition from 0 to 1, or 1 to 0, in your csv file will take some time to complete.

Your software will take as input:
* the initial resting configuration of the cube object (which has a known geometry), represented by a frame attached to the center of the object
* the desired final resting configuration of the cube object
* the actual initial configuration of the youBot
* the reference initial configuration of the youBot (which will be different from the actual initial configuration, to allow you to test feedback control)

The output of your software will be a single csv file which, when "played" through the V-REP scene, should successfully pick up the block and put it down at the desired location.

Your solution must employ automated planning and control techniques from this Coursera specialization. It should not simply be a manually coded trajectory of the robot. Your solution should automatically go from the input to the output, with no other human intervention. In other words, it should automatically produce a working csv file even if the input conditions are changed.

In your software, you should first piece together a reference trajectory for the gripper of the robot, which the robot is then controlled to follow. A typical reference trajectory would consist of the following segments:

# A trajectory to move the gripper from its initial configuration to a "standoff" configuration a few cm above the block.
# A trajectory to move the gripper down to the grasp position.
# Closing of the gripper.
# A trajectory to move the gripper back up to the "standoff" configuration.
# A trajectory to move the gripper to a "standoff" configuration above the final configuration.
# A trajectory to move the gripper to the final configuration of the object.
# Opening of the gripper.
# A trajectory to move the gripper back to the "standoff" configuration.

Segments 3 and 7 each keep the end-effector fixed in space but, at the beginning of the segment, change the state of the gripper from 0 to 1 or 1 to 0, waiting one second for the gripper closing to complete. In other words, each of these segments would consist of 100 identical lines of the csv file (corresponding to one second), where the first line has a gripper state different from the previous line in the csv file, to initiate the opening or closing.
Segments 2, 4, 6, and 8 are simple up or down translations of the gripper of a fixed distance. Good trajectory segments would be cubic or quintic polynomials taking a reasonable amount of time (e.g., one second).

Trajectory segments 1 and 5 are longer motions requiring motion of the chassis. Segment 1 is calculated from the desired initial configuration of the gripper to the standoff configuration, and segment 5 is calculated from the first standoff configuration to the second standoff configuration. The gripper trajectories could correspond to constant screw motion paths or decoupled Cartesian straight-line motion plus rotational motion, time scaled by third-order polynomials (Chapter 9).

Once the entire gripper reference trajectory has been pieced together from the 8 segments, the actual trajectory of the youBot is obtained by using a Jacobian pseudoinverse position controller as described in Chapter 13.5. Starting from the actual initial robot configuration (which has some error from the beginning of reference segment 1), your controller drives the gripper to follow segment 1, so that the gripper is at the standoff configuration for the beginning of segment 2. Your feedback controller should eliminate initial error before the gripper attempts to grasp the block, to avoid failure.

You are welcome to adopt a different approach to solving the pick-and-place problem, provided your approach takes the same inputs specified above, produces a csv file that successfully achieves the task, and is fully automatic (i.e., it works for different initial and final configurations of the block, different initial and reference configurations for the youBot, and requires no human intervention).

To simulate the effect of feedback control, you must write your own motion simulator. For each timestep, you take the initial configuration of the robot and the wheel and joint speeds calculated by your controller and numerically integrate the effect of these speeds over a timestep to get the new robot configuration. To calculate the new configuration of the chassis due to the wheel motions, you must implement an odometry step (Chapter 13.4).

=== Kinematics of the youBot ===

The images to the right illustrate the youBot. Click on them to make them bigger. The description below is consistent with Exercise 13.33 from the book, if you prefer to see the information there. All distances are in meters and all angles are in radians.

[[image:Yb-book.png|right|300px|thumb|This figure illustrates the arm at its home configuration (all joint angles zero) and the frames {s}, {b}, {0}, and {e}. Joint axes 1 and 5 (not shown) point upward and joint axes 2, 3, and 4 are out of the screen. Click to make the image bigger.]]

[[image:Yb-base-capstone.png|right|300px|thumb|The forward-backward distance between the wheels is <math>2l = 0.47</math> meters and the side-to-side distance between wheels is <math>2w = 0.3</math> meters. The radius of each wheel is <math>r = 0.0475</math> meters. The forward driving and "free sliding" direction <math>\gamma</math> of each wheel is indicated.]]

[[image:Youbot-gripper.png|right|300px|thumb|The gripper and the end-effector frame {e}, which has an origin midway between the fingers of the gripper. The minimum opening distance of the gripper is <math>d_{1,\text{min}} = 2</math> cm, the maximum opening distance is <math>d_{1,\text{max}} = 7</math> cm, the interior length of the fingers is <math>d_{2} = 3.5</math> cm, and the distance from the base of the fingers to the frame {e} is <math>d_{3} = 4.3</math> cm. The axis <math>\hat{\text{x}}_{\text{e}}</math> is into the screen.]]

[[image:Block-capstone.png|right|300px|thumb|The object being manipulated is a cube, 5 cm x 5 cm x 5 cm. The cube's frame is at its center, and the axes are aligned with the edges of the cube.]]

The configuration of the frame {b} of the mobile base, relative to the frame {s} on the floor, is described by the 3-vector <math>q = (\phi,x,y)</math> or the <math>SE(3)</math> matrix

<math> T_{sb}(q) = \left[\begin{array}{cccc} \cos \phi & -\sin \phi & 0 & x \\ \sin \phi & \cos \phi & 0 & y \\ 0 & 0 & 1 & 0.0963 \\ 0 & 0 & 0 & 1 \end{array}\right]</math>

where <math>z = 0.0963</math> meters is the height of the {b} frame above the floor. The forward-backward distance between the wheels is <math>2l = 0.47</math> meters and the side-to-side distance between wheels is <math>2w = 0.3</math> meters. The radius of each wheel is <math>r = 0.0475</math> meters. The forward driving and "free sliding" direction <math>\gamma</math> of each wheel is indicated in the figures.

The fixed offset from the chassis frame {b} to the base frame of the arm {0} is

<math> T_{b0}= \left[\begin{array}{cccc} 1 & 0 & 0 & 0.1662 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0.0026 \\ 0 & 0 & 0 & 1 \end{array}\right].</math>

When the arm is at its home configuration (all joint angles zero, as shown in the figure), the end-effector frame {e} relative to the arm base frame {0} is

<math> M_{0e}= \left[\begin{array}{cccc} 1 & 0 & 0 & 0.033 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0.6546 \\ 0 & 0 & 0 & 1 \end{array}\right].</math>

When the arm is at its home configuration, the screw axes <math>\mathcal{B}</math> for the five joints are expressed in the end-effector frame {e} as
# <math>\omega_1 = (0,0,1), \; v_1 = (0,0.033,0)</math>
# <math>\omega_2 = (0,-1,0), \; v_2 = (-0.5076,0,0)</math>
# <math>\omega_3 = (0,-1,0), \; v_3 = (-0.3526,0,0)</math>
# <math>\omega_4 = (0,-1,0), \; v_4 = (-0.2176,0,0)</math>
# <math>\omega_5 = (0,0,1), \; v_5 = (0,0,0)</math>

In this project, for simplicity '''we assume no joint limits on the five joints of the robot arm.''' It is recommended, however, that you choose limits on the wheel and joint velocities. We will come back to this issue later.

The end-effector frame {e} is rigidly attached to the last link and is midway between the tips of the gripper fingers. The minimum opening distance of the gripper is <math>d_{1,\text{min}} = 2</math> cm, the maximum opening distance is <math>d_{1,\text{max}} = 7</math> cm, the interior length of the fingers is <math>d_{2} = 3.5</math> cm, and the distance from the base of the fingers to the frame {e} is <math>d_{3} = 4.3</math> cm. When the gripper closes, it closes until it reaches its minimum closing distance or encounters a force large enough to prevent further closing.

The object being manipulated is a cube, 5 cm x 5 cm x 5 cm. The cube's frame {c} is at the center of the cube, and the axes are aligned with the edges of the cube. The initial configuration of the cube is at (x, y, z) = (1, 0, 0.025 ) m in the space frame {s}, and the axes of {c} are aligned with {s}. The desired final configuration of the cube is at (x, y, z) = (0, 1, 0.025) m and the axes of {c} are rotated by <math>-\pi/2</math> about the <math>\hat{\text{z}}_{\text{s}}</math> axis of {s}. A good choice for the "standoff" configuration before moving down to the cube and moving back up (the ends of trajectories 1, 4, 5, and 8) is to have the {e} frame a few cm above the {c} frame.

<br clear=all>

=== What You Will Do ===

Your solution to this project will be a fairly complex piece of software. To help structure the project, and to allow you to test individual pieces of your solution, the project has three milestones before you finally complete the project. You do not turn in your solutions to these milestone subprojects; you only turn in your final project.



Then more details on milestones, and the actual geometry, configurations, initial and final conditions, etc., for the demonstrator.

=== Milestone 1: youBot Kinematics Simulator and csv Output ===

You will write a simulator for the kinematics of the youBot. The main function in the simulator, let's call it <tt>NextState</tt>, is specified by the following inputs and outputs:

'''Input:'''
* A 12-vector representing the current configuration of the robot (3 variables for the chassis configuration, 5 variables for the arm configuration, and 4 variables for the wheel angles).
* A 9-vector of controls indicating the arm joint speeds <math>\dot{\theta}</math>(5 variables) and the wheel speeds <math>u</math> (4 variables).
* A timestep <math>\Delta t</math>.
* A positive real value indicating the maximum angular speed of the arm joints and the wheels. For example, if this value is 12.3, the angular speed of the wheels and arm joints is limited to the range [-12.3 radians/s, 12.3 radians/s]. Any speed in the 9-vector of controls that is outside this range will be set to the nearest boundary of the range. If you don't want speed limits, just use a very large number. If you prefer, your function can accept separate speed limits for the wheels and arm joints.

'''Output:'''
* A 12-vector representing the configuration of the robot time <math>\Delta t</math> later.

The function <tt>NextState</tt> is based on a simple first-order Euler step, i.e.,
* new arm joint angles = (old arm joint angles) + (joint speeds) * <math> \Delta t</math>
* new wheel angles = (old wheel angles) + (wheel speeds) * <math>\Delta t</math>
* new chassis configuration is obtained from odometry, as described in Chapter 13.4

To test your <tt>NextState</tt> function, you should put it inside a loop that simulates constant controls for one second. For example, you can set <math>Delta t</math> to 0.01 seconds and run a loop that calls <tt>NextState</tt> 100 times with the constant controls <math>(u,\dot{\theta})</math>. Your program should write a csv file, where each line has 13 values separated by commas (the 12-vector consisting of 3 chassis configuration variables, the 5 arm joint angles, and the 4 wheel angles, plus a "0" for "gripper open") representing the robot's configuration after each integration step. Then you should load the csv file into the CSV Mobile Manipulation youBot V-REP scene and watch the animation of the constant controls to see if your <tt>NextState</tt> function is working properly (and to check your ability to produce a csv file).

'''Sample controls to try:''' Simulate the following controls for 1 second and watch the results in the V-REP scene.
# <math>u = (10,10,10,10)</math>. The robot chassis should drive forward (in the <math>+\hat{\text{x}}_{\text{b}}</math> direction by 0.475 meters.
# <math>u = (-10,10,-10,10)</math>. The robot chassis should slide in the <math>+\hat{\text{y}}_{\text{b}}</math> direction by 0.475 meters.
# <math>u = (-10,10,10,-10)</math>. The robot chassis should spin counterclockwise in place by <math>1.234</math> radians.

If the chassis motion is not what is described, then something is wrong with your implementation of odometry. You should also check that your wheel angles and arm joint angles are being updated properly, but this should be easy.

You should also try specifying a speed limit of 5 for the joints and wheels, then try the same tests above. Since your commanded controls exceed the speed limit, your function should properly restrict the actual speeds executed by the wheels and joints to the range [-5, 5]. As a result, the chassis should only move half the distance in these tests.

=== Milestone 2: Reference Trajectory Generation ===

For this milestone you will write a function <tt>TrajectoryGenerator</tt> to generate the reference trajectory for the end-effector frame {e}. This trajectory consists of eight concatenated trajectory segments, as described above.

'''Input:'''
* The end-effector's initial configuration: <math>T_{se,\text{initial}}</math>.
* The cube's initial configuration: <math>T_{sc,\text{initial}}</math>.
* The cube's desired final configuration: <math>T_{sc,\text{final}}</math>.
* The standoff configuration above the cube, before and after grasping, relative to the cube: <math>T_{ce,\text{standoff}}</math>. This specifies the configuration of the end-effector {e} relative to the cube frame {c} before lowering to grasp, for example. If you would like to specify the standoff configuration in a different way, you are welcome to.
* The number of trajectory reference points per 0.01 seconds: <math>k</math>. The value <math>k</math> is an integer with a value of 1 or greater. Although your final animation will be based on snapshots separated by 0.01 seconds in time, the points of your reference trajectory, and your controller servo cycle, may be at higher frequencies. It is fine to choose <math>k=1</math> if you'd like to keep things simple.

'''Output:'''
* An <math>N \times 9</math> matrix. <math>N</math> is the number of reference points in the entire concatenated eight-segment reference trajectory. Each of the <math>N</math> rows represents a configuration of the end-effector frame {e} relative to {s} at that instant in time. The nine entries of the row represent the top three rows of the transformation matrix <math>T_{se}</math> at that instant of time, i.e.,

<math> T_{se} = \left[\begin{array}{cccc} r_{11} & r_{12} & r_{13} & p_x \\ r_{21} & r_{22} & r_{23} & p_y \\ r_{31} & r_{32} & r_{33} & p_z \\ 0 & 0 & 0 & 1 \end{array}\right]. </math>

* A csv file with the entire eight-segment reference trajectory. Each line of the csv file corresponds to one configuration <math>T_{se}</math> of the end-effector, expressed as nine variables separated by commas. The nine variables are, in order

r11, r12, r13, r21, r22, r23, r31, r32, r33, px, py, pz

It is up to you to determine how long each trajectory segment should take, but it is recommended that each segment's duration be an integer multiple of 0.01 seconds. You could automatically choose the duration of each trajectory segment equal to the distance the origin of the {e} frame has to travel divided by some reasonable maximum linear velocity of the end-effector. The times should not be so short so as to require unreasonable joint and wheel speeds.

Your <tt>TrajectoryGenerator</tt> function is likely to use either <tt>ScrewTrajectory</tt> or <tt>CartesianTrajectory</tt>, from the Modern Robotics code library, to generate the individual segments.

'''Testing your function:''' We have created a V-REP scene to help you test your <tt>TrajectoryGenerator</tt> function. This scene reads in your csv file and animates it, showing how the end-effector frame moves as a function of time. You should verify that your <tt>TrajectoryGenerator</tt> works as you expect before moving on with the project.

=== Milestone 3: Feedforward Control ===

Now that you are able to simulate the motion of the robot and generate a reference trajectory for the end-effector, you are ready to begin experimenting with feedback control of the mobile manipulator. You will write the function <tt>FeedbackControl</tt> to calculate the kinematic task-space feedforward plus feedback control law, written both as Equation (11.16) and (13.37) in the textbook:

<math>
\mathcal{V}(t) = [\text{Ad}_{X^{-1} X_d}] \mathcal{V}_d(t) + K_p X_{\text{err}}(t) + K_i \int_0^t X_{\text{err}}(\text{t}) d\text{t}.
</math>

'''Input:'''
* The current end-effector reference configuration <math>X_{d,\text{current}}</math>.
* The end-effector reference configuration at the next timestep in the reference trajectory, <math>X_d</math>.
* The current actual end-effector configuration <math>X</math> (also written <math>T_{se}</math>).
* The PI gain matrices <math>K_p</math> and <math>K_i</math>.
* The timestep <math>\delta t</math> between reference trajectory configurations.

'''Output:'''
* The commanded end-effector twist <math>\mathcal{V}</math> expressed in the end-effector frame {e}.

To calculate the control law <tt>FeedbackControl</tt>, you calculate the twist <math>X_{\text{err}}</math> that takes <math>X</math> to <math>X_{d,\text{current}}</math> in unit time

The output of <tt>FeedbackControl</tt> is the




control can happen at a higher frequency than reference, and simulation

=== Completed Project and Your Submission ===


'''What to turn in:''' some more text
# stuff 1
# stuff 2
etc.

'''Project grading.'''

Latest revision as of 14:37, 18 June 2018