Skip to content

Commit

Permalink
wheels and mass
Browse files Browse the repository at this point in the history
  • Loading branch information
MikhailChaikovskii committed Aug 7, 2024
1 parent 0f7b363 commit 8a8bbb8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions examples/biped.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from rostok.library.rule_sets.ruleset_simple_wheels import get_four_wheels
from rostok.graph_grammar.graph_utils import plot_graph

scenario = WalkingScenario(0.0001, 3)
scenario = WalkingScenario(0.0001, 10)

#graph = get_biped()
graph = get_four_wheels()
#plot_graph(graph)
control = control_parameters = {"initial_value": [0.02]*12}
control = control_parameters = {"initial_value": [0.01]*4}

scenario.run_simulation(graph, control, starting_positions=None, vis = True, delay=True)
scenario.run_simulation(graph, control, starting_positions=[ [30,-30,0], [30,-30,0], [-30, 30,0], [-30,30,0] ], vis = True, delay=True)
2 changes: 2 additions & 0 deletions rostok/block_builder_api/block_blueprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class RevolveJointBlueprint(JointBlueprintType):
stiffness: float = 0.
damping: float = 0.
equilibrium_position:float = 0.
stopper: Optional[list[float]] = None


class RevolveJointBlueprintWithBody(JointBlueprintType):
Expand All @@ -61,6 +62,7 @@ class RevolveJointBlueprintWithBody(JointBlueprintType):
offset: float = 0.
equilibrium_position:float = 0.
with_collision: bool = True
stopper: Optional[list[float]] = None


@dataclass
Expand Down
25 changes: 12 additions & 13 deletions rostok/library/rule_sets/ruleset_simple_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def rotation_y(alpha):
quat_Y_ang_alpha = chrono.Q_from_AngY(np.deg2rad(alpha))
return [quat_Y_ang_alpha.e0, quat_Y_ang_alpha.e1, quat_Y_ang_alpha.e2, quat_Y_ang_alpha.e3]


def rotation_z(alpha):
quat_Z_ang_alpha = chrono.Q_from_AngZ(np.deg2rad(alpha))
return [quat_Z_ang_alpha.e0, quat_Z_ang_alpha.e1, quat_Z_ang_alpha.e2, quat_Z_ang_alpha.e3]
Expand All @@ -40,13 +39,13 @@ def create_rules(smc=False):
def_mat = DefaultChronoMaterialNSC()
# blueprint for the palm
main_body = PrimitiveBodyBlueprint(
Box(0.5, 0.1, 0.3), material=def_mat, color=[255, 0, 0])
Box(0.5, 0.1, 0.3), material=def_mat, color=[255, 0, 0], density=1000)

wheel_body = PrimitiveBodyBlueprint(
Cylinder(0.05, 0.03), material=def_mat, color=[0, 120, 255])
Cylinder(0.03, 0.01), material=def_mat, color=[0, 120, 255], density=1000)

# blueprint for the base
base = PrimitiveBodyBlueprint(Box(0.03, 0.01, 0.03),
base = PrimitiveBodyBlueprint(Box(0.02, 0.03, 0.02),
material=def_mat,
color=[120, 120, 0],
density=1000)
Expand All @@ -56,11 +55,11 @@ def create_rules(smc=False):
# create link blueprints using mass and length parameters
link = list(
map(
lambda x: PrimitiveBodyBlueprint(Box(0.035, x, 0.027),
lambda x: PrimitiveBodyBlueprint(Box(0.02, x, 0.02),
material=def_mat,
color=[0, 120, 255],
density=get_density_box(link_mass, Box(
0.035, x, 0.027))), length_link))
0.02, x, 0.02))), length_link))


x_translation_values = [0.07, 0.107, 0.144]
Expand Down Expand Up @@ -97,16 +96,16 @@ def create_rules(smc=False):
map(lambda x: TransformBlueprint(x), TURNS_NEGATIVE))


stiffness__values_base = [0.19, 0.095, 0.07]
stiffness__values_base = [0.9, 0.095, 0.07]
preload_angle_values_base = [0, 0, 0]
no_control_base = list(
map(
lambda x, y: RevolveJointBlueprint(JointInputType.UNCONTROL,
stiffness=x,
damping=0.01,
damping=0.02,
equilibrium_position=y), stiffness__values_base,
preload_angle_values_base))
revolve = RevolveJointBlueprint(JointInputType.TORQUE, stiffness=0, damping=0)
revolve = RevolveJointBlueprint(JointInputType.TORQUE, stiffness=0, damping=0.0)
# Nodes
node_vocab = NodeVocabulary()
node_vocab.add_node(ROOT)
Expand Down Expand Up @@ -140,7 +139,7 @@ def create_rules(smc=False):
node_vocab.create_node(label="NZT0", is_terminal=True,block_blueprint=z_translation_negative_transforms[0])
node_vocab.create_node(label="NZT1", is_terminal=True,block_blueprint=z_translation_negative_transforms[1])
node_vocab.create_node(label="NZT2", is_terminal=True,block_blueprint=z_translation_negative_transforms[2])
node_vocab.create_node(label="J", is_terminal=True, block_blueprint=revolve)
node_vocab.create_node(label="J", is_terminal=True, block_blueprint=no_control_base[0])

for i, bp in enumerate(link):
node_vocab.create_node(label=f"L{i}", is_terminal=True, block_blueprint=bp)
Expand Down Expand Up @@ -198,9 +197,9 @@ def get_four_wheels():
graph = GraphGrammar()
rules = ["Init",
'Add_FR_W',"Extension","Extension","Wheel",'Terminal_Positive_XTranslate_2', "Terminal_Positive_ZTranslate_1","Terminal_Link2","Terminal_Link1",
"Add_FL_W", 'Terminal_Positive_XTranslate_2', "Terminal_Negative_ZTranslate_2","Wheel",
"Add_BR_W", 'Terminal_Negative_XTranslate_2', "Terminal_Positive_ZTranslate_1","Wheel",
"Add_BL_W", 'Terminal_Negative_XTranslate_2', "Terminal_Negative_ZTranslate_2","Wheel"
"Add_FL_W", "Extension","Extension",'Terminal_Positive_XTranslate_2', "Terminal_Negative_ZTranslate_1","Wheel", "Terminal_Link2","Terminal_Link1",
"Add_BR_W", "Extension","Extension",'Terminal_Negative_XTranslate_2', "Terminal_Positive_ZTranslate_1","Wheel", "Terminal_Link2","Terminal_Link1",
"Add_BL_W", "Extension","Extension",'Terminal_Negative_XTranslate_2', "Terminal_Negative_ZTranslate_1","Wheel", "Terminal_Link2","Terminal_Link1",
]
rule_vocabul = create_rules()
for rule in rules:
Expand Down
4 changes: 2 additions & 2 deletions rostok/simulation_chrono/simulation_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def run_simulation(self,
def_mat = DefaultChronoMaterialSMC()
else:
def_mat = DefaultChronoMaterialNSC()
floor = creator.create_environment_body(EnvironmentBodyBlueprint(Box(1, 0.1, 1), material=def_mat, color=[215, 255, 0]))
floor = creator.create_environment_body(EnvironmentBodyBlueprint(Box(10, 0.1, 10), material=def_mat, color=[215, 255, 0]))
floor.body.SetNameString("Floor")
floor.body.SetPos(chrono.ChVectorD(0,-0.05,0))
#floor.body.GetVisualShape(0).SetTexture("/home/yefim-work/Packages/miniconda3/envs/rostok/share/chrono/data/textures/bluewhite.png", 10, 10)
Expand All @@ -202,7 +202,7 @@ def run_simulation(self,
simulation.add_design(graph,
controller_data,
self.controller_cls,
Frame=FrameTransform([0, 0.2, 0], [0,0,0,1]),
Frame=FrameTransform([0, 0.25, 0], [0,0,0,1]),
starting_positions=starting_positions, is_fixed=False)

# setup parameters for the data store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DefaultChronoMaterialNSC(Material):
name: str = "default_NSC"
type_class: str = "ChMaterialSurfaceNSC"
Friction:float = 0.5
Restitution:float = 0.15
Restitution:float = 0.75
Compliance: float = 1e-6
ComplianceT: float = 1e-6
DampingF:float = 1e6
Expand Down

0 comments on commit 8a8bbb8

Please sign in to comment.