View | Details | Raw Unified | Return to bug 2363
Collapse All | Expand All

(-)a/src/mobility/helper/ns2-mobility-helper.cc (-8 / +9 lines)
 Lines 755-763    Link Here 
755
        {
755
        {
756
          return retval;
756
          return retval;
757
        }
757
        }
758
      // now calculate the xSpeed = distance / time
758
      // distance traveled based on input mobility trace file  
759
      double xSpeed = (xFinalPosition - retval.m_finalPosition.x) / time;
759
      double total_Dist = std::sqrt (std::pow (xFinalPosition - retval.m_finalPosition.x, 2) + std::pow (yFinalPosition - retval.m_finalPosition.y, 2));
760
      double ySpeed = (yFinalPosition - retval.m_finalPosition.y) / time; // & same with ySpeed
760
      double xSpeed = speed * (xFinalPosition - retval.m_finalPosition.x) / total_Dist; // comment out for the scheduled movement
761
      double ySpeed = speed * (yFinalPosition - retval.m_finalPosition.y) / total_Dist; // & same with ySpeed comment out for the scheduled movement
761
      retval.m_speed = Vector (xSpeed, ySpeed, 0);
762
      retval.m_speed = Vector (xSpeed, ySpeed, 0);
762
763
763
      // quick and dirty set zSpeed = 0
764
      // quick and dirty set zSpeed = 0
 Lines 766-776    Link Here 
766
      NS_LOG_DEBUG ("Calculated Speed: X=" << xSpeed << " Y=" << ySpeed << " Z=" << zSpeed);
767
      NS_LOG_DEBUG ("Calculated Speed: X=" << xSpeed << " Y=" << ySpeed << " Z=" << zSpeed);
767
768
768
      // Set the Values
769
      // Set the Values
769
      Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetVelocity, model, Vector (xSpeed, ySpeed, zSpeed));
770
      Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetPosition, model, Vector (xFinalPosition, yFinalPosition, 0));  // update the speed according to the input mobility trace file
770
      retval.m_stopEvent = Simulator::Schedule (Seconds (at + time), &ConstantVelocityMobilityModel::SetVelocity, model, Vector (0, 0, 0));
771
      Simulator::Schedule (Seconds (at), &ConstantVelocityMobilityModel::SetVelocity, model, Vector (xSpeed, ySpeed, zSpeed)); // update the position according to the input mobility trace file
771
      retval.m_finalPosition.x += xSpeed * time;
772
      retval.m_finalPosition.x = xFinalPosition; //comment out for use scheduled postion
772
      retval.m_finalPosition.y += ySpeed * time;
773
      retval.m_finalPosition.y = yFinalPosition; //comment out for use scheduled postion 
773
      retval.m_targetArrivalTime += time;
774
      retval.m_targetArrivalTime = at;	//comment out for use scheduled postion       
774
    }
775
    }
775
  return retval;
776
  return retval;
776
}
777
}

Return to bug 2363