Unity Lab 6: Embodied Cognition

Prelab:

  1. Think back to the obstacle course lab we did at the beginning of term. In that lab, whenever the robot collides with an obstacle, it will get information from the obstacle as to whether the right or left side is open, then move to the open side if there is one. Based on this strategy, list some assumptions about actions that the robot is and is not capable of (think about what the robot is doing and the information it is taking in from the environment).
  2. In Unity, what is a Raycast? How does it work? What are some tasks that it can be used for?  (Note: the technical description may not be intuitive to some of you – if that is the case, there are many YouTube videos that demonstrate great examples of Raycasting)

 

Lab:

Download the code for the lab here.

In this lab, we will return to the obstacle course from lab 1, but with different player robots. You will implement obstacle course navigation strategies for the different robots, each with their own set of abilities and limitations. The general recommendation for implementing the strategies is to do some trial and error in your brainstorming process to get accustomed to the physics in the environment.

Notes:

  • Movement can be done using rb.AddForce() with the force amount to apply to each axis
  • For any function for moving the robot forward, make sure to multiply the force value with Time.deltaTime to account for your computer’s processing time.

Part 1: Blind Robot

The robot in this part has the following abilities:

  • It can move forward, left, or right
  • When it collides with an object, it can detect if the object is an obstacle

This robot’s limitations are:

  • It is not able to identify which side of the obstacle is open
  • It cannot jump

Your tasks:

  1. Implement the MoveForward() function
  2. Implement the DodgeLeftOrRight(). The robot will dodge either left or right when this function is called (the logic for which way to dodge is up to you) with the amount of force that is passed in as dodgeForce
  3. Figure out a strategy to get this robot past all the obstacles. Hint: look at the variables and functions provided

Show your TA once you have finished implementing the navigation strategy for this part and briefly explain your strategy.

Part 2: Jumpy Robot

The robot in this part has the following abilities:

  • It can move forward
  • It can do single jumps using the Jump function
  • It can look directly ahead and see if there is an obstacle a certain distance away

This robot’s limitations are:

  • It cannot move sideways
  • It cannot jump any higher or in a different direction than what is provided by Jump()

Your tasks:

  1. Implement the MoveForward() function (like part 1)
  2. Figure out a strategy to get this robot past all the obstacles. Hint: look at the variables and functions provided. Test out the Jump() function first to see how high and far the robot can jump

Show your TA once you have finished implementing the navigation strategy for this part and briefly explain your strategy.

Part 3: Coin Collector Robot

In this part, in addition to navigating past obstacles, the robot also has the additional goal of collecting all the coins in the course

The robot in this part has the following abilities:

  • It can move forward, left, or right
  • It can look directly ahead, left, or right and see if there is an object a certain distance away

This robot’s limitations are:

  • It cannot jump
  • It is not able to identify what object it collides with

Your tasks:

  1. Implement the MoveForward(), MoveLeft(), and MoveRight() functions
  2. Implement the LookAhead(), LookLeft(), and LookRight() functions. Hint: look up Raycast in Unity if you haven’t and look at how the ObstacleAhead() function in Part 2 is implemented
  3. Figure out a strategy to get this robot past all the obstacles and collect all the coins. Hint: look at the functions provided and the ones you implemented. The majority of the navigation strategy can be done in the FixedUpdate() function

Show your TA once you have finished implementing the navigation strategy for this part and briefly explain your strategy.

BONUS: no wasted movement challenge – can you adjust the robot in part 3 so that it will travel the least distance possible to accomplish its goals? You can modify/use another variation of LookLeft() and LookRight() so the robot can look at things at different angles on its left and right.

 

Postlab:

  1. Can the different navigation strategies be applied to robots that it was not originally built for, e.g., can the strategy for the robot in part 2 be applied for the robots in part 1, 3, or any other robot? How does this relate to embodied cognition?
  2. Can the same robot from each part use the same navigation strategy in a different obstacle course? Choose a robot and either justify why your navigation strategy could work in other obstacle courses or give an example of how your strategy could fail.
  3. (Optional) What could be improved about this lab? (Note: please give specific details as opposed to “there were errors with installation”, or “the code was hard”. This will allow us to hone in on the issue rather than guessing what the challenges were).