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 a joint.
9    *
10   * Corresponding GameBots command is DRIVE.
11   *
12   */
13  public class DriveJoint extends CommandMessage
14  {
15      //constructor for the sixth type
16      public DriveJoint(String Name, int Steer, int Order, double Value)
17      {
18          this.Name = Name;
19          this.Steer = Steer;
20          this.Order = Order;
21          this.Value = Value;
22      }
23  
24      /**
25       * <p></p>WARNING: this is empty-command constructor, you have to use
26       * setters to fill it up!
27       */
28      public DriveJoint()
29      {
30      }
31      /////// Properties BEGIN
32      //sixth type - Name, Steer, Order, Vlaue
33      //the joint name
34      protected String Name = null;
35  
36      public String getName()
37      {
38          return Name;
39      }
40  
41      public DriveJoint setName(String Name)
42      {
43          this.Name = Name;
44          return this;
45      }
46      //the steer angle of the joint
47      protected int Steer = 0;
48  
49      public int getSteer()
50      {
51          return Steer;
52      }
53  
54      public DriveJoint setSteer(int Steer)
55      {
56          this.Steer = Steer;
57          return this;
58      }
59      /*
60       * the control mode. It can be 0-2. 0: zero-order control. It controls
61       * rotation angle. 1: first-order control. It controls spin speed. 2:
62       * second-order control. It controls torque.
63       */
64      protected int Order = 0;
65  
66      public int getOrder()
67      {
68          return Order;
69      }
70  
71      public DriveJoint setOrder(int Order)
72      {
73          this.Order = Order;
74          return this;
75      }
76      /*
77       * the control value. For zero-order control, it’s the rotation angle in
78       * radians. For first-order control, it’s the spin speed in radians/second.
79       * For second-order control, it’s the torque.
80       */
81      protected double Value = 0;
82  
83      public double getValue()
84      {
85          return Value;
86      }
87  
88      public DriveJoint setValue(double Value)
89      {
90          this.Value = Value;
91          return this;
92      }
93  
94      /*
95       * Example: DRIVE {Name LeftFWheel} {Steer 1.57} will steer the left front
96       * wheel 90 degrees. DRIVE {Name LeftFWheel} {Order 1} {Value 0.175} will
97       * make the left front wheel spin at 0.175 radians/second, i.e. 10
98       * degrees/second
99       */
100     /////// Properties END
101     /////// Extra Java code BEGIN
102     /////// Additional code from xslt BEGIN
103     /////// Additional code from xslt END
104     /////// Extra Java from XML BEGIN
105     /////// Extra Java from XML END
106     /////// Extra Java code END
107     /**
108      * Cloning constructor.
109      */
110     public DriveJoint(DriveJoint original)
111     {
112         this.Name = original.Name;
113         this.Steer = original.Steer;
114         this.Order = original.Order;
115         this.Value = original.Value;
116     }
117 
118     @Override
119     public String toString()
120     {
121         return toMessage();
122     }
123 
124     public String toHtmlString()
125     {
126         return super.toString()
127                 + "<b>Name</b> : "
128                 + String.valueOf(Name)
129                 + " <br/> "
130                 + "<b>Steer</b> : "
131                 + String.valueOf(Steer)
132                 + " <br/> "
133                 + "<b>Order</b> : "
134                 + String.valueOf(Order)
135                 + " <br/> "
136                 + "<b>Value</b> : "
137                 + String.valueOf(Value)
138                 + " <br/> "
139                 + "";
140     }
141 
142     public String toMessage()
143     {
144 
145         StringBuilder buf = new StringBuilder();
146         buf.append("DRIVE");
147 
148         if(Name != null)
149         {
150             buf.append(" {Name ").append(Name).append("}");
151         }
152         buf.append(" {Steer ").append(Steer).append("}");
153         buf.append(" {Order ").append(Order).append("}");
154         buf.append(" {Value ").append(Value).append("}");
155 
156         return buf.toString();
157     }
158 }