Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gcode class #48

Merged
merged 39 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e8f6574
initialwork
philipp1604 Jan 10, 2023
b779f49
Current State Gcode_class
philipp1604 Mar 15, 2023
4bfc69a
Final Comit before Merge
philipp1604 Mar 16, 2023
60a5f3d
Merge branch 'main' into gcode_class
philipp1604 Mar 17, 2023
8d0ed55
Final Comit G-Code Class
philipp1604 Mar 23, 2023
b3e9e1d
Update gcode_dem.py
philipp1604 Mar 24, 2023
10e4d2b
new commit
philipp1604 Mar 24, 2023
12c7a68
Adjusting Codiga Errors
philipp1604 Mar 24, 2023
5ec0835
Update of the GCodeProcessor
philipp1604 Apr 19, 2023
10cad6a
Deletion of leftover files
philipp1604 Apr 19, 2023
cb1e25c
Final Adjustment GCodeProcessor
philipp1604 Apr 19, 2023
03abc0a
Renaming plane to axis
philipp1604 Apr 19, 2023
b3104fb
Update of read_gcode
philipp1604 Apr 19, 2023
4567a24
Update init-Method
philipp1604 Apr 19, 2023
a0a3a31
Update __init__
philipp1604 Apr 20, 2023
5a2bf30
Offset_def inside the __init__
philipp1604 Apr 21, 2023
22c9f7d
Changing GCodeProcessor to iterable object
philipp1604 May 2, 2023
700deae
Update GCodeProcessor as Iterable
philipp1604 May 5, 2023
a72dd9a
G1 commands inserted into GCode
philipp1604 May 10, 2023
9dae74d
Interpolation with Lamda Calls
philipp1604 May 16, 2023
7d1a91f
Converting into elemenary operations
philipp1604 May 17, 2023
ff0eec5
Converting every operation into a elementary operation
philipp1604 May 17, 2023
71c483a
Completion of G-Code Processor
philipp1604 May 22, 2023
7ce83fc
Adapting Test Class
philipp1604 May 23, 2023
3928a95
New version of the GCodeProccessor complete
philipp1604 May 23, 2023
57b7e5a
Reupload last Comit
philipp1604 May 24, 2023
f88a7d9
T-,M-,G- Command as Dictionaries
philipp1604 Jun 15, 2023
3235ff0
Merge branch 'main' into gcode_class
philipp1604 Jun 21, 2023
2f6b9c9
Update Test Class to Dictionary
philipp1604 Jun 21, 2023
fcb82a5
Implementation of self.interpolation_precision
philipp1604 Jun 21, 2023
08409a2
Debugging interpolation precision
philipp1604 Jun 22, 2023
07a6792
Debugged Interpolation Precsision
philipp1604 Jun 26, 2023
aba4b74
Addition of comments to the GCodeProcessor class
philipp1604 Jun 26, 2023
49edd97
set_path renamed to create_movement_operations
philipp1604 Jul 5, 2023
3307aa5
G Code Processor Update
philipp1604 Jul 17, 2023
e5c5e20
G Code Processor
philipp1604 Jul 17, 2023
9a59cb0
GCodeProcessor ready for Review
philipp1604 Jul 17, 2023
f64381e
Correction of the comments excpect monastry
philipp1604 Jul 18, 2023
326e5f2
Final Comit
philipp1604 Jul 19, 2023
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
48 changes: 48 additions & 0 deletions examples/GCodes/gcode_G0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
% with "%" it is possible to place comments in the G-Code

%Go to default position and adjust the orientation
G0 X1.9 Y-0.5 Z1.7 A-1.5708 B0 C0

%Approach Gripper
G0 X2.7
G0 Z1.3

%Toolchange (if programmed)
T1
%Move up and adjust orientation
G0 Z1.5 A-3.1415 B0 C0
%Go back to the default position
G0 X1.9 Y-0.5

%Close the gripper
M10
%Open the gripper
M11

%Approach Toolchange position
G0 X2.7
G0 Z0.7


%Decouple Gripper (if programmed)
T0

%Move up and adjust orientation
G0 Z1.9 A-1.57 B0 C0
%Go to default position
G0 X1.9 Y-0.5



%Zero Offset - Activation
G54
%Square movement and orientation flip
G0 X0.2
G0 Y0.2
G0 X0
G0 Y0
%Zero Offset - Deactivation
G500

%Go to default position and adjust the orientation
G0 X1.9 Y-0.5 Z1.9 A-1.5707 B0 C0
56 changes: 56 additions & 0 deletions examples/GCodes/gcode_G123.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
% with "%" it is possible to place comments in the G-Code

%Go to default position and adjust the orientation
G0 X1.9 Y-0.5 Z1.5 A-1.5707 B0 C0
%Approach Gripper
G1 X2.7
G1 Z1.3

%Toolchange (if programmed)
T1
%Move up and adjust orientation
G1 Z1.5 A3.1415 B0 C0
%Go back to the default position
G1 X1.9 Y-0.5

%Close the gripper
M10
%Open the gripper
M11

%Approach Toolchange position
G1 X2.7
G1 Z0.7


%Decouple Gripper (if programmed)
T0

%Move up and adjust orientation
G1 Z1.9 A-1.5707 B0 C0
%Go to default position
G1 X1.9 Y-0.5



%Zero Offset - Activation
G54
%Square movement and orientation flip
G1 X0.2
G1 Y0.2
G1 X0
G1 Y0
%Zero Offset - Deactivation
G500

%Go to default position and adjust the orientation
G1 X1.9 Y-0.5 Z1.9 A-1.5707 B0 C0

%Circular Interpolation - G2 in X-Y Plane
G17
G2 Y0.5 R0.6
G2 Y-0.5 R0.6

%Circular Interpolation - G3 in X-Y Plane
G3 Y0.5 R0.6
G3 Y-0.5 R0.6
3 changes: 3 additions & 0 deletions examples/GCodes/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
G0 X1.9 Y-0.5 Z1.7 A-1.5707 B0 C0
G54
G1 X0.1
83 changes: 83 additions & 0 deletions examples/g_code_processor_dem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import os
import pybullet as p
import pybullet_data
import pybullet_industrial as pi
import numpy as np


def actuate_gripper(gripper: pi.Gripper, val: int):
return gripper.actuate(val)


def couple_endeffector(gripper: pi.Gripper, robot: pi.RobotBase, link: chr):
return gripper.couple(robot, link)


def decouple_endeffector(gripper: pi.Gripper):
return gripper.decouple()


if __name__ == "__main__":

dirname = os.path.dirname(__file__)
urdf_file1 = os.path.join(dirname,
'robot_descriptions', 'comau_nj290_robot.urdf')
urdf_file2 = os.path.join(dirname,
'robot_descriptions', 'gripper_cad.urdf')
urdf_file3 = os.path.join(dirname,
'Objects', 'FoFa', 'FoFa.urdf')

pysics_client = p.connect(p.GUI, options='--background_color_red=1 ' +
'--background_color_green=1 ' +
'--background_color_blue=1')
p.setPhysicsEngineParameter(numSolverIterations=10000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is called twice for some reason

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line was removed

p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
p.setGravity(0, 0, -10)

p.loadURDF("cube.urdf", [1.9, 0, 0.5], useFixedBase=True)

p.loadURDF(urdf_file3, [-2, 5, 0], useFixedBase=True, globalScaling=0.001)

test_robot = pi.RobotBase(urdf_file1, [0, 0, 0], [0, 0, 0, 1])

test_robot.set_joint_position(({'q2': np.deg2rad(-15.0),
'q3': np.deg2rad(-90.0)}))
for _ in range(100):
p.stepSimulation()

start_orientation = p.getQuaternionFromEuler([np.pi, 0, 0])
test_gripper = pi.Gripper(urdf_file2, [2.7, -0.5, 1.2], start_orientation)
endeffector_list = []
endeffector_list.append(test_gripper)

# M-Commands have to be added in this convention
m_commands = {
"10": [lambda: actuate_gripper(test_gripper, 1)],
"11": [lambda: actuate_gripper(test_gripper, 0)]
}

# T-Commands have to be added in this convention
t_commands = {
"0": [lambda: decouple_endeffector(test_gripper)],
"1": [lambda: couple_endeffector(test_gripper, test_robot, 'link6')]
}

dirname = os.path.dirname(__file__)
textfile = os.path.join(dirname, 'Gcodes', 'gcode_G123.txt')

with open(textfile, encoding='utf-8') as f:
gcode_input = f.read()

demonstration_object = pi.GCodeProcessor(gcode_input, test_robot,
endeffector_list,
m_commands, t_commands)

# Create an iterator from the demonstration object
demonstration_iterator = iter(demonstration_object)

# Iterate over the demonstration object
for _ in demonstration_iterator:
# Execute the simulation steps
for _ in range(200):
p.stepSimulation()
1 change: 1 addition & 0 deletions src/pybullet_industrial/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
from pybullet_industrial.interpolation import circular_interpolation, linear_interpolation, spline_interpolation
from pybullet_industrial.path_builders import *
from pybullet_industrial.milling_tool import *
from pybullet_industrial.g_code_processor import *
Loading