Public Interfaces

Managers

RoboyManager

class RoboyManager

Roboymanager has different tasks:

- Run ROS:

  1. Connect to the simulation.
  2. Add subscriber to the pose.
  3. Add publisher for external force.
  4. Add service response for world reset.

- Receive and send ROS messages:

  1. receive pose msg to adjust roboy pose.
  2. subscribe to external force event and send msg to simulation.
  3. send service call for world reset.
  4. FUTURE: receive motor msg and forward it to the according motors.

Inherits from Singleton< RoboyManager >

Public Functions

void RoboyManager.InitializeRoboyParts()

Initializes the roboy parts with a random count of motors => WILL BE CHANGED IN THE FUTURE, for now just a template

void RoboyManager.ReceiveMessage(RoboyPoseMsg msg)

Main function to receive messages from ROSBridge.

Adjusts the roboy pose and the motors values (future).

Parameters
  • msg: JSON msg containing roboy pose.

void RoboyManager.ReceiveExternalForce(RoboyPart roboyPart, Vector3 position, Vector3 force, int duration)

Sends a message to the simualation to apply an external force on a certain position.

Parameters
  • roboyPart: The roboypart where the force should be applied.
  • position: The relative position of the force to the roboypart.
  • force: The direction and the amount of force relative to roboypart.
  • duration: The duration for which the force should be applied.

Public Members

string RoboyManager.VM_IP = ""

The IP address of the VM or the machine where the simulation is running

Transform RoboyManager.Roboy

Transform of roboy with all roboy parts as child objects

Property

property RoboyManager::RoboyParts

Public variable for the dictionary with all roboyparts, used to adjust pose and motor values

Private Functions

void RoboyManager.Awake()

Initialize ROSBridge and roboy parts

void RoboyManager.Update()

Run ROSBridge

void RoboyManager.OnApplicationQuit()

Disconnect from the simulation when Unity is not running.

Quaternion RoboyManager.gazeboRotationToUnity(Quaternion gazeboRot)

Converts a quaternion in gazebo coordinate frame to unity coordinate frame.

Return
Quaternion in unity coordinate frame.
Parameters
  • gazeboRot: Quaternion in gazebo coordinate frame.

Vector3 RoboyManager.gazeboPositionToUnity(Vector3 gazeboPos)

Converts a vector in gazebo coordinate frame to unity coordinate frame.

Return
Vector in unity coordinate frame.
Parameters
  • gazeboPos: Vector in gazebo coordinate frame.

Vector3 RoboyManager.unityPositionToGazebo(Vector3 unityPos)

Converts a vector in unity coordinate frame to gazebo coordinate frame.

Return
Vector in gazebo coordinate frame.
Parameters
  • unityPos: Vector in unity coordinate frame.

Quaternion RoboyManager.unityRotationToGazebo(Quaternion unityRot)

Converts a quaternion in unity coordinate frame to gazebo coordinate frame.

Return
Quaternion in gazebo coordinate frame.
Parameters
  • unityRot: Quaternion in unity coordinate frame.

void RoboyManager.drawTendons()

Test function to draw tendons.

For now draws only random lines. TEMPLATE!

void RoboyManager.adjustPose(RoboyPoseMsg msg)

Adjusts roboy pose for all parts with the values from the simulation.

Parameters
  • msg: JSON msg containing the roboy pose.

Private Members

ROSBridgeWebSocketConnection RoboyManager.m_Ros = null

ROSBridge websocket

RoboyPoseMsg RoboyManager.m_RoboyPoseMessage

Pose message of roboy in our build in class

Dictionary<string, RoboyPart> RoboyManager.m_RoboyParts = new Dictionary<string, RoboyPart>()

Dictionary with all roboyparts, used to adjust pose and motor values

InputManager

class InputManager

InputManager holds a reference of every tool.

On top of that it listens to button events from these tools and forwards touchpad input to the respective classes.

Inherits from Singleton< InputManager >

Public Types

enum TouchpadStatus

Possible touchpad positions.

Values:

Right
Left
Top
Bottom
None

Public Functions

void InputManager.GUIControllerSideButtons(object sender, ClickedEventArgs e)

Changes view mode when the user presses the side button on the controller.

Parameters
  • sender
  • e

void InputManager.ToolControllerSideButtons(object sender, ClickedEventArgs e)

Changes the tool when the user presses the side button on the controller.

Parameters
  • sender
  • e

void InputManager.GetTouchpadInput(object sender, ClickedEventArgs e)

Retrives the touchpad input of the tool controller and updates the values.

Parameters
  • sender
  • e

Property

property InputManager::GUI_Controller

Public GUIController reference.

property InputManager::Selector_Tool

Public SelectorTool reference.

property InputManager::ShootingTool

Public ShootingTool reference.

property InputManager::TimeTool

Public TimeTool reference.

property InputManager::SelectorTool_TouchpadStatus

Touchpad status of the controller where selector tool is attached to.

property InputManager::GUIController_TouchpadStatus

Touchpad status of the controller where gui controller tool is attached to.

Private Functions

void InputManager.Start()

Initialize all tools.

void InputManager.Update()

Calls the ray cast from the selector tool if it is active.

IEnumerator InputManager.InitControllers()

Initializes all controllers and tools.

Return

Private Members

SelectorTool InputManager.m_SelectorTool

Private SelectorTool reference.

Is serialized so it can be dragged in the editor.

ShootingTool InputManager.m_ShootingTool

Private ShootingTool reference.

Is serialized so it can be dragged in the editor.

TimeTool InputManager.m_TimeTool

Private TimeTool reference.

Is serialized so it can be dragged in the editor.

GUIController InputManager.m_GUIController

Private GUIController reference.

Is serialized so it can be dragged in the editor.

ModeManager

class ModeManager

ModeManager holds a reference of every active mode and provides function to switch between them.

This includes:

  • Current tool: ShootingTool, SelectionTool etc.
  • Current view mode: singe vs. comparison
  • Current GUI mode: selection vs. GUI panels
  • Current panel mode: motorforce, motorvoltage etc.

Inherits from Singleton< ModeManager >

Public Types

enum Viewmode

We change between Single view where we can choose only one objet at a time and comparison view with three maximum objects at a time.

Values:

Single
Comparison
enum Panelmode

Describes the different modes for panel visualization.

Values:

Motor_Force
Motor_Voltage
Motor_Current
Energy_Consumption
Tendon_Forces
enum GUIMode

Enum for current GUI mode.

Values:

Selection
GUIPanels
enum ToolMode

SelectorTool: Select roboy meshes.

ShooterTool: Shoot projectiles at roboy. TimeTool: Reverse/stop time.

Values:

SelectorTool
ShooterTool
TimeTool

Public Functions

void ModeManager.ChangeViewMode()

Changes between single and comparison view.

void ModeManager.ChangeGUIMode()

Switches between selection and panels GUI mode.

void ModeManager.ChangeToolMode()

Switches between all tools.

void ModeManager.ChangePanelModeNext()

Changes the panel mode to the next one based on the order in the enum defintion.

void ModeManager.ChangePanelModePrevious()

Changes the panel mode to the previous one based on the order in the enum defintion.

void ModeManager.ResetPanelMode()

Resets current panel mode to MotorForce.

Property

property ModeManager::CurrentViewmode

Current view mode, READ ONLY.

property ModeManager::CurrentPanelmode

Current panel mode, READ ONLY.

property ModeManager::CurrentGUIMode

Current GUI mode, READ ONLY.

property ModeManager::CurrentToolMode

Current Tool mode, READ ONLY.

Private Members

Viewmode ModeManager.m_CurrentViewmode = Viewmode.Comparison

Private variable for current view mode.

Panelmode ModeManager.m_CurrentPanelmode = Panelmode.Motor_Force

Private variable for current panel mode.

GUIMode ModeManager.m_CurrentGUIMode = GUIMode.Selection

Private variable for current GUI mode.

ToolMode ModeManager.m_CurrentToolMode = ToolMode.SelectorTool

Private variable for current Tool mode.

SelectorManager

class SelectorManager

SelectorManager is responsible to hold references of all selected roboy parts and the corresponding UI elements.

Inherits from Singleton< SelectorManager >

Public Functions

void SelectorManager.AddSelectedObject(SelectableObject obj)

Adds the roboy part to selected objects.

Parameters

void SelectorManager.RemoveSelectedObject(SelectableObject obj)

Removes the roboy part from the selected objects.

Parameters

void SelectorManager.ResetSelectedObjects()

Resets all roboy parts to default state and empties the selected objects list.

Property

property SelectorManager::UI_Elements

Property which returns a dictionary of all UI elements in the SelectionPanel.

property SelectorManager::SelectedParts

Reference of all currently selected roboy parts.

property SelectorManager::MaximumSelectableObjects

Integer to switch between single mode selection and normal mode collection.

Private Functions

IEnumerator SelectorManager.Start()

Initializes all variables.

Return

Private Members

Transform SelectorManager.m_Roboy

Transform of roboy model.

List<SelectableObject> SelectorManager.m_RoboyParts = new List<SelectableObject>()

List of SelectableObject components of all roboy parts.

List<SelectableObject> SelectorManager.m_SelectedParts = new List<SelectableObject>()

List of SelectableObject components of all selected parts.

int SelectorManager.m_MaximumSelectableObjects = 3

Maximum cound of selectable objects in multiple selection mode.

int SelectorManager.m_CurrentMaximumSelectedObjects = 3

Current count of maximum selectable objects.

Dictionary<string, GameObject> SelectorManager.m_UI_Elements = new Dictionary<string, GameObject>()

Private reference to all UI elements.

Material SelectorManager.m_UI_Line_Material

I am not sure what this is.

Will be deleted soon.

Tools

ControllerTool

class ControllerTool

ControllerTool is a base class for all tools which are attached to a controller.

It provides access to steamVR functions to track the input of the controllers. On top of that it provides a function to vibrate the controller for a defined time.

Inherits from MonoBehaviour

Subclassed by SelectorTool, ShootingTool

Public Functions

void ControllerTool.Vibrate()

Starts a coroutine to vibrate the controller for a fixed time.

void ControllerTool.Initialize()

Initiliazes the controller in a coroutine.

Intermediate function for outside classes.

Property

property ControllerTool::Controller

Returns the controller identity for verification purposes for outside classes.

property ControllerTool::ControllerEventListener

Returns a component which listens to controller events like OnTouchpad.

Private Functions

void ControllerTool.Awake()

Calls initialize for all controller members.

IEnumerator ControllerTool.vibrateController()

Coroutine to vibrate the controller for a fixed time.

Return

IEnumerator ControllerTool.initializeCoroutine()

Coroutine to initialize all controller members.

Return

SelectorTool

class SelectorTool

SelectorTool provides a functionality to select parts of roboy on the mesh itself or through the GUI.

Inherits from ControllerTool

Public Functions

void SelectorTool.GetRayFromController()

Starts a ray from the controller.

If the ray hits a roboy part, it changes its selection status. Otherwise it resets the last selected/targeted roboy part.

Private Functions

void SelectorTool.Start()

Initializes the lineRenderer component.

Private Members

LineRenderer SelectorTool.m_LineRenderer

LineRenderer to draw the laser for selection.

SelectableObject SelectorTool.m_LastSelectedObject

Variable to track the last selected object for comparison.

float SelectorTool.m_RayDistance = 3f

Maximum ray length for selection.

ShootingTool

class ShootingTool

ShootingTool is used to shoot a projectile on roboy.

The projectile then triggers a ROS message to send an external force to the simulation.

Inherits from ControllerTool

Public Members

Projectile ShootingTool.ProjectilePrefab

Projectile prefab which is responsible to send the ROS message.

Transform ShootingTool.SpawnPoint

Spawn transform to retrieve the spawn position and direction.

Transform ShootingTool.Trigger

Trigger transform for trigger animation.

Transform ShootingTool.TriggerBack

Transform of the position when trigger is fully pressed.

float ShootingTool.ShootDelay = 0.5f

Reload time between shots.

Private Functions

void ShootingTool.Start()

Initializes trigger position.

void ShootingTool.Update()

Shoots when the user presses the trigger to maximum value if shooting is not on cooldown.

void ShootingTool.Shoot()

Instantiates a projectile prefab on the SpawnPoint.

void ShootingTool.animateTrigger()

Animates trigger based on current trigger value.

Private Members

Vector3 ShootingTool.m_InitTriggerPosition

The standard trigger position.

float ShootingTool.m_CurrentShootCooldown = 0f

Variable for tracking current shooting cooldown.

GUIController

class GUIController

GUIController is attached on another controller as the Tools like ShootingTool or SelectorTool.

It is mainly responsible for animating so the following tasks refer always to animation:

  • manage the switch between selection mode and panel mode
  • manage switch between different panel modes
  • manage page switch inside a panel mode NOTICE: Right now GUIController is not inheriting from ControllerTool as we implemented this script at the beginning of the project. This will be changed soon, so be aware that this documentation could be out of date!

Inherits from MonoBehaviour

Public Types

enum UIPanelAlignment

Enum for possible panel alignments.

Values:

Left
Top
Right

Public Functions

void GUIController.CheckTouchPad(InputManager.TouchpadStatus touchpadStatus)

Checks the touchpad input of the controller and acts accordingly:

  1. Left: changes to previous panel if in panel mode
  2. Right: changes to next panel if in panel mode
  3. Top: changes between GUI modes
  4. Bottom: changes the page of the current panel if in panel mode

Parameters
  • touchpadStatus

void GUIController.InitializePanels()

Initialize the position of all panels and set their corresponding roboy part reference.

Public Members

UIPanelRoboyPart GUIController.UIPanelRoboyPartPrefab

Prefab variable for a roboy UI panel.

Property

property GUIController::Controller

Public variable for outside classes to track input.

property GUIController::ControllerEventListener

Public variable for outside classes to track controller events.

property GUIController::UIFadePanels

Property which holds a dictionary to store a reference to the standard position of panels in panel mode.

Private Functions

void GUIController.Start()

Initializes the controller variables.

Intializes the UI Panels and creates them for every roboy part for every panel mode.

void GUIController.changePageOfPanel()

Changes the page of the current panel if the current GUI mode is set to panel mode.

void GUIController.changepanelsToNextMode()

Changes to the next panel if the current GUI mode if set to panel mode.

void GUIController.changeToPreviousMode()

Changes to the previous panel if the current GUI mode if set to panel mode.

IEnumerator GUIController.changeGUIMode()

Changes GUI mode between selection and panel mode.

Return

void GUIController.positionPanels()

Positions the panels according to the template panel positions in the editor.

Private Members

SteamVR_Controller.Device GUIController.m_SteamVRDevice

Private variable to track controller input.

SteamVR_TrackedObject GUIController.m_SteamVRController

Private variable to track controller identity.

SteamVR_TrackedController GUIController.m_SteamVRTrackedController

Private variable to track controller events.

Dictionary<RoboyPart, UIPanelRoboyPart> GUIController.m_RoboyPartPanelsDic = new Dictionary<RoboyPart, UIPanelRoboyPart>()

Dictionary to store a reference to all UI Panels which are created at the start of the scene.

Dictionary<UIPanelAlignment, FadePanelStruct> GUIController.m_UIFadePanels = new Dictionary<UIPanelAlignment, FadePanelStruct>()

Dictionary to store a reference to the standard position of panels in panel mode.

SelectionPanel GUIController.m_SelectionPanel

Reference to the SelectionPanel.

struct FadePanelStruct

Struct to store the position where a panel should fade in and out.

Additional classes

SelectableObject

class SelectableObject

SelectableObject is attached on every roboy part.

Is used to switch between selection states, which then again changes the material and manages GUI highlighting.

Inherits from MonoBehaviour

Public Types

enum State

Enum for possible selection states.

Values:

DEFAULT
TARGETED
SELECTED

Public Functions

void SelectableObject.SetStateSelected()

Changes the state depending on the current state and updates the result in SelectorManager.

void SelectableObject.SetStateTargeted()

Sets the state to targeted if the last state was default.

void SelectableObject.SetStateDefault(bool forceMode = false)

Resets the state to default if the last state was targeted (without force mode).

Parameters
  • forceMode: Boolean to force the state switch.

Public Members

Material SelectableObject.TargetedMaterial

Material of meshes which are targeted.

Material SelectableObject.SelectedMaterial

Material of meshes which are selected.

Property

property SelectableObject::CurrentState

Public property to track the selection state for outside classes.

Private Functions

void SelectableObject.Awake()

Initializes the renderer array and default material.

void SelectableObject.changeState(State s)

Switches the state based on the parameter and manages GUI highlighting.

Parameters
  • s: State to which the object should switch to.

Private Members

State SelectableObject.m_CurrentState = State.DEFAULT

Variable to track the current selection state.

Renderer [] SelectableObject.m_Renderers

Array of all renderer to change the material.

Material SelectableObject.m_DefaultMaterial

Default material of all meshes.

SelectionPanel

class SelectionPanel

SelectionPanel is the panel where you can select roboy parts with the SelectorTool on a GUI interface.

Whereas the components inside the panel provide functions to switch between selection states, this class is responsible to animate the switch between Selection Mode and GUI Panel mode.

Inherits from MonoBehaviour

Public Functions

void SelectionPanel.Shrink()

Starts a coroutine to shrink the selection panel.

void SelectionPanel.Enlarge()

Starts a coroutine to enlarge the selection panel.

IEnumerator SelectionPanel.shrinkCoroutine()

Coroutine to shrink the selection panel.

Fades out the UI elements, turns off the colliders and shrinks the selection panel.

Return

Public Members

Text SelectionPanel.CurrentPanelMode

Reference to the text component to display the current panel mode like MotorForce etc.

Private Functions

void SelectionPanel.Awake()

Initializes all variables like the RectTransform and the lists.

IEnumerator SelectionPanel.enlargeCoroutine()

Coroutine to enlarge the selection panel.

Fades in the UI elements, turns on the colliders and enlarges the selection panel.

Return

Private Members

RectTransform SelectionPanel.m_RectTransform

Private RectTransform component for animation purposes.

List<CanvasGroup> SelectionPanel.m_ChildCanvasGroups = new List<CanvasGroup>()

List of all canvas groups to change the alpha value.

List<BoxCollider> SelectionPanel.m_ChildBoxColliders = new List<BoxCollider>()

List of all colliders on the UI elements to switch them off and on.

Projectile

class Projectile

Inherits from MonoBehaviour

Public Members

float Projectile.projectileSpeed

The speed of the projectile.

Private Functions

void Projectile.Update()

Move forward and destroy yourself if you are not in the roboy cave.

void Projectile.OnCollisionEnter(Collision collision)

Triggers a ROS external force message.

Transforms the hit point from world space to roboy local space.

Parameters
  • collision