00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2007 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef RANDOM_DIRECTION_MOBILITY_MODEL_H 00021 #define RANDOM_DIRECTION_MOBILITY_MODEL_H 00022 00023 #include "ns3/object.h" 00024 #include "ns3/ptr.h" 00025 #include "ns3/nstime.h" 00026 #include "ns3/event-id.h" 00027 #include "ns3/rectangle.h" 00028 #include "ns3/random-variable.h" 00029 #include "mobility-model.h" 00030 #include "static-speed-helper.h" 00031 00032 namespace ns3 { 00033 00034 /** 00035 * \brief a RandomDirection mobility model 00036 * 00037 * The movement of objects is based on random directions: each object 00038 * pauses for a specific delay, chooses a random direction and speed and 00039 * then travels in the specific direction until it reaches one of 00040 * the boundaries of the model. When it reaches the boundary, it pauses, 00041 * selects a new direction and speed, aso. 00042 */ 00043 class RandomDirection2dMobilityModel : public MobilityModel 00044 { 00045 public: 00046 static TypeId GetTypeId (void); 00047 00048 RandomDirection2dMobilityModel (); 00049 private: 00050 void Start (void); 00051 void ResetDirectionAndSpeed (void); 00052 void BeginPause (void); 00053 void SetDirectionAndSpeed (double direction); 00054 void InitializeDirectionAndSpeed (void); 00055 virtual void DoDispose (void); 00056 virtual Vector DoGetPosition (void) const; 00057 virtual void DoSetPosition (const Vector &position); 00058 virtual Vector DoGetVelocity (void) const; 00059 00060 static const double PI; 00061 Rectangle m_bounds; 00062 RandomVariable m_speed; 00063 RandomVariable m_pause; 00064 EventId m_event; 00065 StaticSpeedHelper m_helper; 00066 }; 00067 00068 } // namespace ns3 00069 00070 #endif /* RANDOM_DIRECTION_MOBILITY_MODEL_H */