Walking Backwards - The Difficulty



Overview

e.

Background

After developing the process of the Kinect detecting if the user is simulating walking forward the next step is to make the robot walk backwards.

Activity

The difficulty of this was that because the Kinect detects the walking motion when a user walks on the spot and not physically moving forwards or back because they stay in one spot. This meant that the user would have to indicate if they wanted to move backwards. The first attempt was for the user to put hands backwards however during testing the user found this unconformable and hard to keep hands backwards. This was over come by the user having to raise hand above their head when walking.

Another problem that was apparently when testing was due when walking on the spot the program detected the legs moving and started to walk forward regardless if the hand position. This lead to the code needing to be rearranged. The solution was to first detect if the legs are moving. Then detect where the hands Y position is to determine to walk backwards or forwards.

To prevent to robot from stopping when the user put both legs down during the walking motion a timer was created using an integer that incremented each time the method looped. If the timer was between two number the robot should keep waling however if it is over then stop the robot because the user has stopped moving their legs.
The code below shows how this has been done

if (countTF == true)
  {
      count++;
  }
  //Detect if right or left knee is in front of the other knee by 0.05M and that the robot is not turning left or right
  if ((skeleton.Joints[JointType.KneeRight].Position.Z > (skeleton.Joints[JointType.KneeLeft].Position.Z + 0.05))
      || (skeleton.Joints[JointType.KneeLeft].Position.Z > (skeleton.Joints[JointType.KneeRight].Position.Z + 0.05))
      && (activeCommand[IRSTurnLeft] == false && activeCommand[IRSTurnRight] == false)
     )
  {
      //if the timer/count is then then 2 (1 second)
      if (count < 2)
      {
          Thread thread = new Thread(send);
              //check where the wrist position, if its over the users head, they want to walk backwards
          if (skeleton.Joints[JointType.WristRight].Position.Y > (skeleton.Joints[JointType.Head].Position.Y))
          {
              //Send Command to robot
              thread.Start(RSWalkBackward);
              //Change GUI label
              active(WalkBackward);
              notactive(WalkForward);
              //Populate the active command array
              activeCommand[IRSWalkBackward] = true;
              //Add to Log
              commandLog.Text = "Walk Back\n" + commandLog.Text;
          }
          else
          {
              commandLog.Text = "Walk Foward\n" + commandLog.Text;
              thread.Start(RSWalkForward);
              active(WalkForward);
              notactive(WalkBackward);
              activeCommand[IRSWalkForward] = true;
          }

          label1.Content = "Walk";    //Testing Code
          //Reset Counter between leg movements
          count = 0; 
          //
          countTF = true;

      }
   
  }
  else
  {
      if (count > 1)
      {//stop robot
          //Debug code
          label1.Content = "stopped";
          //Initat thread
          Thread thread = new Thread(send);
          //Send command
          thread.Start(RSStop);
          //Change GUI text
          notactive(WalkBackward);
          notactive(WalkForward);
          //Active command array modified
          activeCommand[IRSWalkForward] = false;
          //Reset counter/timer
          count = 0;
          //Stop counter/timer
          countTF = false;

      }
      
  }

A previous version showing how the development has changed can be seen below. The detection was being over completed as seen below in the code for the backwards movement.

 if (((skeleton.Joints[JointType.KneeRight].Position.Z > (skeleton.Joints[JointType.KneeLeft].Position.Z + 0.06))
     || (skeleton.Joints[JointType.KneeLeft].Position.Z > (skeleton.Joints[JointType.KneeRight].Position.Z + 0.06)))
     && ((skeleton.Joints[JointType.WristLeft].Position.Y > (skeleton.Joints[JointType.Head].Position.Y))
     || (skeleton.Joints[JointType.WristRight].Position.Y > (skeleton.Joints[JointType.Head].Position.Y)))
     && activeCommand[IRSWalkForward] == false)

Comments

Popular Posts