Skip to content

Commit

Permalink
Add documentation for sitting task, move models into own folder, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lenalinke committed Oct 13, 2024
1 parent 2e67b66 commit 30cc4f0
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ public class AgentSittingTask: AgentBaseTask, ISerializable
private readonly Vector3 footrest;
private readonly Vector3 sitPosition;

/// <summary>
/// Enables the agent to sit on a prepared chair GameObject
/// </summary>
/// <param name="chair">The chair to be sat on. Needs to have at least "FeetPosition" and "SitPosition" child objects.</param>
/// <param name="direction">Either SITDOWN, STANDUP or TOGGLE. TOGGLE is equivalent to SITDOWN while standing and STANDUP while sitting.</param>
public AgentSittingTask(GameObject chair, SittingDirection direction = SittingDirection.TOGGLE)
{
Direction = direction;
Chair = chair;
// TODO: give as parameters
feetPosition = chair.transform.Find("FeetPosition").position;
footrest = chair.transform.Find("Footrest") != null ? chair.transform.Find("Footrest").position : feetPosition;
sitPosition = chair.transform.Find("SitPosition").position;
Expand Down Expand Up @@ -106,8 +110,6 @@ public override void StartExecution(Agent agent)
{
animator.SetBool("Sitting", false);
agent.StartCoroutine(FadeIK(agent, false));

Debug.Log("Standing up");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ protected override void Start()
AgentSittingTask sittingTask = new AgentSittingTask(Chair, SittingDirection.SITDOWN);
AgentSittingTask standingTask = new AgentSittingTask(Chair, SittingDirection.STANDUP);


AgentSittingTask sittingTaskStool = new AgentSittingTask(Stool, SittingDirection.SITDOWN);
AgentSittingTask standingTaskStool = new AgentSittingTask(Stool, SittingDirection.STANDUP);
// Notice that both tasks use "TOGGLE" as the direction, so the agent will sit down when standing and vice versa
AgentSittingTask sittingTaskStool = new AgentSittingTask(Stool, SittingDirection.TOGGLE);
AgentSittingTask standingTaskStool = new AgentSittingTask(Stool, SittingDirection.TOGGLE);

GameObject destination1 = Chair.transform.Find("FeetPosition").gameObject;
taskSystem.Tasks.GoTo(destination1, Vector3.zero, 0, true);
taskSystem.Tasks.WaitForSeconds(1);
// add a sitting task
taskSystem.ScheduleTask(sittingTask);
taskSystem.Tasks.WaitForSeconds(3);
Debug.Log("2nd Sitting Task Scheduled");
taskSystem.ScheduleTask(standingTask);

GameObject destination = Stool.transform.Find("FeetPosition").gameObject;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1562,20 +1562,12 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
title:
description: 'This scene demonstrates how to schedule walking tasks so that the
agent navigates a series of waypoints.
description: 'During execution of the scene, the agent will walk to a chair, sit
down, stand up, and then walk to a stool to do the same.
The script on the Controller object
issues walking tasks to the agent on startup.
Use the scene view during
play mode to inspect the scene freely while the agent is walking around.
If
Objects are changed in the scene: Select the GameObject "NavMesh Surface" and
bake the NavMesh again before running the scene.'
Notice the setup
of the chair and stool objects, with empties defining various positions needed
for sitting.'
type: 0
url:
--- !u!4 &1264251852
Expand Down
1 change: 1 addition & 0 deletions Documentation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ If you click on it, there are further descriptions about the scene in the inspec
The package's code is distributed under the [MIT license](https://github.com/rwth-acis/Virtual-Agents-Framework/blob/master/LICENSE).

All art assets (e.g. files located in the folders "3D Models" and "Animations" in the package's root folder) are distributed under the [Creative Commons Attribution 4.0 International](http://creativecommons.org/licenses/by/4.0/) license and are attributed to Benedikt Hensen unless stated otherwise.
The chair and stool models, used in the sitting sample, are licensed under the CC0 license.

## Contributors

Expand Down
3 changes: 2 additions & 1 deletion Documentation/manual/quickstart-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ Going from least to most complex, it is recommended to look at the samples in th
5. Parallel Task Sample ([manual page](parallel-tasks.md))
6. Aiming Sample ([manual page](aiming.md))
7. Adaptive Gaze Sample ([manual page](adaptive-gaze.md))
8. Item Pickup Sample ([manual page](items.md))
8. Sitting Sample ([manual page](sitting.md))
9. Item Pickup Sample ([manual page](items.md))

## Customization of agents
To make the application look more appealing from the beginning custom agent models can be used, see [Adding Own Agent Models and Animations](own-agents.md) for that.
33 changes: 33 additions & 0 deletions Documentation/manual/sitting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Sitting

The agent has the ability to sit on chairs or other objects of variable height. To do this, the GameObject the agent should sit on needs to have multiple positions defined, which are marked as Empty child GameObjects.


## Requirements
GameObjects intended to be used for sitting must be set up with the following Empty GameObjects as children:
1. **"SitPosition"** - The position where the agent should sit, i.e. the position the hip should rest at while sitting.
2. **"FeetPosition"** - The position the agent should stand before and after sitting. The agent should walk to this position before initiating the task.
3. **"Footrest"** - The position the agent should rest his feet on while sitting. This might be the literal footrest of a chair or an arbitrary position in the air, for chairs where the agent can't reach the ground with their feet. This is the only optional position, as the FeetPosition will be used instead, if it is missing.

*The Empties should be named exactly as described above.*

## Usage
After ensuring that a chair GameObject is set up correctly, the agent can be instructed to sit on it by creating a new `AgentSittingTask`.
Its first parameter is the GameObject the agent should sit on, the second parameter is either `SittingDirection.SITDOWN` or `SittingDirection.STANDUP`, depending on whether the agent should sit down or stand up.
Alternatively use `SittingDirection.TOGGLE` to toggle between sitting and standing, depending on the current state.

```csharp
AgentSittingTask sittingTask = new AgentSittingTask(Chair, SittingDirection.SITDOWN);
AgentSittingTask standingTask = new AgentSittingTask(Chair, SittingDirection.STANDUP);

taskSystem.ScheduleTask(sittingTask);
taskSystem.Tasks.WaitForSeconds(3);
taskSystem.ScheduleTask(standingTask);
```


## Example Scenes

The framework contains an example scene that demonstrates the ability to sit on different chairs and stools.

During execution of the scene, the agent will walk to a chair, sit down, stand up, and then walk to a stool to do the same.

0 comments on commit 30cc4f0

Please sign in to comment.