Open awesomebytes opened 10 years ago
Hey, thanks for writing!
My feeling is that yes, Go is awesome. For ROS, it has built into the language this feature of typed channels. I think they will map very nicely onto ROS publish/subscribe. Besides the good fit for ROS, I think the Go designers basically looked at a bunch of the stuff that causes trouble for software engineers and built in solutions. So it is garbage-collected, it is compiled, but the compiler is so fast you can actually treat even medium-sized Go programs as scripts. It has strong typing, but has the nice ":=" operator which keeps it from being so verbose. The parallelization features are super nice for ROS. The ease of making in-line functions makes parallelization and event-handling really slick.
Anyway, yes I would love help on rosgo. What you see here so far is just me playing around and getting familiar with the ROS/Go pairing. I have definitely gotten some ideas down, but none of them are complete.
The genmsg stuff is probably done the wrong way for a serious "rosgo" implementation. I was frustrated with how slow the python-based message generation is in ROS, and I thought I could do better with compiled Go. I probably could, ultimately, but it would be a big duplication of effort. A better solution to get rosgo going is to use the existing msggen stuff in ROS and just create new Go language templates. It would be a much faster route to Go message support.
One thing that is a bit of a frustration is the lack of template ("generics") support in Go. Templates are used heavily in roscpp to handle message processing of all the different message types. For Go, my presumption was to just put all the stuff that would have been templated into the code generated by msggen. It would serve the same purpose but not need templates in the language. Another option is to find one of the implementations of templates/generics for golang that's out there on the web and adopt it. I'm a little leery of that, but it might be practical. Finally of course you could do all the generic message stuff with go's reflection support, but I'm afraid that would be slower and/or less clear in the code. Still, would be a pure-go solution.
I have more to say, but I have to go for now. I'd love to talk more about the possibilities.
One thing I really want to see happen is to make a rosgo "node" not be tied to a single process, like they are in roscpp. I would like them to act more like nodelets in roscpp, where you can have a bunch of nodes which communicate within one process, or can be run independently. I have a mockup of that idea in here where a go program acts a lot like a roslaunch file, but of course runs all the nodes in a single process.
To make this work, I figure there will be a "master" object in rosgo that routes pub/sub messages etc directly from one rosgo node to another rosgo node in the same process and also does the regular network pub/sub to communicate outside the process. This "master" object should not be just a global instance like it effectively is in roscpp. Instead it should be created in the "launch" go file and handed to each node. That way we can make other implementations of the "master" interface and use them to implement different communication protocols, or a standalone master, etc. All without needing changes to the node code.
Dude, you are a guru! haha I should learn quite a bit of Go and then how the internals of ROS communication work to be able to help it seems. I have plenty of experience with ROS, mainly from Python, but as "an user" we could say. Never got really down to watch the implementation of roscore, publisher, subscribers and so.
I'm having some hard deadlines in the next days, so I expect to procrastinate some of this nights probably, perfect chance to play with Go.
"expect to procrastinate" - haha! uh, great! :)
Getting into the communication details, for me at least, has involved a fair amount of experimentation. The ROS documentation is pretty poor for "how to implement for a new language".
Hi again,
Looks like someone else has been working harder on this than I have: https://github.com/akio/rosgo_core/ They even have a ros-wiki page up: http://wiki.ros.org/rosgo
I'm a teeny bit jealous but mostly glad that someone else is working on it. It looks like they are a lot farther along than I am, so you should check out their stuff.
For one side, cool! There is a lot of work done! From the other, aww it looked like a cool project to work on "from scratch". I had no time to start learning go :( Did you look if Aki has implemented some of the cool concepts you wanna use from Go for ROS? Maybe it would be a nice issue to open about.
Aki took the more sensible approach, and built on the systems already created for ROS stuff, like message generation templates. They build slower, since they run in Python and CMake, but I'm sure it was a shorter path to get a working ROS-Go binding than I was heading down.
I haven't suggested changing the way he's done things, as I want only to encourage him. :)
If there is time in the future for optimization, that would be great. At least now we can send and receive messages.
Hello hersh, This is not really an issue, is just the easiest way to contact with you. I wanted to learn golang, and I was searching for ROS support for go and casually I found out in your repo that you are (or were) working on it thanks to your answer to a pull request in moveit_ros.
Want some help so I get some homework to force myself to learn some go? And in general, is go awesome? Does it seem to fit into solving some kind of problem in ROS? (parallelization of some kind I expect).
See you around!