View Javadoc

1   package cz.cuni.amis.pogamut.usar2004.communication.messages.usarcommands;
2   
3   import cz.cuni.amis.pogamut.base.communication.messages.*;
4   import cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes.CustomTypes.*;
5   
6   /**
7    *
8    * Drive command specified for an aircraft.
9    *
10   * Corresponding GameBots command is DRIVE.
11   *
12   */
13  public class DriveAerial extends CommandMessage
14  {
15      //constructor for the fourth type
16      public DriveAerial(double AltitudeVelocity, double LinearVelocity, double LateralVelocity, double RotationalVelocity, boolean Normalized)
17      {
18          this.AltitudeVelocity = AltitudeVelocity;
19          this.LinearVelocity = LinearVelocity;
20          this.LateralVelocity = LateralVelocity;
21          this.RotationalVelocity = RotationalVelocity;
22          this.Normalized = Normalized;
23      }
24  
25      /**
26       * <p></p>WARNING: this is empty-command constructor, you have to use
27       * setters to fill it up!
28       */
29      public DriveAerial()
30      {
31      }
32      /////// Properties BEGIN
33      //fourth type - AltitudeVelocity, LinearVelocity, LateralVelocity, RotationalVelocity, Normalized 
34      /*
35       * the altitude velocity (i.e up/down). If we use normalized values, the
36       * value range is -100 to 100 and corresponds to the robot’s minimum and
37       * maximum altitude velocity, respectively. Otherwise, the value is the
38       * absolute altitude velocity, in meters per second.
39       */
40      protected double AltitudeVelocity = 0;
41  
42      public double getAltitudeVelocity()
43      {
44          return AltitudeVelocity;
45      }
46  
47      public DriveAerial setAltitudeVelocity(double AltitudeVelocity)
48      {
49          this.AltitudeVelocity = AltitudeVelocity;
50          return this;
51      }
52      /*
53       * the linear velocity (i.e forward/backward). If we use normalized values,
54       * the value range is -100 to 100 and corresponds to the robot’s minimum and
55       * maximum linear velocity, respectively. Otherwise, the value is the
56       * absolute linear velocity, in meters per second.
57       */
58      protected double LinearVelocity = 0;
59  
60      public double getLinearVelocity()
61      {
62          return LinearVelocity;
63      }
64  
65      public DriveAerial setLinearVelocity(double LinearVelocity)
66      {
67          this.LinearVelocity = LinearVelocity;
68          return this;
69      }
70      /*
71       * the lateral velocity (i.e left/right). If we use normalized values, the
72       * value range is -100 to 100 and corresponds to the robot’s minimum and
73       * maximum lateral velocity, respectively. Otherwise, the value is the
74       * absolute lateral velocity, in meters per second.
75       */
76      protected double LateralVelocity = 0;
77  
78      public double getLaterarVelocity()
79      {
80          return LateralVelocity;
81      }
82  
83      public DriveAerial setLaterarVelocity(double LaterarVelocity)
84      {
85          this.LateralVelocity = LaterarVelocity;
86          return this;
87      }
88      /*
89       * the rotational velocity. If we use normalized values, the value range is
90       * -100 to 100 and corresponds to the robot’s minimum and maximum rotational
91       * velocity, respectively. Otherwise, the value is the absolute rotational
92       * velocity, in radians per second.
93       */
94      protected double RotationalVelocity = 0;
95  
96      public double getRotationalVelocity()
97      {
98          return RotationalVelocity;
99      }
100 
101     public DriveAerial setRotationalVelocity(double RotationalVelocity)
102     {
103         this.RotationalVelocity = RotationalVelocity;
104         return this;
105     }
106     /*
107      * Example: DRIVE {AltitudeVelocity 1} will elevate the robot at a rate of 1
108      * meters per second. DRIVE {RotationalVelocity 0.1} will rotate the robot
109      * at a rate of 0.1 radians per second. DRIVE {LinearVelocity -3} will make
110      * the robot go backward at a rate of 3 meters per second.
111      */
112     /*
113      * Indicates whether we are using normalized values or ´ * not. The default
114      * value is ‘False’ which means absolute values are used to control wheel
115      * spin speed.
116      */
117     protected boolean Normalized = false;
118 
119     public boolean isNormalized()
120     {
121         return Normalized;
122     }
123 
124     /////// Properties END
125     /////// Extra Java code BEGIN
126     /////// Additional code from xslt BEGIN
127     /////// Additional code from xslt END
128     /////// Extra Java from XML BEGIN
129     /////// Extra Java from XML END
130     /////// Extra Java code END
131     /**
132      * Cloning constructor.
133      */
134     public DriveAerial(DriveAerial original)
135     {
136         this.Normalized = original.Normalized;
137         this.AltitudeVelocity = original.AltitudeVelocity;
138         this.LinearVelocity = original.LinearVelocity;
139         this.LateralVelocity = original.LateralVelocity;
140         this.RotationalVelocity = original.RotationalVelocity;
141     }
142 
143     @Override
144     public String toString()
145     {
146         return toMessage();
147     }
148 
149     public String toHtmlString()
150     {
151         return super.toString()
152                 + "<b>AltitudeVelocity</b> : "
153                 + String.valueOf(AltitudeVelocity)
154                 + " <br/> "
155                 + "<b>LinearVelocity</b> : "
156                 + String.valueOf(LinearVelocity)
157                 + " <br/> "
158                 + "<b>LateralVelocity</b> : "
159                 + String.valueOf(LateralVelocity)
160                 + " <br/> "
161                 + "<b>RotationalVelocity</b> : "
162                 + String.valueOf(RotationalVelocity)
163                 + " <br/> "
164                 + "<b>Normalized</b> : "
165                 + String.valueOf(Normalized)
166                 + " <br/> "
167                 + "";
168     }
169 
170     public String toMessage()
171     {
172 
173         StringBuilder buf = new StringBuilder();
174         buf.append("DRIVE");
175         buf.append(" {Normalized ").append(Normalized).append("}");
176         buf.append(" {AltitudeVelocity ").append(AltitudeVelocity).append("}");
177         buf.append(" {LinearVelocity ").append(LinearVelocity).append("}");
178         buf.append(" {LateralVelocity ").append(LateralVelocity).append("}");
179         buf.append(" {RotationalVelocity ").append(RotationalVelocity).append("}");
180 
181         return buf.toString();
182     }
183 }