Skip to content

Commit

Permalink
lots of random service fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Nov 17, 2023
1 parent a736fde commit c157e25
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 24 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/myrobotlab/service/Random.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,16 @@ public RandomConfig getConfig() {
super.getConfig();

config.enabled = enabled;

if (config.randomMessages == null) {
config.randomMessages = new HashMap<>();
}

for (String key : randomData.keySet()) {
RandomMessage msg = randomData.get(key);
RandomMessageConfig m = new RandomMessageConfig();
m.service = msg.name;
m.method = msg.method;
m.maxIntervalMs = msg.maxIntervalMs;
m.minIntervalMs = msg.minIntervalMs;
m.data = msg.data;
Expand All @@ -316,12 +322,16 @@ public RandomConfig getConfig() {
@Override
public RandomConfig apply(RandomConfig c) {
super.apply(c);
enabled = c.enabled;
if (c.enabled) {
enable();
} else {
disable();
}

try {
for (String key : c.randomMessages.keySet()) {
RandomMessageConfig msgc = c.randomMessages.get(key);
addRandom(msgc.minIntervalMs, msgc.maxIntervalMs, key.substring(0, key.lastIndexOf(".")), key.substring(key.lastIndexOf(".") + 1), msgc.data);
addRandom(key, msgc.minIntervalMs, msgc.maxIntervalMs, msgc.service, msgc.method, msgc.data);
if (!msgc.enabled) {
disable(key);
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/org/myrobotlab/service/config/InMoov2Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,40 +282,40 @@ public Plan getDefault(Plan plan, String name) {
random.enabled = false;

// setup name references to different services
RandomMessageConfig rm = new RandomMessageConfig(3000, 8000, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0);
RandomMessageConfig rm = new RandomMessageConfig(name, "setLeftArmSpeed", 3000, 8000, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0);
random.randomMessages.put(name + ".setLeftArmSpeed", rm);

rm = new RandomMessageConfig(3000, 8000, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0);
rm = new RandomMessageConfig(name, "setRightArmSpeed", 3000, 8000, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0);
random.randomMessages.put(name + ".setRightArmSpeed", rm);

rm = new RandomMessageConfig(3000, 8000, 0.0, 5.0, 85.0, 95.0, 25.0, 30.0, 10.0, 15.0);
rm = new RandomMessageConfig(name, "moveLeftArm", 000, 8000, 0.0, 5.0, 85.0, 95.0, 25.0, 30.0, 10.0, 15.0);
random.randomMessages.put(name + ".moveLeftArm", rm);

rm = new RandomMessageConfig(3000, 8000, 0.0, 5.0, 85.0, 95.0, 25.0, 30.0, 10.0, 15.0);
rm = new RandomMessageConfig(name, "moveRightArm", 3000, 8000, 0.0, 5.0, 85.0, 95.0, 25.0, 30.0, 10.0, 15.0);
random.randomMessages.put(name + ".moveRightArm", rm);

rm = new RandomMessageConfig(3000, 8000, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0);
rm = new RandomMessageConfig(name, "setLeftHandSpeed", 3000, 8000, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0);
random.randomMessages.put(name + ".setLeftHandSpeed", rm);

rm = new RandomMessageConfig(3000, 8000, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0);
rm = new RandomMessageConfig(name, "setRightHandSpeed", 3000, 8000, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0, 8.0, 25.0);
random.randomMessages.put(name + ".setRightHandSpeed", rm);

rm = new RandomMessageConfig(3000, 8000, 10.0, 160.0, 10.0, 60.0, 10.0, 60.0, 10.0, 60.0, 10.0, 60.0, 130.0, 175.0);
rm = new RandomMessageConfig(name, "moveLeftHand", 3000, 8000, 10.0, 160.0, 10.0, 60.0, 10.0, 60.0, 10.0, 60.0, 10.0, 60.0, 130.0, 175.0);
random.randomMessages.put(name + ".moveLeftHand", rm);

rm = new RandomMessageConfig(3000, 8000, 10.0, 160.0, 10.0, 60.0, 10.0, 60.0, 10.0, 60.0, 10.0, 60.0, 130.0, 175.0);
rm = new RandomMessageConfig(name, "moveRightHand", 3000, 8000, 10.0, 160.0, 10.0, 60.0, 10.0, 60.0, 10.0, 60.0, 10.0, 60.0, 130.0, 175.0);
random.randomMessages.put(name + ".moveRightHand", rm);

rm = new RandomMessageConfig(3000, 8000, 8.0, 20.0, 8.0, 20.0, 8.0, 20.0);
rm = new RandomMessageConfig(name, "setHeadSpeed",3000, 8000, 8.0, 20.0, 8.0, 20.0, 8.0, 20.0);
random.randomMessages.put(name + ".setHeadSpeed", rm);

rm = new RandomMessageConfig(3000, 8000, 70.0, 110.0, 65.0, 115.0, 70.0, 110.0);
rm = new RandomMessageConfig(name, "moveHead", 3000, 8000, 70.0, 110.0, 65.0, 115.0, 70.0, 110.0);
random.randomMessages.put(name + ".moveHead", rm);

rm = new RandomMessageConfig(3000, 8000, 2.0, 5.0, 2.0, 5.0, 2.0, 5.0);
rm = new RandomMessageConfig(name , "setTorsoSpeed", 3000, 8000, 2.0, 5.0, 2.0, 5.0, 2.0, 5.0);
random.randomMessages.put(name + ".setTorsoSpeed", rm);

rm = new RandomMessageConfig(3000, 8000, 85.0, 95.0, 88.0, 93.0, 70.0, 110.0);
rm = new RandomMessageConfig(name, "moveTorso", 3000, 8000, 85.0, 95.0, 88.0, 93.0, 70.0, 110.0);
random.randomMessages.put(name + ".moveTorso", rm);

// == Peer - headTracking =============================
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/org/myrobotlab/service/config/RandomConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ public static class RandomMessageConfig {
public long minIntervalMs;
public long maxIntervalMs;
public boolean enabled = true;
public String service;
public String method;

public RandomMessageConfig() {
}

public RandomMessageConfig(long minIntervalMs, long maxIntervalMs, double... ranges) {
public RandomMessageConfig(String service, String method, long minIntervalMs, long maxIntervalMs, double... ranges) {
this.service = service;
this.method = method;
this.minIntervalMs = minIntervalMs;
this.maxIntervalMs = maxIntervalMs;
this.data = new Range[ranges.length / 2];
Expand All @@ -29,7 +33,9 @@ public RandomMessageConfig(long minIntervalMs, long maxIntervalMs, double... ran
}
}

public RandomMessageConfig(long minIntervalMs, long maxIntervalMs, int... ranges) {
public RandomMessageConfig(String service, String method, long minIntervalMs, long maxIntervalMs, int... ranges) {
this.service = service;
this.method = method;
this.minIntervalMs = minIntervalMs;
this.maxIntervalMs = maxIntervalMs;
this.data = new Range[ranges.length / 2];
Expand All @@ -42,7 +48,9 @@ public RandomMessageConfig(long minIntervalMs, long maxIntervalMs, int... ranges
}
}

public RandomMessageConfig(long minIntervalMs, long maxIntervalMs, float... ranges) {
public RandomMessageConfig(String service, String method, long minIntervalMs, long maxIntervalMs, float... ranges) {
this.service = service;
this.method = method;
this.minIntervalMs = minIntervalMs;
this.maxIntervalMs = maxIntervalMs;
for (int i = 0; i < (ranges.length / 2); i += 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ <h3>
(


<span ng-repeat="param in value.data">[
<span ng-repeat="param in value.data">
<span ng-if="param.min !== null">
{{param.min}} - {{param.max}}
[ {{param.min}} - {{param.max}} ]
</span>
<span ng-repeat="item in param.set">
{{item}}
<span ng-if="!$last || param.min !== null">, </span>
</span>]
{{param.set}}
<span ng-if="!$last">, </span>

</span>
Expand Down Expand Up @@ -91,4 +88,4 @@ <h3>
</div>
</div>
</div>
<!-- {{parameters}} -->

0 comments on commit c157e25

Please sign in to comment.