Communication Architecture Usage |
| Submitted by jscholz on Sat, 2010-03-27 16:20 |
Making Daemons
The process of making ach daemons is now standardized into a few basic steps which everyone should conform to in order to keep things simple and extensible. A simple example can be found in slogd.
- If an existing message type will not work, define a message type in a .proto file. Typically this will be done in lib/somatic/proto/somatic.proto
- Generate the protobuf code for this message type by calling protobuf-c-compiler on your .proto file (just do make; make debinstall in "humanoids/lib/somatic/trunk" if you defined your message here).
- Implement the daemon
Defining message types
You can define message types in any proto file, as long as you build it with the protobuf-c-compiler and link the output into your project. See the google documentation for an explanation of what protocol buffers is and why we need it. It is recommend to define your message types in somatic. Somatic provides some handy macros and functions that make the process of writing daemons faster. Don't worry about learning all the stuff in somatic, just look at one of the daemons (like jachd) that uses it.
Generating Protobuf Code
Calling protoc-c on yoour .proto file will generate c-code which can be found in *.pb-c.c and *.pb-c.h, and give you all the custom protobuf functions for your type (init, pack, unpack, etc). If you defined your message type in somatic, then just do a make and it'll build everything for you. Link against somatic (or your compiled protoc library) to get access to the protocol buffers calls that we need. In the stuff I've done so far, all I've needed is the message type's init, pack, and unpack functions.
Potential pifalls:- When using SOMATIC_D_GET and SOMATIC_D_PUT, the type argument (parameter 2) is the PREFIX for the appropriate libsomatic protobuf functions, NOT the type itself.
Implement your daemon
Write some code that talks to the specific hardware or whatever else it is that your trying to do and communicates with protobuf messages over an ach channel. See any of the drivers in SVN for an example.
Installation
- You should be on Ubuntu 10.04 Lucid i386 (others should work, but you're on your own).
- Add our Apt Repository
-
$ sudo apt-get update -
apt-get install build-essential gfortran maxima libatlas-sse2-dev libatlas3gf-sse2 libprotobuf-c0-dev protobuf-c-compiler python-protobuf libprotobuf5 libprotobuf-dev make-common amino ach somatic libntcan libsdh -
If you need to install a system on the robot, install esdcan drivers. Follow instructions on LWA code setup and compilation. If you are installing on a user PC, install esdcan from the repo.
$ sudo apt-get install esdcan -
Install daemons directly from the SVN.
$ cd drivers/amciod; make && make debinstall$ cd drivers/pcio; make && make debinstall$ cd drivers/joystick; make && make debinstall - If you are on Krang, ask Neil.







