Skip to content

Commit

Permalink
quick edits
Browse files Browse the repository at this point in the history
  • Loading branch information
default user name committed Oct 12, 2022
1 parent 8dea143 commit c5a992c
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 193 deletions.
228 changes: 107 additions & 121 deletions Documentation/2.1_Sample_Scenes.md

Large diffs are not rendered by default.

74 changes: 28 additions & 46 deletions Documentation/3.1_Data_and_Channels.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,52 @@
# 3.1. Data & Channels


## **_<span style="text-decoration:underline;">LIT Lab - AR Data & Channels for VIsual Effects Documentation, March 2022</span>_**

## **_<span style="text-decoration:underline;">How do the data models and Photon work?</span>_**

### Photon basics



* Read about Photon Unity Networking: [https://doc.photonengine.com/en-us/pun/current/getting-started/pun-intro](https://doc.photonengine.com/en-us/pun/current/getting-started/pun-intro)
* Connectivity:
* Photon connects multiple users through a cloud service. All users need to be connected to the internet, not necessarily on the same local network.
* Photon connects multiple users through a cloud service. All users need to be connected to the internet, not necessarily on the same local network.
* Synchronization:
* Networked data is synchronized between all users by Photon, through PhotonViews.
* See [documentation about Photon](./3.6_Photon_Synchronization_of_Custom_Data.md) for more details about synchronizing data
* Networked data is synchronized between all users by Photon, through PhotonViews.
* See [documentation about Photon](./3.6_Photon_Synchronization_of_Custom_Data.md) for more details about synchronizing data
* Ownership:
* Only one user controls a PhotonView at one time. Only they can change its values. This user is called the ‘owner’ of the PhotonView.
* This means when another user wants to change the data, they need to request ownership first.
* Only one user controls a PhotonView at one time. Only they can change its values. This user is called the ‘owner’ of the PhotonView.
* This means when another user wants to change the data, they need to request ownership first.

### Data models basics



* Summary: Data in our project flows through named entities called channels. A channel can get data from a Hololens or from the PC or from Arduino or all of the above. Channel data can be controlled in a variety of ways (ex: knobs, buttons) and displayed in a variety of ways (ex: graphs, text, colors)
* Data is stored/synchronized through **AtomicDataModel**(ADM) objects. Each of these holds a value (typically float), which is automatically synchronized by Photon to all users.
* When one user changes an ADM model value, that model is synchronized by Photon to all other users.
* An ADM value can only be changed by the user who is the current owner of the PhotonView.
* ![](.\Images\2022-10-12-11-38-09-image.png)
* ^ this figure shows a simplified view of an ADM object being shared by multiple users
*
* When one user changes an ADM model value, that model is synchronized by Photon to all other users. An ADM value can only be changed by the user who is the current owner of the PhotonView.
* ![](.\Images\2022-10-12-11-39-03-image.png)
* ^ this figure is more accurate: in reality all users have a local ADM object, which Photon synchronizes through the PhotonViews that have the same ID
*
* Channels:
* Channels allow easy access to sensor data. Channels are basically labels for specific ADM objects.
* They are stored in the “CHANNELS and MODELS” gameobject and accessed through the **ChannelManager** class.
* Some channels come from Arduino (see Arduino Connection section below), and some are within the Unity project (some of these are automatically simulated by the “**SimulatedChannels**” gameobject; and some are manually controlled, possibly through “**ManualDataChannel**” prefabs)
* Channels allow easy access to sensor data. Channels are basically labels for specific ADM objects.
* They are stored in the “CHANNELS and MODELS” gameobject and accessed through the **ChannelManager** class.
* Some channels come from Arduino (see Arduino Connection section below), and some are within the Unity project (some of these are automatically simulated by the “**SimulatedChannels**” gameobject; and some are manually controlled, possibly through “**ManualDataChannel**” prefabs)
* Simulated Channels
* Only the user running in the UNITY EDITOR controls these channels. No other users will be generating these signals.
* They are generated within the “**SimulatedChannels**” gameobject.
* **AtomicDataSwitches**(ADS) are objects that look like AtomicDataModels but they actually can provide values from with different channels. For example, ADS pointed at channel C1 will act like the ADM model associated with C1; if we point it at C2 it acts like the ADM model associated with C2.
* Only the user running in the UNITY EDITOR controls these channels. No other users will be generating these signals.
* They are configured through the **ConfigurationProfile** object (as described below)
* Arduino Channels
* Some of the data in channels could come from the Arduino, as configured in the **ConfigurationProfile** object. (Please see the [Arduino documentation](./3.2_Arduino_Connection.md) for how to connect/disconnect channels from the Arduino)
* **AtomicDataSwitches**(ADS) are objects that look like AtomicDataModels but they actually can provide values from with different channels. For example, ADS pointed at channel C1 will act like the ADM model associated with C1; if we point it at C2 it acts like the ADM model associated with C2. It's basically a way of accessing data from an ADM, but it can be switched at runtime to different channels.

### Simulated Channels

* Unity can generate simulated data. It can be configured via the **ConfigurationProfile** object, to send simulated data on any channel:

* ![](.\Images\2022-10-12-11-42-22-image.png)

* The way this works is, there's a “**SimulatedChannels**” gameobject generates fake data into several channels.

* The “**SimulatedChannels**” gameobject generates fake data into several channels:



<p align="center">
<picture>
<img align="center" alt="Simulated Channels" src="https://github.com/shankar-r19/CYBS-MArkdown-files/blob/5145db920b350e5ab5fb17170f35c465a4e63d5f/Images/Simulated_Channels.png" width= "400" height="400">
</picture>
</p>


* The “FakeDataBroadcaster” child object generates these signals:

* Sensor 1: sawtooth spiky
* Sensor 2: sine wave
* Sensor 3: square wave
* Sensor 4: constantly increasing

* The fake data is sent to channels as specified in the “SimulatedChannels” object (see screenshot above).
* **If you don’t want a channel to be populated with fake data, just set the Sensor Model to point to nothing.**

**Arduino note**



* Some of the data in channels could come from the Arduino. (Please see the [Arduino documentation ](./3.2_Arduino_Connection.md)for how to connect/disconnect channels from the Arduino)

* * 1: sawtooth spiky
* 2: sine wave
* 3: square wave
* 4: constantly increasing
37 changes: 11 additions & 26 deletions Documentation/3.2_Arduino_Connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,28 @@

### **Description and configuration**



* To talk to Arduino, you’ll need a computer connected to Arduino using serial port. (*if you want to talk through wifi, you could use websockets)
* To talk to Arduino, you’ll need a computer connected to Arduino using serial port. (*if you want to talk through wifi, you could use websockets [experimental feature])
* In a multiplayer session, only the user running in the Unity Editor is actually talking to the Arduino; everyone else gets/sends data through the [data channels](./3.1_Data_and_Channels.md)
* Configuring the serial port:
* The computer’s serial port is configured through the “**SerialController**” object.
* When plugging a new arduino you will need to update the Port Name in the “SerialController” object, to match what is in the Arduino IDE (on Mac this includes /dev/..)
* The computer’s serial port is configured through the “**ConfigurationProfile**” object.
* When plugging a new arduino you will need to update the port in the configuration profile, to match what is in the Arduino IDE (on Mac this includes /dev/tty..)
* Configuring the data channels:
* Search for the “**SerialPort**” gameobject in the scene hierarchy.
* If it’s disabled, you need to enable it otherwise you won’t get data to/from the Arduino.
* Search for the “**ArduinoCommManager**” object. It is in charge of talking to the arduino through the serial port. It keeps track of which channels will be sent/received with the Arduino.
* If you want other channels, you need to update the lists To Unity and From Unity:

<p align="center">
<picture>
<img alt="Arduino Comm Manager" src="./Images/Arduino_Comm_Mgr.png" width= "400" height="400">
</picture>
</p>
* Unity will send/receive data according to what channels are listed in the **ConfigurationProfile**
* ![](.\Images\2022-10-12-11-42-22-image.png)
* If you want more channels to be connected to/from Arduino, you will need to add them to the Arduino_channels_from_arduino and Arduino_channels_to_arduino lists in the **ConfigurationProfile **object

### **Messages between Arduino and Unity:**



* Messages to/from Arduino are always sent through the com port in the form of “:X:V” where X is channel id (ex: C1) and V is a value from 0-1024. (ex: “:C4:123”)
* The provided Arduino code makes it easy to send/receive data with Unity, but if you want to do it manually you can use simple serial communication
* Sending from Arduino to Unity:
* In the Arduino code, using Serial.println(“:C4:555”) will tell Unity that the C4 channel’s value should be 555.
* On reception of a new value from Arduino, the channel’s AtomicDataModel will be updated (assuming the channel is listed in the ArduinoCommManager).
* In the Arduino code, using Serial.println(“:C4:555”) will tell Unity that the C4 channel’s value should be 555.
* On reception of a new value from Arduino, the channel’s AtomicDataModel will be updated (assuming the channel is listed in the ArduinoCommManager).
* Sending:
* From Unity, you can use SerialController to send “:C3:222”, and the Arduino will receive this value.
* In the Unity project, when a channel’s ADM model is updated, it is automatically sent to Arduino (assuming the channel is listed in the ArduinoCommManager).
* Known bugs: there are issues when Unity tries to send too much data; see section below.
* From Unity, you can use SerialController to send “:C3:222”, and the Arduino will receive this value.
* In the Unity project, when a channel’s ADM model is updated, it is automatically sent to Arduino (assuming the channel is listed in the ArduinoCommManager).
* Known bugs: there are issues when Unity tries to send too much data; see section below.

**Known issues**



* When sending too much continuous data from Unity to Arduino, the data may be lost or may be received as wrong values (ex: super big or low numbers). If this happens, reduce the amount of channels / data that you send from Unity to Arduino. The connection from Arduino to Unity doesn’t seem to be affected.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c5a992c

Please sign in to comment.