I cant get lcm-spy to decode lcm messages

1,187 views
Skip to first unread message

Benjamin Fain

unread,
Sep 22, 2016, 4:02:16 PM9/22/16
to Lightweight Communications and Marshalling
I have lcm messages that were created using python. Since lcm-spy needs a jar file I have recreated the lcm definition files into java and tried turning them into .jars. I also tried to do this with just the example_t.lcm and I keep getting errors on the "javac -cp lcm.jar exlcm/*.java" part.

suas@suas:~/Desktop/LCM_EXP$ javac -cp lcm.jar exlcm/*.java
exlcm/example_t.java:10: package lcm.lcm does not exist
import lcm.lcm.*;
^
exlcm/example_t.java:12: package lcm.lcm does not exist
public final class example_t implements lcm.lcm.LCMEncodable
                                               ^
exlcm/example_t.java:80: cannot find symbol
symbol  : class LCMDataInputStream
location: class exlcm.example_t
        this(new LCMDataInputStream(data));
                 ^
exlcm/example_t.java:78: recursive constructor invocation
    public example_t(byte[] data) throws IOException
           ^
4 errors

------
Not sure why it cannot find lcm.lcm


Thanks for the help!
example_t.java

Benjamin Fain

unread,
Sep 22, 2016, 4:11:48 PM9/22/16
to Lightweight Communications and Marshalling
I also have Java 1.6 installed as I found 1.7 or 1.8 could give problems based on the forum

suas@suas:~$ java -version
java version "1.6.0_39"
OpenJDK Runtime Environment (IcedTea6 1.13.11) (6b39-1.13.11-0ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

Jonathan Bendes

unread,
Sep 25, 2016, 7:24:33 PM9/25/16
to lcm-...@googlegroups.com
Hey Ben,

Did you make sure that you're pointing to the correct lcm.jar file during your attempted javac of your java files? Can you open that .jar file with a file browser and make sure it contains the lcm java files?

Best,
Jonathan

--
You received this message because you are subscribed to the Google Groups "Lightweight Communications and Marshalling" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lcm-users+...@googlegroups.com.
To post to this group, send email to lcm-...@googlegroups.com.
Visit this group at https://groups.google.com/group/lcm-users.
For more options, visit https://groups.google.com/d/optout.

Benjamin Fain

unread,
Sep 26, 2016, 7:30:26 AM9/26/16
to lcm-...@googlegroups.com

Jonathan,
Thanks for the response.
After it kept erroring out on import lcm.lcm.* I opened the .Java in the exclum folder to find import lcm.lcm.* to be where it keeps erroring. I was not able to locate an lcm.jar file to point Java to. In the lcm install folder I could not find it. Only lcm-logger, lcm-logger and others where there. Internet searchs also did not help me. Is it an extra I have to download from git?

Regards,
Ben


To unsubscribe from this group and stop receiving emails from it, send an email to lcm-users+unsubscribe@googlegroups.com.

To post to this group, send email to lcm-...@googlegroups.com.
Visit this group at https://groups.google.com/group/lcm-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Lightweight Communications and Marshalling" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lcm-users/Nn-5KgtE2pE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lcm-users+unsubscribe@googlegroups.com.

Benjamin Fain

unread,
Sep 26, 2016, 7:31:57 AM9/26/16
to lcm-...@googlegroups.com

Also this is on Ubuntu the 14.04. And I have upgrade to Java 1.7 but can revert.

Jonathan Bendes

unread,
Sep 26, 2016, 7:45:36 PM9/26/16
to lcm-...@googlegroups.com
Hey Ben,

You built the jar when you built lcm if you configured your build correctly. Did you follow the steps here?
https://lcm-proj.github.io/build_instructions.html

I am far more familiar with the zcm build tool chain but I believe there may be some parallels. When you built, did you make sure Java was enabled in your build? I believe it should enable automatically if you have java installed and will notify you accordingly in the configure step.

Best,
Jonathan

To unsubscribe from this group and stop receiving emails from it, send an email to lcm-users+...@googlegroups.com.

To post to this group, send email to lcm-...@googlegroups.com.
Visit this group at https://groups.google.com/group/lcm-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Lightweight Communications and Marshalling" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lcm-users/Nn-5KgtE2pE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lcm-users+...@googlegroups.com.

To post to this group, send email to lcm-...@googlegroups.com.
Visit this group at https://groups.google.com/group/lcm-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lightweight Communications and Marshalling" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lcm-users+...@googlegroups.com.

Benjamin Fain

unread,
Sep 27, 2016, 9:09:13 AM9/27/16
to lcm-...@googlegroups.com
Jonathan,

Thanks for the help. I had to find the lcm.jar file and then point to it for java to see.

For those finding this question through google you can run the below provided on https://github.com/lcm-proj/lcm/blob/master/examples/lcm-spy/buildjar.sh

For those new to the area like myself the if statements are used to set up the lcm.jar path for java.

I used "export CLASSPATH=/user/local/share/java/lcm.jar" which is the first part of the if statement. I am running ubuntu 14.04 (This only adds the variable to the current terminal you have open!) 

the lcm-gen line assumes you have your types in a folder called ../types. if you are already in the directory just delete the "../types/"
The javac line can be updated to "javac -cp lcm.jar name of folder/*.java" Java can already see lcm.jar now so no need to call the variable in its place.
The last line creates the jar with name "my_types" assuming the folder name is exlcm.

Also this works with java 1.6 and 1.7 (not sure about 1.8) You also need to make sure you have the java sdk installed (includes javac) and not just the jre. on unbuntu use "java -version" in a terminal.

# try to automatically determine where the LCM java file is
LCM_JAR=`pkg-config --variable=classpath lcm-java`
if [ $? != 0 ] ; then
if [ -e /usr/local/share/java/lcm.jar ] ; then
LCM_JAR=/usr/local/share/java/lcm.jar
else
if [ -e ../../lcm-java/lcm.jar ] ; then
LCM_JAR=../../lcm-java/lcm.jar
fi
fi
fi
lcm-gen -j ../types/*.lcm
javac -cp $LCM_JAR exlcm/*.java
jar cf my_types.jar exlcm/*.class

To unsubscribe from this group and stop receiving emails from it, send an email to lcm-users+unsubscribe@googlegroups.com.

To post to this group, send email to lcm-...@googlegroups.com.
Visit this group at https://groups.google.com/group/lcm-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Lightweight Communications and Marshalling" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lcm-users/Nn-5KgtE2pE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lcm-users+unsubscribe@googlegroups.com.

To post to this group, send email to lcm-...@googlegroups.com.
Visit this group at https://groups.google.com/group/lcm-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Lightweight Communications and Marshalling" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lcm-users+unsubscribe@googlegroups.com.

To post to this group, send email to lcm-...@googlegroups.com.
Visit this group at https://groups.google.com/group/lcm-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Lightweight Communications and Marshalling" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lcm-users/Nn-5KgtE2pE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lcm-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages