## 2R Robotic Arm Simulation using MATLAB

Code and Description:

The project involves simulating a 2-joint robotic arm.

% Lengths
l1 = 1;
l2 = 0.5;

% Angles
ang1 = linspace (0, 90, 20);
ang2 = linspace (0, 90, 20);

count = 1;
% loop
for i = 1:length(ang1)
ANG1 = ang1(i);
for j = 1:length(ang2)
ANG2 = ang2(j);

x0 = 0;
y0 = 0;

x1 = l1*cosd(ANG1);
y1 = l1*sind(ANG1);

x2 = x1 + l2*cosd(ANG2);
y2 = y1 + l2*sind(ANG2);

% figure(count)
% hold on
plot([x0 x1],[y0 y1],'linewidth',3,'color','r',[x1 x2], [y1 y2], 'linewidth',2,'color','b')
axis([-0.5 1.5 0 1.5])
pause (0.03)
file_text = sprintf('img%d.png',count);
saveas(gca,file_text)
count = count + 1;

endfor
endfor

Firstly, we are going to run the simulation for positions of the arm at angles from 0 to 90 degrees. Lengths are taken as 1 and 0.5.

Angle 1 is the angle of the base link 1 and angle 2 is that of link 2, connected to the manipulator. We are simulating positions at every instance of angle 1 of link 1.

The inside nested loop simulates link 2, that is, the manipulator-connected-link, by plotting it's position at different inclinations for a single inclination of link 1. The positions are calculated and lines are plotted, which become the arms.

Animation is then saved in octave using sprintf to print multiple images, and then an mp4 video is compiled using imagemagick:

magick img%d.png[1-400] 2RRobotArmAnim.mp4

(400 frames were generated and then compiled)

Errors and Correction:

Below are some errors:

1. Length error: took the wrong length

Solution: changed l2 to l1, since the points x1 and y1 correspond to length of link 1.

2. "Hold on" command in effect; superimposed frames:

Solution: Removed "hold on" so plot is overwritten everytime.

3. Incorrect axis command:

Solution: hold on removed and axis adjusted to push the plot forward.

Below is the animation of the code.

2R Robotic Arm Simulation

### Simulating the motion of a pendulum using 2nd order ODE in Python Arjun Bhat · 2019-12-09 17:11:02

This project explores the simulation of the motion of a pendulum for the equation of damped vibration of a pendulum. Below is the equation (taken from "Challenges" page): The above equation is solved using ODE function, and then odeint is used to get an ar Read more

### Air standard cycle graph plotting in Python Arjun Bhat · 2019-11-20 17:11:18

Project involves plotting an Otto Cycle graph in MATLAB The goal is to plot all strokes for a petrol operating by the otto cycle from intake, compression, power to exhaust, including both adiabatic curves. Description: The Otto Cycle is the idealised cycle that descr Read more

### Forward Kinematics of a 2R Robotic Arm in Python Arjun Bhat · 2019-11-18 16:21:42

Objective: The project involves simulating a 2-joint robotic arm.   Code and Description: import math import matplotlib.pyplot as plt import numpy as nm # Lengths l1 = 1 l2 = 0.5 # Angles ang1 = nm.radians(nm.linspace(0, 90, 19)) ang2 = nm.radians Read more

### Flow over bicycle in Python Arjun Bhat · 2019-11-18 16:09:30

Objective: To calculate the drag force for various drag coefficient and velocity values for a certain geometry.   Introduction: Drag force is the force exerted by the air as the vehicle moves through it. The force exerted is directly proportional to the square Read more

### Parsing NASA Thermodynamic data for multiple specified Gas Species and Calculating the Thermodynamic Properties Arjun Bhat · 2019-09-11 20:25:18

Aim: To parse the NASA Thermodynamc Properties data file, calculate thermodynamic properties and plot the characteristics. Introduction: NASA's thermodynamic properties file consists of multiple species of gases, their respective operating temperature ranges, and Read more

### Optimization of a function using Genetic Algorithm in MATLAB Arjun Bhat · 2019-09-03 08:51:45

The project aims at optimization of a stalagmite function and finding the global maxima. For this, we will be using the concept of genetic algorithm. Following are the steps used to optimise the function: Code the function given in a separate function code. This is Read more

### Curve Fitting using MATLAB Arjun Bhat · 2019-08-19 20:20:53

Project aims at finding the best fit curve for a given data and finding the error between the original and said curve. The data being used is that of Specific heat (Cp) vs Temeperature. Plot will be made to show variation of Cp with Temp first.  Code: % Data cp Read more

### Simulating the motion of a pendulum using 2nd order ODE in MATLAB Arjun Bhat · 2019-08-13 18:30:48

This project explores the simulation of the motion of a pendulum for the equation of damped vibration of a pendulum. Below is the equation (taken from "Challenges" page): An attempt is made to solve the above equation, and then call it using ode45 to get an array of Read more

### Plotting of an Otto Cycle graph in MATLAB Arjun Bhat · 2019-08-12 19:40:08

Project involves plotting an Otto Cycle graph in MATLAB The goal is to plot all strokes for a petrol operating by the otto cycle from intake, compression, power to exhaust, including both adiabatic curves. Description: The Otto Cycle is the idealised cycle that descr Read more