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

simplified version of smart interaction explorer #35

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/__pycache__
/examples/__pycache__
*.pyc

/rostok.egg-info
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Установить Pychono из архива `conda install pychrono-7.0.0-py39_2112.tar.bz2`
* Установка движка способ 2
* `conda install -c projectchrono pychrono`
* Установить пакет в режими разработки `pip3 install -e .`
* Установить пакет `rostok` и остальные локальные пакеты в режими разработки `pip3 install -e .`
# Прокидываем дисплей через Docker

* Установить Х сервер для Windows https://sourceforge.net/projects/vcxsrv/
Expand Down
5 changes: 4 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ channels:
- defaults
dependencies:
- python=3.9.12
- irrlicht=1.8.5
- irrlicht
- numpy
- yapf
- mypy
- pylint
- pip
- pip:
- networkx==2.8.6
- matplotlib==3.6.0
- scipy
- mcts==1.0.4
- open3d
- lxml
49 changes: 49 additions & 0 deletions examples/intexp_crutch_render.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import open3d as o3d
import pychrono as chrono
import pychrono.irrlicht as irr
from numpy import asarray
from rostok.intexp.chrono_api import ChTesteeObject, ChCrutch

''' Floor added for clarity '''
floor = chrono.ChBodyEasyBox(1,0.005,1, 1000, True, True, chrono.ChMaterialSurfaceSMC())
floor.SetPos(chrono.ChVectorD(0,-0.1,0))
floor.SetBodyFixed(True)
floor.SetName('Floor')
floor.GetVisualShape(0).SetColor(chrono.ChColor(80/255, 80/255, 80/255))

''' Testee object placed in Crutch '''
obj_db = ChTesteeObject() # Create Chrono Testee Object
# Create 3D mesh and setup parameters from files
obj_db.create_chrono_body_from_file('./examples/models/custom/pipe.obj',
'./examples/models/custom/pipe.xml')
obj_db.set_chrono_body_ref_frame_in_point(chrono.ChFrameD(chrono.ChVectorD(0, 0.2, 0),
chrono.ChQuaternionD(1, 0, 0, 0)))

holder = ChCrutch(depth_k = 0.05)
holder.build_chrono_body(obj_db)

obj_db.set_chrono_body_ref_frame_in_point(holder.place_for_object)

system = chrono.ChSystemSMC()
system.Set_G_acc(chrono.ChVectorD(0,-9.8,0))
system.Add(obj_db.chrono_body) # Chrono Testee Object added to simulation
system.Add(floor)
system.Add(holder.chrono_body)
vis = irr.ChVisualSystemIrrlicht()
vis.AttachSystem(system)
vis.SetWindowSize(1028,768)
vis.SetWindowTitle('ZXC')
vis.SetSymbolScale(3)
vis.Initialize()
vis.AddLight(chrono.ChVectorD(0,10,0), 15)
vis.AddSkyBox()
vis.AddCamera(chrono.ChVectorD(1,0.5,1))
vis.EnableCollisionShapeDrawing(True)
vis.EnableBodyFrameDrawing(True)

while vis.Run():
system.Update()
system.DoStepDynamics(1e-3)
vis.BeginScene()
vis.Render()
vis.EndScene()
71 changes: 71 additions & 0 deletions examples/intexp_external_forces_on_testee_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import pychrono as chrono
import pychrono.irrlicht as irr
from rostok import intexp

""" Testee object is dumbbell """
obj_db = intexp.chrono_api.ChTesteeObject() # Create Chrono Testee Object
# create 3D mesh and parameters (grasping poses read from file)
obj_db.create_chrono_body_from_file('./examples/models/custom/body1.obj',
'./examples/models/custom/body1.xml')
obj_db.set_chrono_body_ref_frame_in_point(chrono.ChFrameD(chrono.ChVectorD(0,0.2,0),
chrono.ChQuaternionD(1,0,0,0)))

""" Impact on Testee Object """
impact = chrono.ChForce() # Create Impact
obj_db.chrono_body.AddForce(impact) # Attach to ChBody

IMPACTS_M = [1, 1, 1, 2, 2, 2] # Exam with 6 constant forces and different directions
IMPACTS_DIR = [chrono.ChVectorD(1,0,0),
chrono.ChVectorD(0,1,0),
chrono.ChVectorD(0,0,1),
chrono.ChVectorD(-1,0,0),
chrono.ChVectorD(0,-1,0),
chrono.ChVectorD(0,0,-1)]
IMPACTS_APPLICATION_POINT = [chrono.ChVectorD(0, 0, 0),
chrono.ChVectorD(0, 0, 0),
chrono.ChVectorD(0, 0, 0),
chrono.ChVectorD(0, 0, 0),
chrono.ChVectorD(0, 0, 0),
chrono.ChVectorD(0, 0, 0)]

# Switch timer of impact every 2 sec
tracking_timer = intexp.chrono_api.ImpactTimerParameters(test_bound=len(IMPACTS_DIR),
clock_bound=0.5, step = 1e-3)


''' Floor added for clarity '''
floor = chrono.ChBodyEasyBox(1,0.005,1, 1000, True, True, chrono.ChMaterialSurfaceSMC())
floor.SetPos(chrono.ChVectorD(0,-0.005,0))
floor.SetBodyFixed(True)
floor.SetName('Floor')
floor.GetVisualShape(0).SetColor(chrono.ChColor(80/255, 80/255, 80/255))

''' Simulation Solver '''
system = chrono.ChSystemSMC()
system.Set_G_acc(chrono.ChVectorD(0,0,0))
system.Add(obj_db.chrono_body) # Chrono Testee Object added to simulation
system.Add(floor)

''' PyChrono Visualisation '''
vis = irr.ChVisualSystemIrrlicht()
vis.AttachSystem(system)
vis.SetWindowSize(1028,768)
vis.SetWindowTitle('Impacts')
vis.SetSymbolScale(3)
vis.Initialize()
vis.AddLight(chrono.ChVectorD(0,10,0), 15)
vis.AddSkyBox()
vis.AddCamera(chrono.ChVectorD(1,0.5,1))
vis.EnableCollisionShapeDrawing(True)
vis.EnableBodyFrameDrawing(True)

while vis.Run():
system.Update()
system.DoStepDynamics(1e-3)
vis.BeginScene()
vis.Render()
vis.EndScene()
# Update timer and go through the list of impacts
intexp.chrono_api.update_impact(obj_db, impact, tracking_timer,
IMPACTS_APPLICATION_POINT, IMPACTS_DIR, IMPACTS_M)

72 changes: 72 additions & 0 deletions examples/intexp_load_and_show_testee_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import pychrono as chrono
import pychrono.irrlicht as irr

from rostok import intexp

GENERATE_NEW_POSES = True

''' Testee object is dumbbell '''
obj_db = intexp.chrono_api.ChTesteeObject() # Create Chrono Testee Object

# Create 3D mesh and setup parameters from files
obj_db.create_chrono_body_from_file('./examples/models/custom/pipe.obj',
'./examples/models/custom/pipe.xml')

# Uncomment the line below for generate new poses
if GENERATE_NEW_POSES:
# new_gen_poses = intexp.poses_generator.gen_random_poses_around_line(20, 0.04, 0.06, 0.015, 0.18)
# new_gen_poses = intexp.poses_generator.gen_cylindrical_surface_from_poses(20, 0.07, 0.015, 0.18)
new_gen_poses = intexp.poses_generator.gen_cylindrical_surface_around_object_axis(obj_db, 20, 0.07, 0.02, 'z')
# new_gen_poses = intexp.poses_generator.gen_random_poses_around_object_axis(obj_db, 20, 0.07, 0.02, 'z')
obj_db.rewrite_grasping_poses_list(new_gen_poses)

obj_db.demonstrate_object_and_grasping_poses()

desired_poses = obj_db.get_chrono_grasping_poses_list() # List of all grasping poses
hand_power_grasp_frame = chrono.ChFrameD(chrono.ChVectorD(0, 0, 0), chrono.Q_ROTATE_Z_TO_Y) # Power grasp point in the ABS
obj_db.set_chrono_body_on_pose(desired_poses[0], hand_power_grasp_frame) # Position object for grasp pose into point

''' Floor added for clarity '''
floor = chrono.ChBodyEasyBox(1,0.005,1, 1000, True, False, chrono.ChMaterialSurfaceSMC())
floor.SetPos(chrono.ChVectorD(0,-0.005,0))
floor.SetBodyFixed(True)
floor.SetName('Floor')
floor.GetVisualShape(0).SetColor(chrono.ChColor(80/255, 80/255, 80/255))

''' Simulation Solver '''
system = chrono.ChSystemSMC()
system.Set_G_acc(chrono.ChVectorD(0,0,0))
system.Add(obj_db.chrono_body) # Chrono Testee Object added to simulation
system.Add(floor)

''' PyChrono Visualisation '''
vis = irr.ChVisualSystemIrrlicht()
vis.AttachSystem(system)
vis.SetWindowSize(1028,768)
vis.SetWindowTitle('Grasping positions generation example')
vis.SetSymbolScale(3)
vis.Initialize()
vis.AddLight(chrono.ChVectorD(0,10,0), 15)
vis.AddSkyBox()
vis.AddCamera(chrono.ChVectorD(1,0.5,1))
vis.EnableCollisionShapeDrawing(True)
vis.EnableBodyFrameDrawing(True)

counter = 0.0
i = 1

while vis.Run():
system.Update()
system.DoStepDynamics(1e-3)
vis.BeginScene()
vis.Render()
vis.EndScene()

if counter > 0.1: #Demonstration all poses every 0.1 seconds
obj_db.set_chrono_body_on_pose(desired_poses[i], hand_power_grasp_frame)
counter = 0.0
i += 1
if i >= len(desired_poses):
i = 0
else:
counter += 1e-3
5 changes: 5 additions & 0 deletions examples/models/custom/body1.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# WaveFront *.mtl file (generated by Autodesk ATF)

newmtl Steel_-_Satin
Kd 0.627451 0.627451 0.627451

Loading