BowlerKernel
PDVelocityConfiguration.java
Go to the documentation of this file.
1 package com.neuronrobotics.sdk.pid;
2 
3 import com.neuronrobotics.sdk.common.BowlerDatagram;
4 import com.neuronrobotics.sdk.common.ByteList;
5 
6 // TODO: Auto-generated Javadoc
11 
13  private int group=0;
14 
16  private double KP=1;
17 
19  private double KD=0;
20 
25 
26  }
27 
42  public PDVelocityConfiguration(int group,boolean enabled,boolean inverted,boolean async,double KP,double KI,double KD, double latch, boolean useLatch, boolean stopOnLatch){
43  setGroup(group);
44  setKP(KP);
45  setKD(KD);
46  }
47 
55  setGroup( conf.getData().get(0));
56  setKP(((double)ByteList.convertToInt(conf.getData().getBytes(1, 4),false))/100);
57  setKD(((double)ByteList.convertToInt(conf.getData().getBytes(5, 4),false))/100);
58  }
59 
65  public PDVelocityConfiguration(Object[] args) {
66  setGroup((Integer) args[0]);
67  setKP((Double) args[1]);
68  setKD((Double) args[2]);
69  }
70 
71  /* (non-Javadoc)
72  * @see java.lang.Object#toString()
73  */
74  @Override
75  public String toString(){
76  String s="PD Velocity configuration group #"+getGroup();
77  s+="\n\tConstants: P="+getKP()+" D="+getKD();
78  return s;
79  }
80 
86  public void setGroup(int group) {
87  this.group = group;
88  }
89 
95  public int getGroup() {
96  return group;
97  }
98 
104  public void setKP(double kP) {
105  KP = kP;
106  }
107 
113  public double getKP() {
114  return KP;
115  }
116 
122  public void setKD(double kD) {
123  KD = kD;
124  }
125 
131  public double getKD() {
132  return KD;
133  }
134 
140  public Object[] getArgs() {
141  return new Object[]{
142  group,
143  KP,
144  KD,
145  };
146  }
147 }
static final int convertToInt(byte[] b)
Definition: ByteList.java:911
PDVelocityConfiguration(int group, boolean enabled, boolean inverted, boolean async, double KP, double KI, double KD, double latch, boolean useLatch, boolean stopOnLatch)