Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jakory committed Jul 6, 2016
2 parents cb2552e + 50b0dca commit 15fd44e
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 96 deletions.
74 changes: 44 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ This game was built and tested with:

## Configuration

The game uses configuration options listed in the opal\_config file. There
is an example file located in Assets/Resources/.
The game uses configuration options listed in the `opal\_config` file. There
is an example file located in `Assets/Resources/`.

### On OS X

When running the game on OS X from the Unity editor, the game will check for
"Assets/Resources/opal\_config.txt".
`Assets/Resources/opal_config.txt`.

### On Android

When running the game on Android (e.g., on a tablet), the game will first check
for "mnt/sdcard/edu.mit.media.prg.sar.opal.base/opal\_config.txt". This is
for `mnt/sdcard/edu.mit.media.prg.sar.opal.base/opal_config.txt`. This is
because once the game is packaged up for Android, you can't change stuff in the
package, so we needed a location for the config file that could be easily
edited after the game is installed. If that file doesn't exist, or connecting
Expand All @@ -41,7 +41,7 @@ in the packaged game.
### On Linux

When running the game on Linux from a standalone executable, the game will
check for the config file in the "executable-name\_Data/Resources" directory.
check for the config file in the `executable-name_Data/Resources` directory.
You will have to manually add the config file to this directory. This is
because when the app is packaged up, all the game assets are packaged up by
Unity and cannot be easily edited after the game is installed. If that file
Expand All @@ -61,6 +61,14 @@ the command line with the flag `-force-opengl`, i.e., `./executable-name
- toucan: [boolean] whether or not you want a toucan sidekick in the game
- log\_debug\_to\_ros: [boolean] whether or not to log Unity's Debug.Log\*
calls to the ROS topic "/opal\_tablet".
- opal\_action\_topic: [string] the ROS topic to publish OpalAction messages to
- opal\_audio\_topic: [string] the ROS topic to publish Bool messages to
indicating whether the sidekick character is done playing audio or not
- opal\_command\_topic: [string] the ROS topic to subscribe to to receive
OpalCommand messages
- opal\_log\_topic: [string] the ROS topic to publish String messages to with
basic log messages
- opal\_scene\_topic: [string] the ROS topic to publish OpalScene messages to

#### Server & port On startup, the game will try to connect to the specified IP

Expand All @@ -82,35 +90,38 @@ rosbridge\_server, the connection will be refused.

#### Toucan

If you set the toucan option to 'true', a toucan sidekick character will be
If you set the toucan option to `true`, a toucan sidekick character will be
loaded into the game (provided you have the toucan graphics in your Assets
folder). You will then be able to send the sidekick commands, such as to play
back sound or animations. If set to false, no toucan will be present.

## SAR Opal messages

The game subscribes to the ROS topic "opal\_tablet\_command" to receive
The topics listed here are the default names of the topics subscribed and
published to. You can change these defaults in the config file.

The game subscribes to the ROS topic `opal\_tablet\_command` to receive
messages of type
"/[sar\_opal\_msgs](https://github.com/personal-robots/sar_opal_msgs
"/sar\_opal\_msgs")/OpalCommand".

The game publishes /std\_msgs/String messages to the ROS topic "opal\_tablet".
The game publishes /std\_msgs/String messages to the ROS topic `opal\_tablet`.

The game publishes
"/[sar\_opal\_msgs](https://github.com/personal-robots/sar_opal_msgs
"/sar\_opal\_msgs")/OpalAction" to the ROS topic "opal\_tablet\_action". See
"/sar\_opal\_msgs")/OpalAction" to the ROS topic `opal\_tablet\_action`. See
[/sar\_opal\_msgs] (https://github.com/personal-robots/sar_opal_msgs
"/sar\_opal\_msgs") for more info.

The game publishes
"/[sar\_opal\_msgs](https://github.com/personal-robots/sar_opal_msgs
"/sar\_opal\_msgs")/OpalScene" to the ROS topic "opal\_tablet\_scene". Usually
"/sar\_opal\_msgs")/OpalScene" to the ROS topic `opal\_tablet\_scene`. Usually
this message will only be published after receiving a "request keyframe"
command - see
[/sar\_opal\_msgs](https://github.com/personal-robots/sar_opal_msgs
"/sar\_opal\_msgs") for more info.

The game publishes "/std\_msgs/Bool" to the ROS topic "opal\_tablet\_audio", to
The game publishes "/std\_msgs/Bool" to the ROS topic `opal\_tablet\_audio`, to
indicate whether the sidekick character is done playing back an audio file.

### OpalCommand LOAD\_OBJECT messages
Expand All @@ -122,15 +133,14 @@ a GameObject with the specified properties. As the
telling Opal to load an object is the name of the associated graphic to load.
Opal tries to load the graphic from two places:

1) "Assets/Resources/graphics/base-images" directory. If the game is a social
1) `Assets/Resources/graphics/base-images` directory. If the game is a social
stories game (see below for different game descriptions), Opal assumes all
graphics loaded will be in the
"Assets/Resources/graphics/base-images/socialstories" directory. Either the
base-images or socialstories directories may have subdirectories, which
shouldsocialstories be provided as part of the graphic name. E.g.,if you want
to load the image "happy.png" that resides in the "base-images/emotions/"
directory, you would need to list the name of the graphic to load as
"emotions/happy.png".
`Assets/Resources/graphics/base-images/socialstories` directory. Either the
base-images or socialstories directories may have subdirectories, which should
be provided as part of the graphic name. E.g., if you want to load the image
`happy.png` that resides in the `base-images/emotions/` directory, you would
need to list the name of the graphic to load as `emotions/happy.png`.

2) If loading from Resources fails, Opal assumes the graphic file name provided
is actually a full file path to the desired image (that may or may not be in
Expand All @@ -140,7 +150,7 @@ will fail.

## Log Files

Unity automatically logs all Debug.Log\* calls to a text file. The location of
Unity automatically logs all `Debug.Log*` calls to a text file. The location of
this file varies by platform -- [here's the official
list](http://docs.unity3d.com/Manual/LogFiles.html).

Expand Down Expand Up @@ -197,10 +207,10 @@ here](http://dentedpixel.com/LeanTweenDocumentation/classes/LeanTween.html
"LeanTween docs")).

If you pull in the submodule, you can get the examples, prefabs, etc. The
necessary .cs files are in the SAR-opal-base Assets/Plugins directory already.
Note that the LeanTween instructions only tell you to move LeanTween.cs to your
Plugins directory; however, you actually need several other files that are in
LeanTween's Plugins directory as well.
necessary .cs files are in the `SAR-opal-base Assets/Plugins` directory
already. Note that the LeanTween instructions only tell you to move
LeanTween.cs to your Plugins directory; however, you actually need several
other files that are in LeanTween's Plugins directory as well.

### websocket-sharp

Expand Down Expand Up @@ -240,7 +250,7 @@ comments on the github gist page added in.
- Only a small set of "demo" graphics are included in this repository. The full
set of graphics for different games is available from the Personal Robots
Group - email students in the group to inquire. Add the full set to the
"Resources\/base\_images" folder.
`Resources/base_images` folder.

## Version Notes

Expand All @@ -258,6 +268,9 @@ game setups. Currently, these include:
- Storybook
- SAR Year 5 social stories game

For all versions, you may need to adjust the options in the config file for
your setup.

### Demo Version

To build and deploy the demo version, do the following:
Expand All @@ -269,8 +282,8 @@ To build and deploy the demo version, do the following:
"base". Technically, this step is not necessary, but if you have another
version of Opal deployed on your device, you'll want to change these
settings so you can have both side by side.
3. In the MainGameController, set the flag "demo" to true, "story" to false,
and "socialStories" to false.
3. In the MainGameController, set the flag `demo` to true, `story` to false,
and `socialStories` to false.
4. Build and deploy.

The demo version of the game requires some graphics that are not included in
Expand All @@ -289,8 +302,8 @@ To build and deploy the Frog Where Are You storybook, do the following:
instead of "base". Technically, this step is not necessary, but if you have
another version of Opal deployed on your device, you'll want to change these
settings so you can have both side by side.
3. In the MainGameController, set the flag "story" to true, "demo" to false,
and "socialStories" to false.
3. In the MainGameController, set the flag `story` to true, `demo` to false,
and `socialStories` to false.
4. Build and deploy.

You can use the Frog Where Are You book as an example for how to load your own
Expand All @@ -309,8 +322,8 @@ To build and deploy the Social Stories version, do the following:
of "base". Technically, this step is not necessary, but if you have another
version of Opal deployed on your device, you'll want to change these
settings so you can have both side by side.
3. In the MainGameController, set the flag "story" to false, "demo" to false",
and "socialStories" to true.
3. In the MainGameController, set the flag `story` to false, `demo` to false",
and `socialStories` to true.
4. Build and deploy.

## Bugs and Known Issues
Expand Down Expand Up @@ -365,3 +378,4 @@ page](https://github.com/personal-robots/SAR-opal-base/issues).
redeploy (and/or a start screen that lets you pick whether you want demo
mode, story mode, etc when you start the game - use "load scene" function to
pick the right one).
- Rarely, we get a "websocket closed 1005" error. Why? Fix.
5 changes: 5 additions & 0 deletions sar-opal-base/Assets/Resources/opal_config.example.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"server": "write the IP address of the ROS server here, e.g., 192.168.1.23",
"port": "9090",
"opal_action_topic": "opal_tablet_action",
"opal_audio_topic": "opal_tablet_audio",
"opal_command_topic": "opal_tablet_command",
"opal_log_topic": "opal_tablet",
"opal_scene_topic": "opal_tablet_scene",
"toucan": false,
"log_debug_to_ros": false
}
30 changes: 16 additions & 14 deletions sar-opal-base/Assets/scripts/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ public struct GameConfig
public string port;
public bool sidekick;
public bool logDebugToROS;
public string opalCommandTopic;
public string opalActionTopic;
public string opalLogTopic;
public string opalSceneTopic;
public string opalAudioTopic;
}

public static class Constants
Expand Down Expand Up @@ -136,14 +141,6 @@ public static class Constants
public const string ANSWER_SLOT = "answer-slot";
public const string SCENE_COLLIDE_SLOT = "scene-collide-slot";

// edges of screen - used to make sure objects aren't dragged off the screen
// screen is 1280x768, minus the menu bar
// TODO this needs to scale to the size of the screen - use Screen.width etc!
public const int LEFT_SIDE = -620; // -640
public const int RIGHT_SIDE = 620; //640
public const int TOP_SIDE = 360; //384
public const int BOTTOM_SIDE = -330; //-384

/** messages we can receive */
public const int DISABLE_TOUCH = 1;
public const int ENABLE_TOUCH = 2;
Expand Down Expand Up @@ -198,30 +195,35 @@ public static class Constants
public const string CONFIG_PATH_LINUX = "/Resources/";


/** ROS-related constants: topics and message types */
/** Default ROS-related constants: topics and message types */
// general string log messages (e.g., "started up", "error", whatever)
public const string LOG_ROSTOPIC = "/opal_tablet";
public static string LOG_ROSTOPIC = "/opal_tablet";
public const string DEFAULT_LOG_ROSTOPIC = "/opal_tablet";
public const string LOG_ROSMSG_TYPE = "std_msgs/String";
// messages about actions taken on tablet (e.g., tap occurred on object x at xyz)
// contains:
// string object: name
// string action_type: tap
// float[] position: xyz
public const string ACTION_ROSTOPIC = "/opal_tablet_action";
public static string ACTION_ROSTOPIC = "/opal_tablet_action";
public const string DEFAULT_ACTION_ROSTOPIC = "/opal_tablet_action";
public const string ACTION_ROSMSG_TYPE = "/sar_opal_msgs/OpalAction";
// messages logging the entire current scene
// contains:
// string background
// objects[] { name posn tag }
public const string SCENE_ROSTOPIC = "/opal_tablet_scene";
public static string SCENE_ROSTOPIC = "/opal_tablet_scene";
public const string DEFAULT_SCENE_ROSTOPIC = "/opal_tablet_scene";
public const string SCENE_ROSMSG_TYPE = "/sar_opal_msgs/OpalScene";
// commands from elsewhere that we should deal with
public const string CMD_ROSTOPIC = "/opal_tablet_command";
public static string CMD_ROSTOPIC = "/opal_tablet_command";
public const string DEFAULT_CMD_ROSTOPIC = "/opal_tablet_command";
public const string CMD_ROSMSG_TYPE = "/sar_opal_msgs/OpalCommand";
// messages to tell the game node when we're done playing audio
// contains:
// bool done playing
public const string AUDIO_ROSTOPIC = "/opal_tablet_audio";
public static string AUDIO_ROSTOPIC = "/opal_tablet_audio";
public const string DEFAULT_AUDIO_ROSTOPIC = "/opal_tablet_audio";
public const string AUDIO_ROSMSG_TYPE = "/std_msgs/Bool";
}
}
Loading

0 comments on commit 15fd44e

Please sign in to comment.