Skip to content

Commit e8e62a8

Browse files
committed
Update readme
1 parent efcfb38 commit e8e62a8

File tree

2 files changed

+38
-29
lines changed

2 files changed

+38
-29
lines changed

README.md

+38-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# API for Simulating Multi-link System
1+
API for Simulating Multi-link System
2+
====================================
23
Final project of ME314 Machine Dynamics
34

45
student: Feiyu Chen
@@ -11,22 +12,30 @@ video domos:
1112

1213
pdf version of README: [pdf](README.pdf) (Due to some math eqs are not shown well on github.)
1314

14-
# Contents:
15-
- [1. Introduction](#1.-Introduction)
16-
- [2. Files](#2.-Files)
17-
- [3. API Functions](#3.-API-Functions)
18-
- [4. Example of Using My Functions](#4.-Example-of-Using-My-Functions)
19-
- [5. Calculation of EL-eqs and Impacts](#5.-Calculation-of-EL-eqs-and-Impacts)
20-
- [6. How is This API being Generalized](#6.-How-is-This-Api-Being-Generalized)
21-
- [7. Problems](#7.-Problems)
15+
**Contents:**
16+
- [API for Simulating Multi-link System](#api-for-simulating-multi-link-system)
17+
- [1. Introduction](#1-introduction)
18+
- [1.1. Why I made this API](#11-why-i-made-this-api)
19+
- [1.2. Intro](#12-intro)
20+
- [1.3. How to run](#13-how-to-run)
21+
- [2. Files](#2-files)
22+
- [3. API Functions](#3-api-functions)
23+
- [4. Example of Using My Functions](#4-example-of-using-my-functions)
24+
- [5. Calculation of EL-eqs and Impacts](#5-calculation-of-el-eqs-and-impacts)
25+
- [5.1. Kinetic and Potential Energy](#51-kinetic-and-potential-energy)
26+
- [5.2. Constraint and External Force](#52-constraint-and-external-force)
27+
- [5.3. Detecting Impacts](#53-detecting-impacts)
28+
- [5.4. Impact Update](#54-impact-update)
29+
- [6. How is This API being Generalized](#6-how-is-this-api-being-generalized)
30+
- [7. Problems](#7-problems)
2231

2332

2433
# 1. Introduction
2534

26-
## 1.1 Why I made this API
35+
## 1.1. Why I made this API
2736
It can be a big headache to hardcode the simulation of multi-link system in Mathematica, as it's nontrivial to type in all formulas and to deal with all kinds of weird bugs. The goal of this project is to reduce such pain by wrapping up an API (> Application Programming Interface) so users/students could build up a simulation by using simple functions.
2837

29-
## 1.2 Intro
38+
## 1.2. Intro
3039

3140
The core of the API is a set of functions called "createLink", with Applications of creating links, triangle (polygon), vertices and wall. I made 4 scenes to demonstrate the usage of my API which are stored in "./scenes/". The videos are in current folder. The images are shown here.
3241

@@ -35,52 +44,52 @@ The core of the API is a set of functions called "createLink", with Applications
3544
Figure 1. Four example scenes of multi-link system.
3645

3746

38-
## 1.3 How to run
47+
## 1.3. How to run
3948

4049
Open this [run_this.nb](run_this.nb). Modify code and choose a scene in the second cell (you can search the keyword "Choose a scene"). And then run through the whole script.
4150
The scenes .nb files are in "./scenes/".
4251

4352
# 2. Files
44-
## 2.1 run_this.nb
53+
* 2.1. run_this.nb
4554
This is the main file.
4655

47-
## 2.2 scenes/
56+
* 2.2. scenes/
4857
The scenes are stored in "./scenes/". Inside each scene script, there is a only function called "CreateObjects[]". Inside it, the codes describe the links that form the simulation. You may change it and create your own.
4958

50-
## 2.3 lib/
59+
* 2.3. lib/
5160
This stores 3 library files: [funcs_assist.nb](funcs_assist.nb), [funcs_main.nb](funcs_main.nb), and [funcs_math.nb](funcs_math.nb). They provide the necessary functions and parameters for the main script. They will be loaded when running the "run_this.nb".
5261

5362
# 3. API Functions
5463
I wrote 5 functions:
5564

56-
### 3.1 createVertex
65+
* createVertex
5766

5867
Create a vertex.
5968

6069
> Application: create a point obstacle, or append a link to it to make a pendulum.
6170
62-
### 3.2 createLink0DOFpp
71+
* createLink0DOFpp
6372

6473
Create a link with 0 degrees of freedom (DOF). The "pp" at the end indicates that the inputs are two points "point1" and "point2" with format of 2-vector.
6574

6675
> Application: create a wall, or append it to another link to form a rigid body. See an example in Example 1 of creating polygon.
6776
68-
### 3.3 createLink0DOFg$\mathbf{\theta}$l
77+
* createLink0DOFg$\mathbf{\theta}$l
6978

7079
This is same as above for creating a 0 DOF link, except that the inputs are:
7180
* The starting coordinate's 4x4 matrix $\mathbf{g}$.
7281
* Relative angle $\theta$.
7382
* Length of this link $\mathbf{l}$.
7483

75-
### 3.4 createLink1DOFg$\mathbf{\theta}$l
84+
* createLink1DOFg$\mathbf{\theta}$l
7685

7786
Create a 1 DOF link. The link can rotate around its starting coordinate $\mathbf{g}$.
7887

7988
The inputs "g$\mathbf{\theta}$l" are the same as above, which are used for specifying the starting coordinate, relative angle, and length of this link.
8089

8190
> Application: append this link to a pendulum. For example, turning a double-pendulum into a triple-pendulum.
8291
83-
### 3.5 createLink3DOFpp
92+
* createLink3DOFpp
8493

8594
Create a 3 DOF link that can move in $\mathbf{x}$ and $\mathbf{y}$ direction and rotate around its center for angle $\theta$.
8695
Its inputs are the initial positions of its two vertices.
@@ -136,14 +145,14 @@ createLink0DOF
136145

137146
After creating these links, you can simply run the main file and see the animation.
138147

139-
## 5. Calculation of EL-eqs and Impacts
148+
# 5. Calculation of EL-eqs and Impacts
140149

141-
### 5.1 Kinetic and Potential Energy
150+
## 5.1. Kinetic and Potential Energy
142151
Suppose a link has length $\mathbf{l}$. Then I assume its mass to be $\mathbf{l}$ and inertia to be $\mathbf{l^2}$. The generalized 6x6 body mass M is then obtained.
143152

144153
For each link, I compute the 4x4 matrix representation $\mathbf{g}$ of its center frame. Then calculate the body screw velocity $\mathbf{V}$ using $\mathbf{g}$ and $\mathbf{dg/dt}$. Then the kinetic energy is $\frac{1}{2}\mathbf{V^T M V}$.
145154

146-
### 5.2 Constraint and External Force
155+
## 5.2. Constraint and External Force
147156

148157
These two elements can be easily added up to the EL-eqs.
149158

@@ -153,7 +162,7 @@ In scene1.nb, I add a constraint to the link at right up corner. I fixed its hei
153162
The external forces are set in this sentence:
154163
> externalForces = ConstantArray[0, nVars];
155164
156-
### 5.3 Detecting Impacts
165+
## 5.3. Detecting Impacts
157166

158167
The impact happens when **one link's vertex** goes through **another link's edge**. The two links should also from different groups.
159168

@@ -166,7 +175,7 @@ For determining whether a vertex is inside the edge, I wrote two different metho
166175

167176
(Meanwhile, whether the projection of vertex is on edge is also considered.)
168177

169-
### 5.4 Impact Update
178+
## 5.4. Impact Update
170179

171180
The logic of my code for impact detection looks like this:
172181

@@ -195,23 +204,23 @@ Loop{
195204

196205

197206
# 7. Problems
198-
### **Not Detecting Some Impacts**
207+
* **Not Detecting Some Impacts**
199208
At some occasions, the vertex might go through the edge. The cause is that the object's velocity is too large, or the integration step length is too large. Currently, I didn't implement any advanced techinques to go back and forth to check the exact impact time.
200209

201210
So you might need to reduce the integration step length, or make your scene smaller (thus less potential energy and a smaller max speed).
202211

203-
### **Slow Computing**
212+
* **Slow Computing**
204213
When the total DOF<10, links<15, step_size=0.001, simulation_time=15s, it takes about 3 minutes to compute all motions. Thus, the DOF and links cannot be too many, or it will cost too much time to compute impacts and do NDSolve.
205214

206-
### **Be Cautions with Constraint**
215+
* **Be Cautions with Constraint**
207216
When applying constraint to a configuration variable, we must make sure that this variable won't move perpendicular to the constraint surface. Two cases (which are not subject to the solution of EL-eqs) can cause problem of making total energy not conserved:
208217

209218
1. Wrong initial velocity.
210219
2. Impacts.
211220

212221
The reason is that we are actually not applying constraint $\mathbf{\phi}$. Instead, we use $\mathbf{d\phi /dq}$ and $\mathbf{d^2\phi /dt^2}$ for solving EL-eqs.
213222

214-
### **No Varying Constraint**
223+
* **No Varying Constraint**
215224
I didn't add varying constraint in this project. But I do make an analysis of how to do it below:
216225

217226
Consider a chair on the floor. Under my current scheme, the chair will keep on impacting with the floor and make the simulation slow and inaccurate.

README.pdf

-61.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)