virtroom

package
v0.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0

README

physics virtual room navigation

This demo shows how to construct and visualize a physics model of a simple virtual room environment, with a virtual robot ("emer") having a first-person view of the world.

You can hold down the motion buttons in the toolbar to move the robot around more easily.

Use -nogui arg to run in no GUI mode (purely offscreen mode, e.g., for batch-mode running), which saves a .png image of the starting view, in eyer_0.png.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emer

type Emer struct {
	// if true, emer is angry: changes face color
	Angry bool

	// VestibHRightEar is the horizontal rotation vestibular signal measured
	// at the right ear, averaged over the steps.
	VestibHRightEar float32

	// full height of emer
	Height float32

	// emer object
	Obj *builder.Object `display:"-"`

	// PlaneXZ joint for controlling 2D position.
	XZ *builder.Joint

	// ball joint for the neck.
	Neck *builder.Joint

	// Right eye of emer
	EyeR *builder.Body `display:"-"`
}

Emer is the robot agent in the environment.

func (*Emer) Defaults

func (em *Emer) Defaults()

type Env

type Env struct {

	// Emer state
	Emer Emer `new-window:"+"`

	// Stiffness for actions
	Stiff float32

	// how far to move every step
	MoveStep float32

	// how far to rotate every step
	RotStep float32

	// number of model steps to take
	ModelSteps int

	// width of room
	Width float32

	// depth of room
	Depth float32

	// height of room
	Height float32

	// thickness of walls of room
	Thick float32

	// current depth map
	DepthVals []float32

	// offscreen render camera settings
	Camera phyxyz.Camera

	// color map to use for rendering depth map
	DepthMap core.ColorMapName

	// The core physics elements: Model, Builder, Scene
	Physics builder.Physics

	// 3D visualization of the Scene
	SceneEditor *xyzcore.SceneEditor

	// snapshot image
	EyeRImg *core.Image `display:"-"`

	// depth map image
	DepthImage *core.Image `display:"-"`
}

Env encapsulates the virtual environment

func (*Env) ConfigGUI

func (ev *Env) ConfigGUI(b tree.Node)

func (*Env) ConfigView3D

func (ev *Env) ConfigView3D(sc *xyz.Scene)

ConfigView3D makes the 3D view

func (*Env) Defaults

func (ev *Env) Defaults()

func (*Env) GrabEyeImage

func (ev *Env) GrabEyeImage()

GrabEyeImage takes a snapshot from the perspective of Emer's right eye

func (*Env) InitState

func (ev *Env) InitState()

Initstate reinitializes the physics model state.

func (*Env) MakeEmer

func (ev *Env) MakeEmer(wl *builder.World, em *Emer, name string)

MakeEmer constructs a new Emer virtual robot of given height (e.g., 1).

func (*Env) MakeModel

func (ev *Env) MakeModel(sc *xyz.Scene)

func (*Env) MakeRoom

func (ev *Env) MakeRoom(wl *builder.World, name string, width, depth, height, thick float32)

MakeRoom constructs a new room with given params

func (*Env) MakeToolbar

func (ev *Env) MakeToolbar(p *tree.Plan)

func (*Env) ModelStep

func (ev *Env) ModelStep()

ModelStep does one step of the physics model.

func (*Env) NoGUIRun

func (ev *Env) NoGUIRun()

func (*Env) RenderEyeImg

func (ev *Env) RenderEyeImg() image.Image

RenderEyeImg returns a snapshot from the perspective of Emer's right eye

func (*Env) RotBodyLeft

func (ev *Env) RotBodyLeft()

RotBodyLeft rotates emer left.

func (*Env) RotBodyRight

func (ev *Env) RotBodyRight()

RotBodyRight rotates emer right.

func (*Env) RotHeadLeft

func (ev *Env) RotHeadLeft()

RotHeadLeft rotates emer left.

func (*Env) RotHeadRight

func (ev *Env) RotHeadRight()

RotHeadRight rotates emer right.

func (*Env) Sensors

func (ev *Env) Sensors()

Sensors reads sensors at various key points on body.

func (*Env) StepBackward

func (ev *Env) StepBackward()

StepBackward moves Emer backward in current facing direction one step.

func (*Env) StepForward

func (ev *Env) StepForward()

StepForward moves Emer forward in current facing direction one step

func (*Env) UpdateView

func (ev *Env) UpdateView()

UpdateView tells 3D view it needs to update.

func (*Env) ViewDepth

func (ev *Env) ViewDepth(depth []float32)

ViewDepth updates depth bitmap with depth data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL