agx-openplx 0.15.0__cp39-cp39-macosx_12_0_arm64.whl → 0.15.2__cp39-cp39-macosx_12_0_arm64.whl
Sign up to get free protection for your applications and to get access to all the features.
- agx_openplx-0.15.2.dist-info/METADATA +63 -0
- agx_openplx-0.15.2.dist-info/RECORD +41 -0
- openplx/DriveTrain.py +0 -406
- openplx/Physics.py +3634 -2416
- openplx/Physics1D.py +23 -1221
- openplx/Physics3D.py +4444 -7186
- openplx/Robotics.py +153 -993
- openplx/_AgxOpenPlxPyApi.cpython-39-darwin.so +0 -0
- openplx/_CorePythonSwig.cpython-39-darwin.so +0 -0
- openplx/_DriveTrainSwig.cpython-39-darwin.so +0 -0
- openplx/_Physics1DSwig.cpython-39-darwin.so +0 -0
- openplx/_Physics3DSwig.cpython-39-darwin.so +0 -0
- openplx/_PhysicsSwig.cpython-39-darwin.so +0 -0
- openplx/_RoboticsSwig.cpython-39-darwin.so +0 -0
- openplx/_SimulationSwig.cpython-39-darwin.so +0 -0
- openplx/_TerrainSwig.cpython-39-darwin.so +0 -0
- openplx/_UrdfSwig.cpython-39-darwin.so +0 -0
- openplx/_VehiclesSwig.cpython-39-darwin.so +0 -0
- openplx/__init__.py +20 -16
- openplx/api.py +102 -86
- openplx/migrate.py +84 -30
- openplx/migrations.py +192 -10
- openplx/openplx_application.py +19 -14
- openplx/openplx_validate.py +3 -3
- openplx/openplx_view.py +1 -1
- agx_openplx-0.15.0.dist-info/METADATA +0 -231
- agx_openplx-0.15.0.dist-info/RECORD +0 -41
- {agx_openplx-0.15.0.dist-info → agx_openplx-0.15.2.dist-info}/WHEEL +0 -0
- {agx_openplx-0.15.0.dist-info → agx_openplx-0.15.2.dist-info}/entry_points.txt +0 -0
openplx/migrations.py
CHANGED
@@ -25,9 +25,8 @@ def migration(from_version: str, to_version: str, order: int = 0):
|
|
25
25
|
|
26
26
|
return decorator
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
def snakecaseify_methods(documents):
|
28
|
+
@migration("0.9.3", "0.10.0")
|
29
|
+
def snakecaseify_methods_093(documents): # pylint: disable=too-many-statements
|
31
30
|
ops = []
|
32
31
|
ops.extend(RefactorToolkit.renameMethod(documents, "Math.Vec3.fromXYZ", "from_xyz"))
|
33
32
|
ops.extend(
|
@@ -118,13 +117,6 @@ def snakecaseify_methods(documents):
|
|
118
117
|
ops.extend(
|
119
118
|
RefactorToolkit.renameMethod(documents, "Math.Line.fromPoints", "from_points")
|
120
119
|
)
|
121
|
-
|
122
|
-
return [ReplaceOp(op) for op in ops]
|
123
|
-
|
124
|
-
|
125
|
-
@migration("0.9.3", "0.10.0")
|
126
|
-
def snakecaseify_methods_093(documents):
|
127
|
-
ops = []
|
128
120
|
# ValueOutputSignal
|
129
121
|
ops.extend(
|
130
122
|
RefactorToolkit.renameMethod(
|
@@ -450,6 +442,185 @@ def migrations_for_0_13_1(documents):
|
|
450
442
|
|
451
443
|
return [ReplaceOp(op) for op in ops]
|
452
444
|
|
445
|
+
@migration("0.14.0", "0.15.0")
|
446
|
+
def rename_from_brick_to_openplx(document_path):
|
447
|
+
|
448
|
+
return ChangeExtensionOp(Path(document_path), ".openplx")
|
449
|
+
|
450
|
+
|
451
|
+
@migration("0.15.1", "0.15.2")
|
452
|
+
def migrations_for_0_15_1(documents):
|
453
|
+
ops = []
|
454
|
+
ops.extend(
|
455
|
+
RefactorToolkit.renameModel(
|
456
|
+
documents,
|
457
|
+
"Robotics.Joints.TorqueDriveTrain",
|
458
|
+
"FlexibleJointDriveTrain",
|
459
|
+
)
|
460
|
+
)
|
461
|
+
ops.extend(
|
462
|
+
RefactorToolkit.renameModel(
|
463
|
+
documents,
|
464
|
+
"Robotics.Joints.AngularVelocityDriveTrain",
|
465
|
+
"FlexibleJointDriveTrain",
|
466
|
+
)
|
467
|
+
)
|
468
|
+
ops.extend(
|
469
|
+
RefactorToolkit.moveAndRenameModel(
|
470
|
+
documents,
|
471
|
+
"Physics3D.Signals.HingeAngularVelocityOutput",
|
472
|
+
"Physics.Signals",
|
473
|
+
"AngularVelocity1DOutput",
|
474
|
+
)
|
475
|
+
)
|
476
|
+
ops.extend(
|
477
|
+
RefactorToolkit.renameAttribute(
|
478
|
+
documents, "Physics3D.Signals.HingeAngularVelocityOutput.hinge", "source"
|
479
|
+
)
|
480
|
+
)
|
481
|
+
ops.extend(
|
482
|
+
RefactorToolkit.moveAndRenameModel(
|
483
|
+
documents,
|
484
|
+
"DriveTrain.Signals.TorqueMotorInput",
|
485
|
+
"Physics.Signals",
|
486
|
+
"Torque1DInput",
|
487
|
+
)
|
488
|
+
)
|
489
|
+
ops.extend(
|
490
|
+
RefactorToolkit.renameAttribute(
|
491
|
+
documents, "DriveTrain.Signals.TorqueMotorInput.motor", "source"
|
492
|
+
)
|
493
|
+
)
|
494
|
+
ops.extend(
|
495
|
+
RefactorToolkit.moveAndRenameModel(
|
496
|
+
documents,
|
497
|
+
"Physics3D.Signals.LinearSpringPositionInput",
|
498
|
+
"Physics.Signals",
|
499
|
+
"Position1DInput",
|
500
|
+
)
|
501
|
+
)
|
502
|
+
ops.extend(
|
503
|
+
RefactorToolkit.renameAttribute(
|
504
|
+
documents, "Physics3D.Signals.LinearSpringPositionInput.spring", "source"
|
505
|
+
)
|
506
|
+
)
|
507
|
+
ops.extend(
|
508
|
+
RefactorToolkit.moveAndRenameModel(
|
509
|
+
documents,
|
510
|
+
"Physics3D.Signals.TorsionSpringAngleInput",
|
511
|
+
"Physics.Signals",
|
512
|
+
"AngleInput",
|
513
|
+
)
|
514
|
+
)
|
515
|
+
ops.extend(
|
516
|
+
RefactorToolkit.renameAttribute(
|
517
|
+
documents, "Physics3D.Signals.TorsionSpringAngleInput.spring", "source"
|
518
|
+
)
|
519
|
+
)
|
520
|
+
ops.extend(
|
521
|
+
RefactorToolkit.moveAndRenameModel(
|
522
|
+
documents,
|
523
|
+
"Physics3D.Signals.RigidBodyRPYOutput",
|
524
|
+
"Physics3D.Signals",
|
525
|
+
"RPYOutput",
|
526
|
+
)
|
527
|
+
)
|
528
|
+
ops.extend(
|
529
|
+
RefactorToolkit.renameAttribute(
|
530
|
+
documents, "Physics3D.Signals.RigidBodyRPYOutput.rigid_body", "source"
|
531
|
+
)
|
532
|
+
)
|
533
|
+
ops.extend(
|
534
|
+
RefactorToolkit.moveAndRenameModel(
|
535
|
+
documents,
|
536
|
+
"Physics3D.Signals.RigidBodyPositionOutput",
|
537
|
+
"Physics3D.Signals",
|
538
|
+
"Position3DOutput",
|
539
|
+
)
|
540
|
+
)
|
541
|
+
ops.extend(
|
542
|
+
RefactorToolkit.renameAttribute(
|
543
|
+
documents, "Physics3D.Signals.RigidBodyPositionOutput.rigid_body", "source"
|
544
|
+
)
|
545
|
+
)
|
546
|
+
ops.extend(
|
547
|
+
RefactorToolkit.renameAttribute(
|
548
|
+
documents, "Physics3D.Interactions.VelocityMotor.desired_speed", "target_speed"
|
549
|
+
)
|
550
|
+
)
|
551
|
+
ops.extend(
|
552
|
+
RefactorToolkit.renameAttribute(
|
553
|
+
documents, "Physics1D.Interactions.VelocityMotor.desired_speed", "target_speed"
|
554
|
+
)
|
555
|
+
)
|
556
|
+
ops.extend(
|
557
|
+
RefactorToolkit.moveAndRenameModel(
|
558
|
+
documents,
|
559
|
+
"Physics3D.Signals.RotationalVelocityMotorVelocityInput",
|
560
|
+
"Physics.Signals",
|
561
|
+
"AngularVelocity1DInput",
|
562
|
+
)
|
563
|
+
)
|
564
|
+
ops.extend(
|
565
|
+
RefactorToolkit.renameAttribute(
|
566
|
+
documents, "Physics3D.Signals.RotationalVelocityMotorVelocityInput.motor", "source"
|
567
|
+
)
|
568
|
+
)
|
569
|
+
ops.extend(
|
570
|
+
RefactorToolkit.moveAndRenameModel(
|
571
|
+
documents,
|
572
|
+
"Physics1D.Signals.RotationalVelocityMotor1DVelocityInput",
|
573
|
+
"Physics.Signals",
|
574
|
+
"AngularVelocity1DInput",
|
575
|
+
)
|
576
|
+
)
|
577
|
+
ops.extend(
|
578
|
+
RefactorToolkit.renameAttribute(
|
579
|
+
documents, "Physics1D.Signals.RotationalVelocityMotor1DVelocityInput.motor", "source"
|
580
|
+
)
|
581
|
+
)
|
582
|
+
ops.extend(
|
583
|
+
RefactorToolkit.moveAndRenameModel(
|
584
|
+
documents,
|
585
|
+
"Physics3D.Signals.LinearVelocityMotorVelocityInput",
|
586
|
+
"Physics.Signals",
|
587
|
+
"LinearVelocity1DInput",
|
588
|
+
)
|
589
|
+
)
|
590
|
+
ops.extend(
|
591
|
+
RefactorToolkit.renameAttribute(
|
592
|
+
documents, "Physics3D.Signals.LinearVelocityMotorVelocityInput.motor", "source"
|
593
|
+
)
|
594
|
+
)
|
595
|
+
ops.extend(
|
596
|
+
RefactorToolkit.moveAndRenameModel(
|
597
|
+
documents,
|
598
|
+
"Physics1D.Signals.RotationalBodyAngularVelocityOutput",
|
599
|
+
"Physics.Signals",
|
600
|
+
"AngularVelocity1DOutput",
|
601
|
+
)
|
602
|
+
)
|
603
|
+
ops.extend(
|
604
|
+
RefactorToolkit.renameAttribute(
|
605
|
+
documents, "Physics1D.Signals.RotationalBodyAngularVelocityOutput.body", "source"
|
606
|
+
)
|
607
|
+
)
|
608
|
+
ops.extend(
|
609
|
+
RefactorToolkit.moveAndRenameModel(
|
610
|
+
documents,
|
611
|
+
"Physics1D.Signals.RotationalBodyAngleOutput",
|
612
|
+
"Physics.Signals",
|
613
|
+
"AngleOutput",
|
614
|
+
)
|
615
|
+
)
|
616
|
+
ops.extend(
|
617
|
+
RefactorToolkit.renameAttribute(
|
618
|
+
documents, "Physics1D.Signals.RotationalBodyAngleOutput.body", "source"
|
619
|
+
)
|
620
|
+
)
|
621
|
+
|
622
|
+
return [ReplaceOp(op) for op in ops]
|
623
|
+
|
453
624
|
|
454
625
|
def split_version(v):
|
455
626
|
match = re.match(r"^(\d+)\.(\d+)\.(\d+)", v)
|
@@ -482,6 +653,17 @@ class MigrateOp(ABC): # pylint: disable=R0903 # Too few public methods
|
|
482
653
|
pass
|
483
654
|
|
484
655
|
|
656
|
+
class ChangeExtensionOp(MigrateOp):
|
657
|
+
def __init__(self, path: Path, new_extension: str):
|
658
|
+
self.path = path
|
659
|
+
self.new_extension = new_extension
|
660
|
+
|
661
|
+
def __str__(self):
|
662
|
+
return f"{{ {self.path}, {self.new_extension} }}"
|
663
|
+
|
664
|
+
def apply_to(self, _lines, _offset):
|
665
|
+
self.path.rename(self.path.with_suffix(self.new_extension))
|
666
|
+
|
485
667
|
class ReplaceOp(MigrateOp):
|
486
668
|
def __init__(self, op: RefactorReplaceOp):
|
487
669
|
self.path = Path(op.source_id)
|
openplx/openplx_application.py
CHANGED
@@ -12,7 +12,7 @@ from openplxbundles import bundle_path
|
|
12
12
|
# Import useful utilities to access the current simulation, graphics root and application
|
13
13
|
from agxPythonModules.utils.environment import init_app, simulation, application, root
|
14
14
|
|
15
|
-
from openplx import InputSignalListener, OutputSignalListener, OsgClickAdapter
|
15
|
+
from openplx import InputSignalQueue, OutputSignalQueue, InputSignalListener, OutputSignalListener, OsgClickAdapter
|
16
16
|
from openplx import load_from_file, OptParams, addVisuals, addDeformableVisualUpdaters, __version__, set_log_level, add_file_changed_listener
|
17
17
|
from openplx.versionaction import VersionAction
|
18
18
|
|
@@ -21,6 +21,7 @@ def dummy_build_scene():
|
|
21
21
|
|
22
22
|
class AgxHelpAction(Action):
|
23
23
|
def __call__(self, parser, namespace, values, option_string=None):
|
24
|
+
sys.argv.append("--usage")
|
24
25
|
OpenPlxApplication(dummy_build_scene).start_agx()
|
25
26
|
sys.exit(0)
|
26
27
|
|
@@ -38,7 +39,7 @@ class OpenPlxApplication:
|
|
38
39
|
self.build_scene_file = sys.modules[self.build_scene.__module__].__file__ if build_scene_file is None else build_scene_file
|
39
40
|
|
40
41
|
@staticmethod
|
41
|
-
def
|
42
|
+
def setup_args_parser(openplxfile = None):
|
42
43
|
parser = ArgumentParser(description="View OpenPLX models", formatter_class=ArgumentDefaultsHelpFormatter)
|
43
44
|
if openplxfile is None:
|
44
45
|
parser.add_argument("openplxfile", help="the .openplx file to load")
|
@@ -58,20 +59,20 @@ class OpenPlxApplication:
|
|
58
59
|
default="info")
|
59
60
|
parser.add_argument("--modelname", help="The model to load (defaults to last model in file)", metavar="<name>", default=None)
|
60
61
|
parser.add_argument("--reload-on-update", help="Reload scene automatically when source is updated", action="store_true", default=SUPPRESS)
|
61
|
-
parser.add_argument("--
|
62
|
+
parser.add_argument("--agxhelp", help="Show AGX specific help", action=AgxHelpAction, nargs=0, default=SUPPRESS)
|
62
63
|
parser.add_argument("--version", help="Show version", action=VersionAction, nargs=0, default=SUPPRESS)
|
63
|
-
return parser
|
64
|
+
return parser
|
64
65
|
|
65
66
|
@staticmethod
|
66
|
-
def
|
67
|
-
args, extra_args = OpenPlxApplication.
|
67
|
+
def prepare_scene(openplxfile = None):
|
68
|
+
args, extra_args = OpenPlxApplication.setup_args_parser(openplxfile).parse_known_args()
|
68
69
|
set_log_level(args.loglevel)
|
69
70
|
if extra_args:
|
70
71
|
print(f"Passing these args to AGX: {(' ').join(extra_args)}")
|
71
72
|
|
72
73
|
opt_params = OptParams()
|
73
74
|
if args.modelname is not None:
|
74
|
-
opt_params.with_model_name(args.modelname)
|
75
|
+
opt_params = opt_params.with_model_name(args.modelname)
|
75
76
|
|
76
77
|
result = load_from_file(simulation(), args.openplxfile if openplxfile is None else openplxfile, args.bundle_path, opt_params)
|
77
78
|
|
@@ -79,8 +80,10 @@ class OpenPlxApplication:
|
|
79
80
|
openplx_scene = result.scene()
|
80
81
|
|
81
82
|
# Add signal listeners so that signals are picked up from inputs
|
82
|
-
|
83
|
-
|
83
|
+
input_queue = InputSignalQueue.create()
|
84
|
+
output_queue = OutputSignalQueue.create()
|
85
|
+
input_signal_listener = InputSignalListener(assembly, input_queue)
|
86
|
+
output_signal_listener = OutputSignalListener(assembly, openplx_scene, output_queue)
|
84
87
|
|
85
88
|
simulation().add(input_signal_listener, InputSignalListener.RECOMMENDED_PRIO)
|
86
89
|
simulation().add(output_signal_listener, OutputSignalListener.RECOMMENDED_PRIO)
|
@@ -97,13 +100,14 @@ class OpenPlxApplication:
|
|
97
100
|
|
98
101
|
if "enable_click" in args:
|
99
102
|
click_adapter = globals()["click_adapter"]
|
100
|
-
click_adapter.add_listeners(application(), simulation(), args.click_addr, openplx_scene,
|
103
|
+
click_adapter.add_listeners(application(), simulation(), args.click_addr, openplx_scene,
|
104
|
+
input_queue, output_queue, output_signal_listener)
|
101
105
|
|
102
106
|
if not addVisuals(result, root(), args.debug_render_frames):
|
103
107
|
application().setEnableDebugRenderer(True)
|
104
108
|
simulation().add(assembly.get())
|
105
109
|
addDeformableVisualUpdaters(result, root())
|
106
|
-
return openplx_scene
|
110
|
+
return openplx_scene, input_queue, output_queue
|
107
111
|
|
108
112
|
@staticmethod
|
109
113
|
def ctrl_break_handler(_signum, _frame):
|
@@ -123,11 +127,12 @@ class OpenPlxApplication:
|
|
123
127
|
def start_agx(self):
|
124
128
|
# Tell AGX where build_scene is located
|
125
129
|
sys.argv[0] = self.build_scene_file
|
126
|
-
# pylint: disable=W0612 # Unused variable 'init'
|
127
130
|
# Use __main__ otherwise AGX will just skip the init
|
128
|
-
|
131
|
+
# pylint: disable=unused-variable
|
132
|
+
init = init_app(name="__main__", scenes=[(self.build_scene, "1")], autoStepping=True, onShutdown=self.on_shutdown)
|
133
|
+
# pylint: enable=unused-variable
|
129
134
|
|
130
135
|
def run(self):
|
131
136
|
signal.signal(signal.SIGINT, self.ctrl_break_handler)
|
132
|
-
self.
|
137
|
+
self.setup_args_parser("").parse_known_args()
|
133
138
|
self.start_agx()
|
openplx/openplx_validate.py
CHANGED
@@ -20,11 +20,11 @@ def parse_args():
|
|
20
20
|
metavar="<bundle_path>", default=bundle_path())
|
21
21
|
parser.add_argument("--debug-render-frames", action='store_true', help="enable rendering of frames for mate connectors and rigid bodies.")
|
22
22
|
parser.add_argument("--loglevel", choices=["trace", "debug", "info", "warn", "error", "critical", "off"], help="Set log level", default="warn")
|
23
|
-
parser.add_argument("--modelname", help="The model to load (defaults to last model in file)", metavar="<name>", default=
|
23
|
+
parser.add_argument("--modelname", help="The model to load (defaults to last model in file)", metavar="<name>", default=None)
|
24
24
|
parser.add_argument("--version", help="Show version", action=VersionAction, nargs=0, default=SUPPRESS)
|
25
25
|
return parser.parse_args()
|
26
26
|
|
27
|
-
class AllowCtrlBreakListener(agxOSG.ExampleApplicationListener):
|
27
|
+
class AllowCtrlBreakListener(agxOSG.ExampleApplicationListener): # pylint: disable=too-few-public-methods
|
28
28
|
pass
|
29
29
|
|
30
30
|
def validate():
|
@@ -37,7 +37,7 @@ def validate():
|
|
37
37
|
|
38
38
|
opt_params = OptParams()
|
39
39
|
if args.modelname is not None:
|
40
|
-
opt_params.with_model_name(args.modelname)
|
40
|
+
opt_params = opt_params.with_model_name(args.modelname)
|
41
41
|
|
42
42
|
result = load_from_file(simulation, args.openplxfile, args.bundle_path, opt_params)
|
43
43
|
|
openplx/openplx_view.py
CHANGED
@@ -5,7 +5,7 @@ Command line utility that loads OpenPLX files and loads them into an AGX Simulat
|
|
5
5
|
from openplx.openplx_application import OpenPlxApplication
|
6
6
|
|
7
7
|
def openplx_view_build_scene():
|
8
|
-
OpenPlxApplication.
|
8
|
+
OpenPlxApplication.prepare_scene()
|
9
9
|
|
10
10
|
def run():
|
11
11
|
OpenPlxApplication(openplx_view_build_scene).run()
|
@@ -1,231 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: agx-openplx
|
3
|
-
Version: 0.15.0
|
4
|
-
Summary: AGX-OpenPLX python interface development
|
5
|
-
Home-page: https://pub.algoryx.dev/openplx/
|
6
|
-
License: Apache 2.0
|
7
|
-
Author: Algoryx
|
8
|
-
Author-email: algoryx@algoryx.com
|
9
|
-
Requires-Python: >=3.8
|
10
|
-
Classifier: Intended Audience :: Manufacturing
|
11
|
-
Classifier: Intended Audience :: Science/Research
|
12
|
-
Classifier: License :: Other/Proprietary License
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
15
|
-
Classifier: Programming Language :: Python :: 3.9
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
17
|
-
Classifier: Programming Language :: Python :: 3.11
|
18
|
-
Classifier: Topic :: Scientific/Engineering :: Physics
|
19
|
-
Classifier: Topic :: Scientific/Engineering :: Visualization
|
20
|
-
Requires-Dist: agx (==2.38.0.2)
|
21
|
-
Requires-Dist: openplx-bundles (>=0.15.0,<0.16.0)
|
22
|
-
Requires-Dist: pclick (>=0.4.1,<0.5.0)
|
23
|
-
Description-Content-Type: text/markdown
|
24
|
-
|
25
|
-
# AGX OpenPLX
|
26
|
-
|
27
|
-
The agx-openplx package implements all OpenPLX bundles such as Physics, Robotics, DriveTrain and Simulation using [AGX Dynamics Real-time multi-body simulation](https://www.algoryx.se/agx-dynamics/).
|
28
|
-
The package contains python bindings and native libraries needed to load and run .openplx files.
|
29
|
-
|
30
|
-
See [OpenPLX documentation](https://pub.algoryx.dev/openplx/) for more info on OpenPLX.
|
31
|
-
|
32
|
-
## Prerequisites
|
33
|
-
|
34
|
-
- Python 3.9 on Windows or OSX
|
35
|
-
- Python 3.8 on Ubuntu 20.04
|
36
|
-
- Python 3.10 on Ubuntu 22.04
|
37
|
-
- [AGX Dynamics](https://www.algoryx.se/agx-dynamics/) 2.38.0.2 and an AGX Dynamics License
|
38
|
-
|
39
|
-
At [OpenPLX documentation](https://pub.algoryx.dev/openplx/getopenplx/) you can find out which older version of OpenPLX matches which version of AGX.
|
40
|
-
|
41
|
-
## Install
|
42
|
-
|
43
|
-
To get the version corresponding to your AGX on Windows do:
|
44
|
-
|
45
|
-
```bash
|
46
|
-
setup_env.bat
|
47
|
-
pip install %AGX_DATA_DIR%/agx-pypi
|
48
|
-
pip install -U agx-openplx
|
49
|
-
```
|
50
|
-
|
51
|
-
To get the version corresponding to your AGX on OSX and Linux do:
|
52
|
-
|
53
|
-
```bash
|
54
|
-
source setup_env.sh
|
55
|
-
pip3 install $AGX_DATA_DIR/agx-pypi
|
56
|
-
pip3 install -U agx-openplx
|
57
|
-
```
|
58
|
-
|
59
|
-
## License
|
60
|
-
|
61
|
-
[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
62
|
-
|
63
|
-
## Usage Examples
|
64
|
-
|
65
|
-
Given the python file and openplx file below, run with:
|
66
|
-
|
67
|
-
```bash
|
68
|
-
python3 inverted_pendulum.py
|
69
|
-
```
|
70
|
-
|
71
|
-
To just simulate the openplx file without controllers, do:
|
72
|
-
|
73
|
-
```bash
|
74
|
-
openplx_view inverted_pendulum.openplx
|
75
|
-
```
|
76
|
-
|
77
|
-
or `python3 -m openplx.openplx_view inverted_pendulum.openplx`
|
78
|
-
|
79
|
-
Store contents below in a new file named `inverted_pendulum.openplx`:
|
80
|
-
|
81
|
-
```openplx
|
82
|
-
Rod is Physics3D.Bodies.RigidBody:
|
83
|
-
inertia.mass: 10
|
84
|
-
geometry is Physics3D.Charges.Box:
|
85
|
-
size: Math.Vec3.from_xyz(0.1, 0.1, 1)
|
86
|
-
arrow is Physics3D.Charges.Box:
|
87
|
-
local_transform:
|
88
|
-
position.z: 0.5
|
89
|
-
rotation: Math.Quat.angleAxis(Math.PI / 4, Math.Vec3.Y_AXIS())
|
90
|
-
size: Math.Vec3.from_xyz(0.071, 0.1, 0.071)
|
91
|
-
mate_connector is Physics3D.Charges.MateConnector:
|
92
|
-
position.z: -geometry.size.z * 0.7
|
93
|
-
main_axis: Math.Vec3.Y_AXIS()
|
94
|
-
normal: Math.Vec3.Z_AXIS()
|
95
|
-
|
96
|
-
Cart is Physics3D.Bodies.RigidBody:
|
97
|
-
inertia.mass: 10
|
98
|
-
geometry is Physics3D.Charges.Box:
|
99
|
-
size: Math.Vec3.from_xyz(0.1, 0.1, 0.1)
|
100
|
-
connector is Physics3D.Charges.MateConnector:
|
101
|
-
main_axis: Math.Vec3.X_AXIS()
|
102
|
-
normal: Math.Vec3.Z_AXIS()
|
103
|
-
rotated_connector is Physics3D.Charges.MateConnector:
|
104
|
-
main_axis: Math.Vec3.Y_AXIS()
|
105
|
-
normal: Math.Vec3.Z_AXIS()
|
106
|
-
|
107
|
-
PendulumScene is Physics3D.System:
|
108
|
-
world_connector is Physics3D.Charges.MateConnector:
|
109
|
-
main_axis: Math.Vec3.X_AXIS()
|
110
|
-
normal: Math.Vec3.Z_AXIS()
|
111
|
-
|
112
|
-
cart is Cart
|
113
|
-
rod is Rod
|
114
|
-
|
115
|
-
prismatic is Physics3D.Interactions.Prismatic:
|
116
|
-
charges: [world_connector, cart.connector]
|
117
|
-
|
118
|
-
cart_motor is Physics3D.Interactions.LinearVelocityMotor:
|
119
|
-
desired_speed: 0
|
120
|
-
charges: prismatic.charges
|
121
|
-
|
122
|
-
hinge is Physics3D.Interactions.Hinge:
|
123
|
-
initial_angle: 0
|
124
|
-
charges: [cart.rotated_connector, rod.mate_connector]
|
125
|
-
|
126
|
-
motor_input is Physics3D.Signals.LinearVelocityMotorVelocityInput:
|
127
|
-
motor: cart_motor
|
128
|
-
|
129
|
-
hinge_angle_output is Physics3D.Signals.HingeAngleOutput:
|
130
|
-
hinge: hinge
|
131
|
-
hinge_angular_velocity_output is Physics3D.Signals.HingeAngularVelocityOutput:
|
132
|
-
hinge: hinge
|
133
|
-
|
134
|
-
cart_position_output is Physics3D.Signals.RigidBodyPositionOutput:
|
135
|
-
rigid_body: cart
|
136
|
-
cart_velocity_output is Physics3D.Signals.RigidBodyVelocityOutput:
|
137
|
-
rigid_body: cart
|
138
|
-
```
|
139
|
-
|
140
|
-
Store contents below in a new file named `inverted_pendulum.py`:
|
141
|
-
|
142
|
-
```python
|
143
|
-
import os
|
144
|
-
import signal
|
145
|
-
import agxOSG
|
146
|
-
import agxSDK
|
147
|
-
from openplxbundles import bundle_path
|
148
|
-
|
149
|
-
# Import useful utilities to access the current simulation, graphics root and application
|
150
|
-
from agxPythonModules.utils.environment import init_app, simulation, root
|
151
|
-
|
152
|
-
from openplx import Math, Physics, Physics3D, Signals
|
153
|
-
from openplx import InputSignalListener, OutputSignalListener, load_from_file
|
154
|
-
|
155
|
-
def file_dir():
|
156
|
-
return os.path.dirname(os.path.abspath(__file__))
|
157
|
-
|
158
|
-
def pendulum():
|
159
|
-
return f"{file_dir()}/inverted_pendulum.openplx"
|
160
|
-
|
161
|
-
class PDController:
|
162
|
-
def __init__(self, kp, kd, goal):
|
163
|
-
self.kp = kp
|
164
|
-
self.kd = kd
|
165
|
-
self.goal = goal
|
166
|
-
|
167
|
-
def observe(self, x, xdot):
|
168
|
-
error = self.goal - x
|
169
|
-
return self.kp * error - self.kd * xdot
|
170
|
-
|
171
|
-
|
172
|
-
class CartController(agxSDK.StepEventListener):
|
173
|
-
motor_input: Physics3D.Signals_LinearVelocityMotorVelocityInput
|
174
|
-
cart: PDController
|
175
|
-
pole: PDController
|
176
|
-
|
177
|
-
def __init__(self, motor_input: Physics3D.Signals_LinearVelocityMotorVelocityInput):
|
178
|
-
super().__init__()
|
179
|
-
self.motor_input = motor_input
|
180
|
-
self.cart = PDController(kp=10, kd=5, goal=0)
|
181
|
-
self.pole = PDController(kp=20, kd=5, goal=0)
|
182
|
-
|
183
|
-
def pre(self, time):
|
184
|
-
if time == 0.0:
|
185
|
-
hinge_angle = 0
|
186
|
-
hinge_angular_velocity = 0
|
187
|
-
cart_position = Math.Vec3.from_xyz(0,0,0)
|
188
|
-
cart_velocity = Math.Vec3.from_xyz(0,0,0)
|
189
|
-
else:
|
190
|
-
signal_values = {signal.source().getName():signal.value().value() for signal in Signals.getOutputSignals()}
|
191
|
-
hinge_angle = signal_values["PendulumScene.hinge_angle_output"]
|
192
|
-
hinge_angular_velocity = signal_values["PendulumScene.hinge_angular_velocity_output"]
|
193
|
-
cart_position = signal_values["PendulumScene.cart_position_output"]
|
194
|
-
cart_velocity = signal_values["PendulumScene.cart_velocity_output"]
|
195
|
-
|
196
|
-
u_cart = self.cart.observe(cart_position.x(), cart_velocity.x())
|
197
|
-
u_pole = self.pole.observe(hinge_angle, hinge_angular_velocity)
|
198
|
-
|
199
|
-
Signals.sendInputSignal(Physics.Signals_RealInputSignal.create(-u_cart - u_pole, self.motor_input))
|
200
|
-
|
201
|
-
|
202
|
-
def buildScene():
|
203
|
-
|
204
|
-
result = load_from_file(simulation(), pendulum(), bundle_path(), "")
|
205
|
-
assembly = result.assembly()
|
206
|
-
openplx_scene = result.scene()
|
207
|
-
# Add a signal listener so that signals are picked up from inputs
|
208
|
-
input_signal_listener = InputSignalListener(assembly)
|
209
|
-
output_signal_listener = OutputSignalListener(assembly, openplx_scene)
|
210
|
-
simulation().add(input_signal_listener, InputSignalListener.RECOMMENDED_PRIO)
|
211
|
-
simulation().add(output_signal_listener, OutputSignalListener.RECOMMENDED_PRIO)
|
212
|
-
simulation().add(assembly.get())
|
213
|
-
agxOSG.createVisual(assembly.get(), root())
|
214
|
-
|
215
|
-
motor_input: Physics3D.Signals_LinearVelocityMotorVelocityInput = openplx_scene.getDynamic("motor_input").asObject()
|
216
|
-
controller = CartController(motor_input)
|
217
|
-
simulation().add(controller)
|
218
|
-
|
219
|
-
|
220
|
-
def handler(_, __):
|
221
|
-
os._exit(0)
|
222
|
-
|
223
|
-
signal.signal(signal.SIGINT, handler)
|
224
|
-
|
225
|
-
init = init_app(name=__name__,
|
226
|
-
scenes=[(buildScene, '1')],
|
227
|
-
autoStepping=True, # Default: False
|
228
|
-
onInitialized=lambda app: print('App successfully initialized.'),
|
229
|
-
onShutdown=lambda app: print('App successfully shut down.'))
|
230
|
-
```
|
231
|
-
|
@@ -1,41 +0,0 @@
|
|
1
|
-
openplx/Core.py,sha256=8V0Y0pJANycjq8SpFEUmqb3cNiqQbFkRI8IagtcsMFE,270043
|
2
|
-
openplx/DriveTrain.py,sha256=c7N8ivmXsfTeGnVSFaEM7-CzKpjOalZK7ZpQqxgjI1Y,418894
|
3
|
-
openplx/Math.py,sha256=kTaoNjhQSmvVHmo1WV3z9GdjNvuzPSXFW6kd-UQpJAQ,188561
|
4
|
-
openplx/Physics.py,sha256=A2TcVBtnpTh7WJjpRruH1Me70kTBKaIc2k0xCMZNtjs,1884436
|
5
|
-
openplx/Physics1D.py,sha256=wix9M9SMRvmGSPrQyCKWdMM7IqdkkVI9Vi7eyrMrfIE,345906
|
6
|
-
openplx/Physics3D.py,sha256=5YQwAXEAp-CMP8Ajqvj_QKgTj3Uvp7gWI9vyRsQ5D0A,2437851
|
7
|
-
openplx/Robotics.py,sha256=NvqWJbCpk1jDZvJJVi0PijOwOpWZm2OZGZJ1_HegNj8,798979
|
8
|
-
openplx/Simulation.py,sha256=mIuypCjz1O6c9_x4O_Ro6GLhOiXRzNlZlVjdgoGYq3U,46318
|
9
|
-
openplx/Terrain.py,sha256=9CxizkDVf9UtPIyBumenXzfbxAL6yn2G_d0_ZWbv-JY,184884
|
10
|
-
openplx/Urdf.py,sha256=JOryVyaFIROiyJ9V9OMrZAS3MoUwVmJW_2TTPSsRlH4,23780
|
11
|
-
openplx/Vehicles.py,sha256=QmtdIawHlYcIRtJH4LotXSQNs06rCpxPl6e5gklUvWg,450074
|
12
|
-
openplx/Visuals.py,sha256=lYBFzzPZvMeWaKzXQgzikmO-fuDshcgf5uCJJQ-WKTM,187052
|
13
|
-
openplx/_AgxOpenPlxPyApi.cpython-39-darwin.so,sha256=UNT_6ZHQ7CTkFJ0JV0pNqqxTHIWvfH7I7b6k_w3HkuA,12442370
|
14
|
-
openplx/_CorePythonSwig.cpython-39-darwin.so,sha256=AC1Au-yZE8eefWcZh4iQ0Oq2LWExqJswpmOLl8T_5rM,3234113
|
15
|
-
openplx/_DriveTrainSwig.cpython-39-darwin.so,sha256=S7K59t90bLKImeeDcs6pFN5dCryqv64tNesbnxHjQU4,6557505
|
16
|
-
openplx/_MathSwig.cpython-39-darwin.so,sha256=sayquEba_a8Dz4oTlrHuTJW1NqeirzqeetLbHT4YO7g,2121771
|
17
|
-
openplx/_Physics1DSwig.cpython-39-darwin.so,sha256=PJm_3eoDi4OuU6hp6FM_sDxrckT8Z0kP8pl9HjasHdM,4094304
|
18
|
-
openplx/_Physics3DSwig.cpython-39-darwin.so,sha256=h7NsNvuDGXHtL0iVsJ_kbchUnfzmoKtrCgSLEa9i-AI,16812448
|
19
|
-
openplx/_PhysicsSwig.cpython-39-darwin.so,sha256=V2snA_N-So-EKgROP1wTMP_FXwc3A3dgP-MMY_Xah_4,12399070
|
20
|
-
openplx/_RoboticsSwig.cpython-39-darwin.so,sha256=qzsEP-XNczq2XByPFPnV7Ov_0qPwbB4nFss7fq5Sk-s,9431775
|
21
|
-
openplx/_SimulationSwig.cpython-39-darwin.so,sha256=GLM3sAMVORYN_y4kMfW-sL5jkojHt-TNAyyd9-78Wm8,2310593
|
22
|
-
openplx/_TerrainSwig.cpython-39-darwin.so,sha256=bWJ0k3fM4JtS3W09lOpExQlZetx7KTMcRXRDFX1KwNY,4833198
|
23
|
-
openplx/_UrdfSwig.cpython-39-darwin.so,sha256=Uo_6kWz6hNJHI-a_oU0fbTYMvzjQkjcj-BA7mTO3FX8,3854011
|
24
|
-
openplx/_VehiclesSwig.cpython-39-darwin.so,sha256=lRCt62LggLFZGR1oF4xSDRIvipX_ChivunOLrV4TPCY,6575247
|
25
|
-
openplx/_VisualsSwig.cpython-39-darwin.so,sha256=n4R9qwQ6Y3f_1QkzJHW-8tFZgi9oilF7kOSYo5milEA,2249374
|
26
|
-
openplx/__init__.py,sha256=84JW4DGXG1xhGs6hL701s4_zXS_ksXBfgboChdrwBoE,2050
|
27
|
-
openplx/agxtoopenplx.py,sha256=gxQgZ_Pgda_5scCCBBhyu8D-jjL1yxlE7bZLtxigKCs,2422
|
28
|
-
openplx/anytoopenplx.py,sha256=qAZVnelFOVAQIpCQt3y9LlfCBHQcNmxUWXFbCZuNQUc,2274
|
29
|
-
openplx/api.py,sha256=05ECQBudlYfrMh1OgAYbq8VDsj_UlZKlPxx31RGnES0,46915
|
30
|
-
openplx/migrate.py,sha256=Lm3dyiAH-1NUV9xjtCCKOj1GldYkw5DggJM8GO_p4us,5602
|
31
|
-
openplx/migration_hint.py,sha256=2Xs2OB_HikmiynDAk4xHKhmU5N4pqOnPFPpeIWhK37Y,603
|
32
|
-
openplx/migrations.py,sha256=-j9it2oNK0A4Z-PCPyXRE0UYdU4kMpbVEVoEIjGxkFA,15094
|
33
|
-
openplx/openplx_application.py,sha256=VDSsIGCDay8__omhsdKkSRaqmvY_vH6yLHQr3fTzyzA,6346
|
34
|
-
openplx/openplx_serialize.py,sha256=Uul2-6_BwyJzg26JdgAz2MjR37mQJ6kWKjPbmE-sJzk,1456
|
35
|
-
openplx/openplx_validate.py,sha256=pqBg9WBh7OUi63dOmmCpDWt_jTn8OhCSmtgL-nmb1XY,2055
|
36
|
-
openplx/openplx_view.py,sha256=nUca0BVnTTcCzGoj8q2f3QVmZFpKd3PPptjuKqoHA18,350
|
37
|
-
openplx/versionaction.py,sha256=Obj_q69dn5GnFMZs2as87ZScPMLaLAduPppmXUzLB6I,283
|
38
|
-
agx_openplx-0.15.0.dist-info/METADATA,sha256=n0lbchTEYxII_StBn_BQjEzYA-X-z40E8jL7Yk8mfBg,7824
|
39
|
-
agx_openplx-0.15.0.dist-info/WHEEL,sha256=O5AT1Qb1jPpISLjIwxiRxhUaN9TX1BFXuc9iRVvoPmk,104
|
40
|
-
agx_openplx-0.15.0.dist-info/entry_points.txt,sha256=IyHBVBNuH_4ZhfWnB1ZVXYtpKG_QT7dwGIUMLWdyhrc,263
|
41
|
-
agx_openplx-0.15.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|