- The respository contains codes to generate dynamic equations for any general serial-manipulator robot given its DH parameters and link masses.
- The dynamic equation calculator is implemented to calculate dynamic equations of SCARA, PUMA and Stanford-type Manipulators and generate their 3-D simulations.
- It also contains codes to calculate the forward/inverse kinematics of the three manipulators and implementation of 4 different types of controllers to controller these 3 robots.
- Requirements: numpy, sympy, matplotlib
- Use to get side-by-side controllable simulation while passing commands in the command prompt.
- Starting Interactive Mode:
- Open the cloned folder using command prompt.
- Start python interactive mode using
py
/python
/python3
- Run the following lines:
This loads SCARA Manipulator and controls it using Multivariable_Position_Controller. This will open a window with live animation for the SCARA Manipulator.
from load import* arko, arkoCon = load(SCARAManipulator, Multivariable_Position_Controller)
- Try controlling the animation using these commands:
arko.set_ee_position((0.4,0.06,-0.3)) arkoCon.Achieve_EE_Position((0.4,0.01,-0.4))
- Use to generate pre-coded response from the simulations, passing command through a python script.
- Import the load.py and use load function as done in interactive mode.
- Use commands in the script files in a similar manner as used in interactive mode.
- Run the python script file.
- Refer to test.py for reference.
.
│ README.md
│ load.py # To load everything using one file
| test.py # A test file to ensure working of simulations and controllers
│
└───Controllers
│ │ __init__.py
│ │ ComputedTorqueFFController.py # Computed torques feedforward controller
| | FeedForwardController.py # Normal feedforward controller
| | MultivariableController.py # Multivariable controller
| | PIDController.py # PID Position Controller
│
└───Robots
| │ __init__.py
| │ PUMA.py # PUMA Manipulator (RRR)
| | SCARA.py # SCARA Manipulator (RRP)
| | Stanford.py # Stanford Manipulator (RRP)
| | Tools.py # Tools required to generate dynamic equations
|
- Each file contains robot classes with their respective functions.
- Useful Methods:
- set_state: To set the state of the robot.
- get_state: To retrieve the state of the robot.
- inv_kin: To get joint angles from the end effector position.
- set_ee_position: Set the end effector position.
- get_ee_position: Get the end effector position.
- apply_constant_torques: Apply the defined constant torques for 2 sec of simulation time.
- reset: Reset the manipulator position and time.
- LiesInWorkspace: Checks if the given point lies in the workspace of the robot.
- run: Start the animation.
- stop: Stop the animation.
- Each file contains robot controllers with their respective functions.
- Useful Methods:
- set_K: Set the gains for the controllers.
- set_target_state: Set the target states.
- achieve_target_state: Achieve the target state.
- Achieve_EE_Position: Achieve the given end effector position.
- follow_trajectory: Follow a defined trajectory of the robot.
- Contains the functions used to generate dynamic equations for any general 3D Manipulator.
- List of functions:
-
DHMatrix2Homo_and_Jacob
- Calculates Homogeneous Transform Matrix and Jacobian from the DH parameter matrix.
- Parameters:
- Hmat:
- DH parameter matrix (nx4); n --> Number of joints
- Number of links automatically estimated from the size of matrix
- Each row is of form: theta (rotation about z), d (translation about z), a(translation about x), alpha(rotation about x)
- First columns of params are frame 0-->1 transformation and last columns are frame (n-1)-->n transformation; n is the end effector frame
- prismatic:
- An array of the joints that are prismatic; Joint corresponding to angle qi is ith joint
- Hmat:
- Returns: A tuple of:
- H: Homogenoeous Transformation Matrix of n w.r.t. 0.
- J: Jacobian of nth frame for the given joints.
-
DV_Calculator
- Calculates the Inertia Matrix (D) and Potential Scalar Function (V) from DHMI Matrix.
- Parameters:
- DHMI Matrix:
- Dhmi: Dhmi (DH + Mass + Inetria Tensor) array
[[theta1, d1, l1, alpha1, m1, I1], [theta2, d2, l2, alpha2, m2, I2], [theta3, d3, l3, alpha3, m3, I3]]
Ii
is 3x3 inertia tensor of ith link w.r.t. the frame attached to ith link.
- g_dir:
- Direction of gravity
- Can be 'x', 'y', 'z', '-x', '-y', '-z'
- prismatic:
- An array of the joints that are prismatic: Joint corresponding to qi is ith joint
- DHMI Matrix:
- Returns:
- A tuple of:
- D: Inertia Matrix of the robot.
- V: Potential Scalar Function of the robot. Considers gravity only.
- A tuple of:
- IMPORTANT NOTES & ASSUMPTIONS:
- Assumed the centre of mass of link_i to lie at the midpoint of frame_(i-1) and frame_i.
- DHMI is a matrix with manipulator lengths, link masses passed as constants and joint variables passed as symbolic constants.
- g_dir is used to calculate the V, specifies the direction of g; Default is taken as -z
- Can also pass whole DHMI Matrix in terms of symbolic constants.
-
CG_from_DV
- Calculates the Christoffel Matrix (C) and Potential Feild Matrix (g_)
- Parameters:
- D: Inertia Matrix
- V: Scalar Potential Function
- Returns:
- A tuple of:
- C: Chritoffel Constants Matrix
- g_: Potential Feild Matrix
- A tuple of:
-
Dynamic_Equations_from_Dhmi
- Prints the dynamic equations from DHMI Matrix.
- Parameters:
- DHMI Matrix
- g_dir
- prismatic
- Returns:
- D: Inertia Matrix
- C: Christoffel Matrix
- g_: Potential Feild Matrix
-
q_dot2_array
- Gives an array of accelerations of joint angles, expressed in terms of joint angles and joint velocities and applied torques.
- Parameters:
- DHMI Matrix
- tau: A symbolic matrix containing symbolic constants for torques/forces at the joints.
- q_dot: A symbolic matrix containing symbolic constants for angular/linear velocities of the joints.
- prismatic
- Returns:
- A matrix containing joint accelerations in symbolic form.
-