Skip to content

Commit

Permalink
Merge branch 'master' into article_3events_and_criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailChaikovskii committed Oct 16, 2023
2 parents b736aed + 218337d commit 6970e36
Show file tree
Hide file tree
Showing 11 changed files with 515 additions and 127 deletions.
11 changes: 10 additions & 1 deletion app/mcts_run_setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from copy import deepcopy

import hyperparameters as hp

from rostok.control_chrono.tendon_controller import TendonControllerParameters
Expand All @@ -14,6 +16,9 @@
from rostok.trajectory_optimizer.control_optimizer import (
CalculatorWithOptimizationDirect, TendonOptimizerCombinationForce)
from rostok.utils.numeric_utils import Offset
from rostok.trajectory_optimizer.control_optimizer import (CalculatorWithGraphOptimization,
CalculatorWithOptimizationDirect)
import rostok.control_chrono.external_force as f_ext


def config_independent_torque(grasp_object_blueprint):
Expand Down Expand Up @@ -69,7 +74,11 @@ def config_independent_torque(grasp_object_blueprint):
def config_with_tendon(grasp_object_blueprint):
# configurate the simulation manager

simulation_manager = GraspScenario(hp.TIME_STEP_SIMULATION, hp.TIME_SIMULATION)
obj_forces = []
obj_forces.append(f_ext.NullGravity(0))
obj_forces.append(f_ext.RandomForces(1e6, 100, 0))
obj_forces = f_ext.ExternalForces(obj_forces)
simulation_manager = GraspScenario(hp.TIME_STEP_SIMULATION, hp.TIME_SIMULATION, obj_external_forces=obj_forces)
simulation_manager.grasp_object_callback = grasp_object_blueprint #lambda: creator.create_environment_body(
#grasp_object_blueprint)
event_contact = EventContact()
Expand Down
11 changes: 9 additions & 2 deletions rostok/block_builder_api/easy_body_shapes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from pathlib import Path
from typing import Union

Expand Down Expand Up @@ -34,6 +34,13 @@ class Ellipsoid:
class FromMesh:
path: Path

@dataclass
class ConvexHull:
points: list[tuple[float, float, float]] = field(default_factory=list)

def __hash__(self) -> int:
return hash(("ConvexHull", self.points))


# All types of shape
ShapeTypes = Union[Box, Cylinder, Sphere, Ellipsoid, FromMesh]
ShapeTypes = Union[Box, Cylinder, Sphere, Ellipsoid, FromMesh, ConvexHull]
9 changes: 9 additions & 0 deletions rostok/block_builder_chrono/block_comprehension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rostok.block_builder_chrono.block_builder_chrono_api import \
ChronoBlockCreatorInterface


def calc_volume_body(blueprint):
"""Calculate the volume of the body."""
body = ChronoBlockCreatorInterface.init_block_from_blueprint(blueprint)
volume = body.body.GetMass() / body.body.GetDensity()
return volume
6 changes: 3 additions & 3 deletions rostok/control_chrono/control_utils.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from dataclasses import dataclass, field

from rostok.control_chrono.external_force import ForceControllerTemplate
from rostok.control_chrono.external_force import ForceChronoWrapper


@dataclass
class ForceTorqueContainer:
controller_list: list[ForceControllerTemplate] = field(default_factory=list)
controller_list: list[ForceChronoWrapper] = field(default_factory=list)

def update_all(self, time: float, data=None):
for i in self.controller_list:
i.update(time, data)

def add(self, controller: ForceControllerTemplate):
def add(self, controller: ForceChronoWrapper):
if controller.is_bound:
self.controller_list.append(controller)
else:
Expand Down
Loading

0 comments on commit 6970e36

Please sign in to comment.