-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample2.py
More file actions
55 lines (50 loc) · 1.88 KB
/
example2.py
File metadata and controls
55 lines (50 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import numpy as np
from TwoLink.TwoLinkAnimation import TwoLinkAnimation
from ThreeDOF.ThreeDOFJacobian import ThreeDOFJacobian
from TwoLink.TwoLinkLogAnimation import TwoLinkLogAnimation
from TwoLink.TwoLinkPDAnimation import TwoLinkPDAnimation
#Example Code
#Declare Link Lenghts
l1, l2 = 2.0, 1.0
x,y = 1.0, 1.0
xf, yf = 2.0, 2.0
m1 = 1.0
m2 = 1.0
#TwoLinkAnimation(l1,l2,x,y,xf,yf,m1,m2)
TwoLinkSimulation = TwoLinkLogAnimation(l1=l1,l2 =l2,x=x,y=y,xf=xf,yf=yf,m1=m1,m2=m2)
#
#
TwoLinkSimulation.animate()
#Defining Targets for 3DOF Robot Arm (In This example, the arm will be drawing a cube)
targets = [
(9, 9, 9), # Starting point
(9, 12, 9), # Move to top-left front
(12, 12, 9), # Move to top-right front
(12, 9, 9), # Move to bottom-right front
(9, 9, 9), # Back to bottom-left front
(9, 9, 12), # Move to bottom-left back
(9, 12, 12), # Move to top-left back
(12, 12, 12), # Move to top-right back
(12, 9, 12), # Move to bottom-right back
(9, 9, 12), # Back to bottom-left back
(9, 12, 12), # Connect to top-left back
(9, 12, 9), # Connect to top-left front
(12, 12, 9), # Connect to top-right front
(12, 12, 12), # Connect to top-right back
(12, 9, 12), # Connect to bottom-right back
(12, 9, 9), # Connect to bottom-right front
(9, 9, 9) # Return to starting point
]
# Create an instance of the JacobianThreeDOFManipulator class
manipulator = ThreeDOFJacobian(
l1=10, # Length of the first link
l2=10, # Length of the second link
l3=10, # Length of the third link
theta1=45, # Initial angle of the first joint in degrees
theta2=30, # Initial angle of the second joint in degrees (upward bend)
theta3=-30, # Initial angle of the third joint in degrees (upward bend)
targets=targets, # List of targets
t_per_target=100 # Time per target
)
# Run the animation
#manipulator.animate()