Skip to content
Snippets Groups Projects
Commit 06a3ec6c authored by René Schöne's avatar René Schöne
Browse files

Streamline receiver.

parent 47b8af00
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import config.Robotconfig.RobotConfig;
import de.tudresden.inf.st.ros2rag.starter.ast.MqttUpdater;
import de.tudresden.inf.st.ros2rag.starter.data.DataConfiguration;
import de.tudresden.inf.st.ros2rag.starter.data.DataJoint;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import panda.Linkstate.PandaLinkState;
......@@ -19,6 +20,7 @@ import java.util.concurrent.TimeUnit;
public class Main {
private static final Logger logger = LogManager.getLogger(Main.class);
private String topicPattern;
public static void main(String[] args) throws Exception {
Main main = new Main();
......@@ -32,6 +34,7 @@ public class Main {
private void run(DataConfiguration config) throws IOException, InterruptedException {
final CountDownLatch finish = new CountDownLatch(1);
int topicMaxLength = 0;
MqttUpdater receiver = new MqttUpdater("receiver stub");
receiver.setHost(config.mqttHost);
receiver.waitUntilReady(2, TimeUnit.SECONDS);
......@@ -39,7 +42,9 @@ public class Main {
receiver.newConnection(config.dataConfigTopic, this::printDataConfig);
for (DataJoint joint : config.joints) {
receiver.newConnection(joint.topic, this::printPandaLinkState);
topicMaxLength = Math.max(topicMaxLength, joint.topic.length());
}
this.topicPattern = "%" + topicMaxLength + "s";
receiver.newConnection("components", bytes -> {
String message = new String(bytes);
......@@ -70,8 +75,10 @@ public class Main {
PandaLinkState.Orientation tmpOrientation = pls.getOrient();
PandaLinkState.TwistLinear tmpTwistLinear = pls.getTl();
PandaLinkState.TwistAngular tmpTwistAngular = pls.getTa();
logger.info("{}: pos({},{},{}), orient({},{},{},{})," +
" twist-linear({},{},{}), twist-angular({},{},{})",
// panda::panda_link0: pos(-3.0621333E-8,-1.5197388E-8,3.3411725E-5), orient(0.0,0.0,0.0,0.0), twist-linear(0.0,0.0,0.0), twist-angular(0.0,0.0,0.0)
logger.printf(Level.INFO,topicPattern + ": pos(% .5f,% .5f,% .5f), ori(%.1f,%.1f,%.1f,%.1f)," +
" twL(%.1f,%.1f,%.1f), twA(%.1f,%.1f,%.1f)",
pls.getName(),
tmpPosition.getPositionX(),
tmpPosition.getPositionY(),
......
......@@ -6,7 +6,7 @@
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment