Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
JastAdd
ros2rag
Commits
06a3ec6c
Commit
06a3ec6c
authored
Jun 30, 2020
by
René Schöne
Browse files
Streamline receiver.
parent
47b8af00
Changes
2
Hide whitespace changes
Inline
Side-by-side
ros2rag.receiverstub/src/main/java/de/tudresden/inf/st/ros2rag/receiverstub/Main.java
View file @
06a3ec6c
...
...
@@ -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
(),
...
...
ros2rag.receiverstub/src/main/resources/log4j2.xml
View file @
06a3ec6c
...
...
@@ -6,7 +6,7 @@
</Console>
</Appenders>
<Loggers>
<Root
level=
"
debug
"
>
<Root
level=
"
info
"
>
<AppenderRef
ref=
"Console"
/>
</Root>
</Loggers>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment