Created
January 13, 2026 08:36
-
-
Save hovsep/4035de8e27c4498c7880f1d7c1274c2b to your computer and use it in GitHub Desktop.
human body sim custom commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // setMeshCommands sets the commands that can be executed on the mesh | |
| func setMeshCommands(mesh *fmesh.FMesh, commands step_sim.MeshCommandMap) { | |
| timeComponent := mesh.ComponentByName("time") | |
| // Print current time | |
| commands["time:now"] = step_sim.NewMeshCommandDescriptor("Print current time", func(_ *fmesh.FMesh) { | |
| tickCount := timeComponent.State().Get("tick_count") | |
| simTime := timeComponent.State().Get("sim_time") | |
| simWallTime := timeComponent.State().Get("sim_wall_time") | |
| fmt.Println("Current tick count:", tickCount) | |
| fmt.Println("Simulation duration:", simTime) | |
| fmt.Println("Simulation wall-clock time:", simWallTime) | |
| }) | |
| // Print habitat state | |
| commands["habitat:show"] = step_sim.NewMeshCommandDescriptor("Print habitat state", func(fm *fmesh.FMesh) { | |
| temperature := fm.ComponentByName("air").State().Get("temperature") | |
| fmt.Println("Current air temperature: ", temperature) | |
| }) | |
| // Increase temperature | |
| commands["temp:inc"] = step_sim.NewMeshCommandDescriptor("Increase air temperature by 1.0 degree", func(fm *fmesh.FMesh) { | |
| fm.ComponentByName("air").Inputs().ByName("ctl").PutSignals(signal.New(+1.0).AddLabel("cmd", "change_temperature")) | |
| }) | |
| // Decrease temperature | |
| commands["temp:dec"] = step_sim.NewMeshCommandDescriptor("Decrease air temperature by 1.0 degree", func(fm *fmesh.FMesh) { | |
| fm.ComponentByName("air").Inputs().ByName("ctl").PutSignals(signal.New(-1.0).AddLabel("cmd", "change_temperature")) | |
| }) | |
| // Set the temperature to zero | |
| commands["temp:zero"] = step_sim.NewMeshCommandDescriptor("Set air temperature to zeo degrees", func(fm *fmesh.FMesh) { | |
| mesh.ComponentByName("air").Inputs().ByName("ctl").PutSignals(signal.New(0.0).AddLabel("cmd", "set_temperature")) | |
| }) | |
| // Make the air hot | |
| commands["temp:hot"] = step_sim.NewMeshCommandDescriptor("Set air temperature to +38.0", func(fm *fmesh.FMesh) { | |
| mesh.ComponentByName("air").Inputs().ByName("ctl").PutSignals(signal.New(+38.0).AddLabel("cmd", "set_temperature")) | |
| }) | |
| // Make the air cold | |
| commands["temp:cold"] = step_sim.NewMeshCommandDescriptor("Set air temperature to -35.0", func(fm *fmesh.FMesh) { | |
| mesh.ComponentByName("air").Inputs().ByName("ctl").PutSignals(signal.New(-35.0).AddLabel("cmd", "set_temperature")) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment