Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Python_program_for_2R_Robot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#python program for inverse and forward kinematics
import bpy
import numpy as np

#Set the mode to pose
bpy.ops.object.mode_set(mode='POSE')

# get specific bone name 'Bone'
End_eff = bpy.data.objects['Armature'].pose.bones["Bone.003"]

#Trajectory Planning using cubic polynomial
def cubic_coefficients(q0, qf, t0, tf):
a0 = q0
a1 = 0
a2 = (3 * (qf - q0) / ((tf - t0) ** 2))
a3 = (-2 * (qf - q0) / ((tf - t0) ** 3))
return a0, a1, a2, a3

def cubic_trajectory(t, a0, a1, a2, a3):
return a0 + a1 * t + a2 * t**2 + a3 * t**3

#Initializing an array to store the robot trajectory
x_traj = np.zeros(1)
y_traj = np.zeros(1)
z_traj = np.zeros(1)
tframe = np.zeros(1)

#Start generating trajectory in every frame
start_frame = 1
last_frame = 240

#A loop to generate position equal to the number of frames
t = np.linspace(start_frame-1,last_frame,240)
for i in t:
t0 = start_frame
tf = last_frame
tframe += start_frame
End_eff_home = (0,0,0)
End_eff_final = (0,0,0)
#X coordinates for the trajectory
q0_xi, q0_xf = End_eff_home[0], End_eff_final[0]
x0,x1,x2,x3 = cubic_coefficients(q0_xi,q0_xf,t0,tf)
x_traj= cubic_trajectory(tframe,x0,x1,x2,x3)

#y coordinates for the trajectory
q0_yi, q0_yf = End_eff_home[1], End_eff_final[1]
y0,y1,y2,y3 = cubic_coefficients(q0_yi,q0_yf,t0,tf)
y_traj= cubic_trajectory(tframe,y0,y1,y2,y3)

#z coordinates for the trajectory
q0_zi, q0_zf = End_eff_home[2], End_eff_final[2]
z0,z1,z2,z3 = cubic_coefficients(q0_zi,q0_zf,t0,tf)
z_traj= cubic_trajectory(tframe,z0,z1,z2,z3)


End_eff.keyframe_insert("location", frame = i)

End_eff.location = (x_traj,y_traj,z_traj)

End_eff.keyframe_insert("location", frame = last_frame)
#robot_pos.location.y =3
Binary file added RIGGED 3D model of a 2R robotic arm.blend
Binary file not shown.
60 changes: 60 additions & 0 deletions presentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Project Name: Robot Simulator with Blender and Python

## Contents
1. **Introduction**
2. **3D Model**
3. **Rigging**
4. **Visualization**
5. **Scripting**
- Inverse Kinematics
6. **Conclusion**
7. **Future Works**
## Introduction
This project aims to develop an open-source, real-time robot arm simulator inspired by This project aims to develop an open-source, real-time robot arm simulator inspired by the KUKA KR 700 PA palletizing robot.
![3D Model](https://github.com/CK-Ndiritu/CK-Ndiritu/blob/main/Picture1.png?raw=true)

## Objectives
1. 3D Modeling: Create a detailed 3D model of the robotic arm and its components in Blender, inspired by the KUKA KR 700 PA palletizing robot.

2. Rigging: Rig the robot arm in Blender, creating a control system that corresponds to the joints and actuators of the real robot.

3. Scripting: Develop scripts using Python.

## Methodology
There are various steps involved in creating the Simulator. These steps include 3D Modeling, Rigging, Scripting, Creating a user inteface and finally digital twinning the physical robot with the virtual model.

### 1. 3D Modeling
Involves creating a three dimensional representation of the robot using Blender software. The design includes 3 links, 3 joints and an end effector.

![3D Model](https://github.com/CK-Ndiritu/CK-Ndiritu/blob/main/Picture5.png?raw=true)


### 2. Rigging
Involves adding control to the model. It defines the range of movement for a model by defining its actions and movements. Rigging in blender inlvoves the use of armatures that are parented to the robot links and constrained to produce a movement similar to that of a real robot.

![3D Model](https://github.com/CK-Ndiritu/CK-Ndiritu/blob/main/Rigging.png?raw=true)

### Visualization and animation
![Visualization](https://github.com/CK-Ndiritu/CK-Ndiritu/blob/main/visualization.gif?raw=true)

### 3. Scripting
This is the programming part of the simulator which involves designing a forward kinematics algorithm and an inverse kinematics algorithm.

*Inverse Kinematics and real time simulations*
![3D Model](https://github.com/CK-Ndiritu/CK-Ndiritu/blob/main/Picture4.png?raw=true)

![Video](https://github.com/CK-Ndiritu/CK-Ndiritu/blob/main/end%20effectors%20move%20from%20home%20to%20final%20position.gif?raw=true)


## 4. Conclusion
Using the python program one can simulate the 2R robot movements and when interfaced with blender open source software its possible to animate, visualize and also verify the simulation results, as what would happen in real situations.

## 5. Extra Work to Work on.
Modeling a more realistic and aesthetic Robot Simulator model in Blender making use of rendering and realistic dimensions.
Creating a Graphics User Interface in blender or in the python Code to enable a simple interaction of the code and the model by the learner.
Documenting the Project
Extracting Tutorials from the project for new learners with interest in similar related projects.

***
*Refer to the **https://github.com/SiliconWit/real-time-robot-arm-simulator/blob/CK-Ndiritu/RIGGED%203D%20model%20of%20a%202R%20robotic%20arm.blend** for the 3D Model and **https://github.com/SiliconWit/real-time-robot-arm-simulator/blob/CK-Ndiritu/Python_program_for_2R_Robot.py** for the robot control python script.*
***