I need documentation to support a new programming language

32 views
Skip to first unread message

Claudio Carnino

unread,
Jan 27, 2018, 11:26:44 AM1/27/18
to Lightweight Communications and Marshalling
Hello LCM community!
I want to add the support to a new programming language (Swift 4) but I am not able to find all the documentation needed.

Can you share with me any technical documentation on:
1. how to create a Message type fingerprint or hash?
2. how to encode/decode the message to a buffer of data that I can pass to lcm_publish?
3. how to parse a .lcm file (XDR, RFC1832, RFC4506) so then I can generate a Swift class?

The Type Specification page is not detailed enough. Is there anything else that could help me?
Maybe some guide wrote for other languages?

Thank you very much!
Claudio

Edwin Olson

unread,
Jan 27, 2018, 6:10:25 PM1/27/18
to lcm-...@googlegroups.com
Hi Claudio, and welcome-

In all cases, the C reference implementation serves as the ultimate specification, and you'll need to spend some quality time reading that code just as you would with a stand-alone specification.

There is also some overview information which might be helpful, including some discussion of the hash method, here:


The LCM format specification was inspired largely by XDR, but is its own language.

Hope that gets you started!

-Ed

--
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.



--
Edwin Olson
Assoc. Professor, Computer Science & Engineering
University of Michigan
http://april.eecs.umich.edu

Claudio Carnino

unread,
Jan 28, 2018, 5:37:28 AM1/28/18
to lcm-...@googlegroups.com
Thanks Ed for the answer. 
I was afraid that the only way was to study the C implementation. Though I am not very familiar with C and the generate message implementation is uncommented. 

Regarding the hash method the high level view is clear. But then I am missing the knowledge of the technical implementation.

Thanks anyway.
Claudio 
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/r-oISVNgZ9I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lcm-users+...@googlegroups.com.

Tim Perkins

unread,
Jan 29, 2018, 10:23:37 AM1/29/18
to lcm-...@googlegroups.com

Hi Claudio,

I think it's great that you're interested in LCM and creating bindings for a new language. I've actually done the same thing in the past, and I learned alot doing it.

However, LCM is a little conservative in its first-class language support. If you eventually want to merge your work into the main LCM repo, you will want to coordinate with the maintainers, probably Albert. In the last few years there have been a couple "unofficial" language bindings. Those have lived in separate repos, and have been maintained by their respective authors. We added links on LCM's website and in the docs to point to them.

The last "unofficial" bindings were for, I think, Vala and Julia. There was some resistance to adding them because they are relatively obscure languages. Swift is a pretty popular language, so that shouldn't be a problem.

I hope that helps.

-- Tim


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.



--
Edwin Olson
Assoc. Professor, Computer Science & Engineering
University of Michigan
http://april.eecs.umich.edu

--
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/r-oISVNgZ9I/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.

Claudio Carnino

unread,
Jan 29, 2018, 10:39:07 AM1/29/18
to lcm-...@googlegroups.com
Thanks Tim for the reply.

The problem is that I was hoping to find some written documentation and how-tos, so I could size up my time investment. I see that this kind of docs seems to be missing. And not being familiar with C, it makes really hard to understand the logic of that code.

But thanks for the support anyway.

--
Claudio Carnino
http://tugulab.org

Tim Perkins

unread,
Jan 29, 2018, 2:36:45 PM1/29/18
to lcm-...@googlegroups.com

Yes, in this case the best spec is the code. I know that's not very helpful when you're not familiar with C.

Another approach you could consider, could be interacting with the existing C library instead of reimplementing it in Swift. Like if Swift has a FFI or similar (but I'm not really familiar with Swift). I did find this:

https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithCAPIs.html#//apple_ref/doc/uid/TP40014216-CH8-ID17

If you did go that route, you would still need to implement the message code generation. You have a bit more freedom doing that, as it can be more or less unique to the language. You just need to be able to pack and unpack messages, basically.

Claudio Carnino

unread,
Jan 29, 2018, 4:06:32 PM1/29/18
to lcm-...@googlegroups.com
I am going throw that path actually. I am using the lcm_publish and lcm_subscribe witting my swift code. I am, for now, just using lcm for communicating, but not for marshalling. I pass a buffer of data and receive a buffer of data. Then it’s my swift app encodes and decides the buffer. 

This works. But I cannot interface with nodes generate by other lcm compliant apps. I am not implementing fingerprinting and encoding/decoding per lcm spec, since I’ve not understood it. 

For now I start being able to communicate between nodes and understand if lcm satisfy my needs. Then I have to understand if it’s worth investing the time to learn the c code and add the swift support. 

I need to concentrate on my robot specific part. Which is where I have to demonstrate our product advantages. 

Have any of you thought about writing a walk through the c code that explain how to fingerprint and encode and decode. 
Like what bytes you actually write. 

If you built that kind of how to, it would be much faster for me to implement it. 

Thanks!

-- 
Claudio Carnino

Tim Perkins

unread,
Jan 29, 2018, 4:36:47 PM1/29/18
to lcm-...@googlegroups.com
Ok, I think I might be able to point you in the right direction.

The fingerprinting is actually in the generated code for some languages. For example, if you generate the Python code for a message, then open up the result, you should see some hashing and fingerprinting code. (Same thing for the Lua generated code.) I'm thinking the Python code will be easier to read, in general. Then I would reference that against `emit_python_fingerprint` in `lcmgen/emit_python.c`, which is in C, but should be pretty straight forward and having some sample output should help.

Of course that's just one piece, but maybe enough to get you started?
Reply all
Reply to author
Forward
0 new messages