Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Computational Mechanics Project #02 - Create specifications for a projectile robot\n",
"\n",
"On the first day of class, we threw $2\"\\times~2\"$ dampened paper (spitballs) at a target on the whiteboard. Now, we are going to analyze the accuracy of the class with some cool Python tools and design a robot that has the same accuracy and precision as the class, but we will have the robot move farther away from the target and use a simpler projectile i.e. a tennis ball so we don't need to worry about knuckle-ball physics. \n",
"\n",
"The goal of this project is to determine the precision of necessary components for a robot that can reproduce the class throwing distibution. We have generated pseudo random numbers using `numpy.random`, but the class target practice is an example of truly random distributions. If we repeated the exercise, there is a vanishingly small probability that we would hit the same points on the target, and there are no deterministic models that could take into account all of the factors that affected each hit on the board. \n",
"\n",
"<img src=\"../images/robot_design.png\" style=\"height: 250px;\"/>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, we ask ourselves some questions:\n",
"\n",
"1. How do we quantify the class accuracy and precision?\n",
"\n",
"2. If we design a robot, what design components can we control?\n",
"\n",
"3. How can we relate the controlled components to the class accuracy, and specify the component precision?\n",
"\n",
"The first question, we have some experience from our work in [02_Seeing_Stats](../notebooks/02_Seeing_Stats.ipynb). We can define the mean, standard deviation, measure the first, second, and third quartiles, etc. \n",
"\n",
"The second question is a physical question. We cannot control the placement of the robot or the target those are chosen for us. We cannot control temperature, mechanical vibrations, etc. We *can* control the desired initial velocity. The initial velocity will have some speed and direction, and both will be subject to random noise. Once the speed and direction are set, the location on the target is determined by kinematic equations for an object in freefall, as such\n",
"\n",
"$x_{impact} = \\frac{v_x}{v_y}d + x(0)~~~~~~~~~~~~~~~~~~~~(1.a)$\n",
"\n",
"$z_{impact} = d\\left(\\frac{v_z(0)}{v_y}-\\frac{g}{2v_y^2}d\\right)+ z(0)~~~~~(1.b)$.\n",
"\n",
"Where the location of impact is at a $y$-distance of $d$ at a point on the target with coordinates $(x_{impact},~z_{impact})$, and the initial velocity is $\\bar{v}=v_x\\hat{i}+v_y\\hat{j}+v_z(0)\\hat{k}$, the object is released at an initial location $\\bar{r}(0)=x(0)\\hat{i}+0\\hat{j}+z(0)\\hat{k}$, and the only acceleration is due to gravity, $\\bar{a}=-g\\hat{k}$. Equation (1) becomes much easier to evaluate if we assume that $v_x=0$, resulting in an evalution of the accuracy of the height of the impact, $z_{impact}$, as such\n",
"\n",
"$x_{impact} = x(0)~~~~~~~~~~~~~~~~~~~~(2.a)$\n",
"\n",
"$z_{impact} = \\frac{d}{\\cos{\\theta}}\\left(\\sin{\\theta}-\\frac{g}{2v_0^2\\cos{\\theta}}d\\right)+ z(0)~~~~~(2.b)$.\n",
"\n",
"Where $\\theta$ is the angle of the initial velocity and $v_0$ is the initial speed. Equation (2) restricts the analysis to height accuracy. You can incorporate the 2D impact analysis if you finish the 1D analysis. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The third question, is how we can relate equation (2) to the measured points of impact? For this, we can use Monte Carlo methods *(There are other methods, but Monte Carlo is one of the most straight-forward)*. Our Monte Carlo approach is as such, if we have a desired initial speed, $v_0$, and desired angle, $\\theta$, we can propagate the uncertainty of our actual speeds and angles into the $z_{impact}$ locations. Then, we can choose distributions in speed and angles that match the distributions in $z_{impact}$ locations. Here are the steps:\n",
"\n",
"1. Generate random $\\theta_i$ and $v_{0~i}$ variables\n",
"\n",
"2. Plug into eqn 2 for random $z_{impact~i}$ locations\n",
"\n",
"3. Compare to our measured $z_{impact}$ location statistics\n",
"\n",
"4. Repeat 1-3 until the predicted uncertainty matches the desired uncertainty, we can use a number of comparison metrics:\n",
" \n",
" - standard deviation\n",
" \n",
" - first, second, and third quartiles\n",
" \n",
" - visually, with box plots and histograms"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Project Deliverables\n",
"\n",
"1. Statistical analysis of class accuracy and precision (x- and z-locations) data is in the csv file [../data/target_data.csv](../data/target_data.csv) _Note: if you want to see how I turned the images into data check out the jupyter notebook [process_target_practice](./process_target_practice.ipynb)\n",
"\n",
"2. A Monte Carlo model to generate impact heights based upon uncertainty in $\\theta_0$ and $v_0$. \n",
"\n",
"3. The precision required to recreate the class accuracy and precision with a robot. \n",
"**You must show some validation of your work**\n",
"\n",
"4. [BONUS] Repeat 2-3 taking into account the variation in $x_{impact}$ due to misalignment. \n",
"\n",
"Given constants and constraints:\n",
"\n",
"- $d=$3 m, distance to target\n",
"\n",
"- $g=$9.81 m/s$^2$, acceleration due to gravity\n",
"\n",
"- $z(0)=$0.3 m, the initial height is 0.3 m above the bull's eye\n",
"\n",
"- 4 m/s$<v_0<$12 m/s, the initial velocity is always higher than 9 mph and less than 27 mph"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"#Import rcParams to set font styles\n",
"from matplotlib import rcParams\n",
"\n",
"#Set font style and size \n",
"rcParams['font.family'] = 'sans'\n",
"rcParams['font.size'] = 16\n",
"rcParams['lines.linewidth'] = 3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}