Commit b9a3384e authored by René Schöne's avatar René Schöne
Browse files

Update scripts, send as sequence possible.

parent 901d7fde
#!/usr/bin/env bash
./gradlew :ros2rag.goal:installDist
./ros2rag.goal/build/install/ros2rag.goal/bin/ros2rag.goal $@
./gradlew :ros2rag.goal:installDist && \
./ros2rag.goal/build/install/ros2rag.goal/bin/ros2rag.goal $@
#!/usr/bin/env bash
./gradlew :ros2rag.receiverstub:installDist
./ros2rag.receiverstub/build/install/ros2rag.receiverstub/bin/ros2rag.receiverstub $@
./gradlew :ros2rag.receiverstub:installDist && \
./ros2rag.receiverstub/build/install/ros2rag.receiverstub/bin/ros2rag.receiverstub $@
......@@ -3,30 +3,59 @@ package de.tudresden.inf.st.ros2rag.senderstub;
import de.tudresden.inf.st.ros2rag.starter.ast.MqttHandler;
import panda.Linkstate;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
public class SenderMain {
public static void main(String[] args) throws Exception {
// either 3 or 4 arguments
// 3 arguments: topic filename wait
// 4 arguments: topic x y z
// assume 4 arguments
if (args.length < 4) {
System.err.println("Sends a new position, expected arguments: topic x y z");
if (args.length < 3 || args.length > 4) {
System.err.println("Either sends a new position, arguments: topic x y z");
System.err.println("Or reads positions from a file, arguments: topic filename wait");
return;
}
MqttHandler sender = new MqttHandler("sender stub").dontSendWelcomeMessage();
sender.setHost("localhost", 1883);
sender.waitUntilReady(2, TimeUnit.SECONDS);
final String topic = args[0];
if (args.length == 3) {
final String filename = args[1];
final int wait = Integer.parseInt(args[2]);
try {
for (String line : Files.readAllLines(Paths.get(filename))) {
if (line.isEmpty()) continue;
String[] lineSplit = line.split(";");
publish(sender, topic,
Float.parseFloat(lineSplit[0]),
Float.parseFloat(lineSplit[1]),
Float.parseFloat(lineSplit[2]));
TimeUnit.MILLISECONDS.sleep(wait);
}
} catch (InterruptedException ignore) {
}
} else {
publish(sender, topic,
Float.parseFloat(args[1]),
Float.parseFloat(args[2]),
Float.parseFloat(args[3]));
}
sender.close();
}
private static void publish(MqttHandler sender, String topic, float x, float y, float z) {
Linkstate.PandaLinkState pls = Linkstate.PandaLinkState.newBuilder()
.setName(args[0])
.setName(topic)
.setPos(Linkstate.PandaLinkState.Position.newBuilder()
.setPositionX(Float.parseFloat(args[1]))
.setPositionY(Float.parseFloat(args[2]))
.setPositionZ(Float.parseFloat(args[3]))
.setPositionX(x)
.setPositionY(y)
.setPositionZ(z)
.build())
.build();
final byte[] message = pls.toByteArray();
MqttHandler sender = new MqttHandler("sender stub").dontSendWelcomeMessage();
sender.setHost("localhost", 1883);
sender.waitUntilReady(2, TimeUnit.SECONDS);
sender.publish(topic, message);
sender.close();
}
}
#!/usr/bin/env bash
./gradlew :ros2rag.senderstub:installDist && \
./ros2rag.senderstub/build/install/ros2rag.senderstub/bin/ros2rag.senderstub $@
#!/usr/bin/env bash
./ros2rag.senderstub/build/install/ros2rag.senderstub/bin/ros2rag.senderstub $@
0.0; 0.0; 0.0
0.3; 0.3; 0.3
0.6; 0.6; 0.6
1.0; 1.0; 1.0
1.0; 1.0; 1.0
1.0; 1.0; 1.0
1.0; 1.0; 1.0
1.0; 1.0; 1.0
1.0; 1.0; 1.0
1.0; 1.0; 1.0
1.0; 0.6; 1.0
1.0; 0.3; 1.0
1.0; 0.0; 1.0
1.0; 0.0; 1.0
1.0; 0.0; 1.0
1.0; 0.0; 1.0
1.0; 0.0; 1.0
0.6; 0.0; 1.0
0.3; 0.0; 1.0
0.0; 0.0; 1.0
0.0; 0.0; 1.0
0.0; 0.0; 1.0
0.0; 0.0; 1.0
0.0; 0.0; 1.0
0.0; 0.0; 1.0
#!/usr/bin/env bash
./gradlew :ros2rag.starter:installDist
./ros2rag.starter/build/install/ros2rag.starter/bin/ros2rag.starter $@
./gradlew :ros2rag.starter:installDist && \
./ros2rag.starter/build/install/ros2rag.starter/bin/ros2rag.starter $@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment