Openag_brain problem - sensor development


#1

I am trying to develop new sensor code (BPM180 barometer), and keep hitting problems when I finally try to put it into open_ag,

  • this was a fresh build of docker, to make sure I had a ‘clean’ open_ag system.
  • RaspberryPi 3
  • Arduino Mega 2560

The problem is with:

rosrun openag_brain main -f default

  • I took existing sensor C code and modified it to include ROS messages and the OpenAg module.
  • It runs fine, using the Arduino IDE (on my PC and on the Raspberry Pi)
  • The library was moved to github, and json files created.
  • I moved the library into Docker and made it executable

cd ~/openag_bpm180

  • Within docker, I ran:

openag firmware run_module -p csv -t upload

  • It compiled, downloaded and ran fine. Using another terminal window I opened up:

platformio serialports monitor

  • and watched the data flow. I could see the same data in the Arduino IDE serial monitor window (though it fought with platformio till I shut it off).
  • I modified the default.json to include this sensor as the only ‘firmware_module_type’ and left the software declarations alone.

I keep hitting some errors. I got the same errors using the original default.json (which I tried before modifying). I get the following errors:

  • socket.error: [Errno 98] Address already in use: (’’, 5000)
  • error: [Errno 9] File descriptor was closed in another greenlet
  • [api-4] process has died [pid 1821, exit code 1, cmd
  • [ERROR] [WallTime: 1483651358.552622] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

Insights or suggestions would be appreciated.
When I get this working, I will post the full development instructions.

Full log below

pi@6b2a2ddd89ca:~/openag_bpm180$ rosrun openag_brain main -f default
Initializing the database
Applying CouchDB configuration [##############################------] 85% 0dApplying CouchDB configuration [####################################] 100%
Creating databases [####################################] 100%
Pushing design documents
Applying fixture /home/pi/catkin_ws/src/openag_brain/fixtures/default.json
environment [####################################] 100%
software_module_type [####################################] 100%
firmware_module_type [####################################] 100%
software_module [####################################] 100%
Generating launch file
Processing module “arduino_handler” from server
Processing module “recipe_handler_1” from server
Processing module “api” from server
Processing module “topic_connector” from server
Processing module “topic_filter” from server
Processing module “video_writer_1” from server
Processing module “image_persistence_1” from server
Processing module “sensor_persistence_1” from server
Spawning software modules
… logging to /home/pi/.ros/log/d76e6c7e-d381-11e6-90c2-0242ac120003/roslaunch-6b2a2ddd89ca-1794.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://6b2a2ddd89ca:46385/

SUMMARY

PARAMETERS

  • /arduino_handler/should_flash: False
  • /image_persistence_1/min_update_interval: 3600
  • /rosdistro: indigo
  • /rosversion: 1.11.19
  • /sensor_persistence_1/max_update_interval: 600
  • /sensor_persistence_1/min_update_interval: 5

NODES
/environment_1/
recipe_handler_1 (openag_brain/recipe_handler.py)
video_writer_1 (openag_brain/video_writer.py)
/
api (openag_brain/api.py)
arduino_handler (openag_brain/handle_arduino.py)
image_persistence_1 (openag_brain/image_persistence.py)
sensor_persistence_1 (openag_brain/sensor_persistence.py)
topic_connector (openag_brain/topic_connector.py)
topic_filter (openag_brain/topic_filter.py)

ROS_MASTER_URI=http://localhost:11311

core service [/rosout] found
process[arduino_handler-1]: started with pid [1813]
process[environment_1/recipe_handler_1-2]: started with pid [1814]
process[environment_1/video_writer_1-3]: started with pid [1818]
process[api-4]: started with pid [1821]
process[topic_connector-5]: started with pid [1831]
process[topic_filter-6]: started with pid [1832]
process[image_persistence_1-7]: started with pid [1880]
process[sensor_persistence_1-8]: started with pid [1890]
Traceback (most recent call last):
File “/home/pi/catkin_ws/src/openag_brain/src/openag_brain/software_modules/api.py”, line 301, in
server.serve_forever()
File “/usr/lib/python2.7/dist-packages/gevent/baseserver.py”, line 282, in serve_forever
self.start()
File “/usr/lib/python2.7/dist-packages/gevent/baseserver.py”, line 234, in start
self.init_socket()
File “/usr/lib/python2.7/dist-packages/gevent/pywsgi.py”, line 639, in init_socket
StreamServer.init_socket(self)
File “/usr/lib/python2.7/dist-packages/gevent/server.py”, line 78, in init_socket
self.socket = self.get_listener(self.address, self.backlog, self.family)
File “/usr/lib/python2.7/dist-packages/gevent/server.py”, line 89, in get_listener
return _tcp_listener(address, backlog=backlog, reuse_addr=self.reuse_addr, family=family)
File “/usr/lib/python2.7/dist-packages/gevent/server.py”, line 153, in _tcp_listener
sock.bind(address)
File “”, line 1, in bind
socket.error: [Errno 98] Address already in use: (’’, 5000)
Exception in thread Thread-3:
Traceback (most recent call last):
File “/usr/lib/python2.7/threading.py”, line 810, in __bootstrap_inner
self.run()
File “/usr/lib/python2.7/threading.py”, line 763, in run
self.__target(*self.__args, **self.__kwargs)
File “/opt/ros/indigo/lib/python2.7/dist-packages/rospy/impl/tcpros_base.py”, line 153, in run
(client_sock, client_addr) = self.server_sock.accept()
File “/usr/lib/python2.7/dist-packages/gevent/socket.py”, line 314, in accept
self._wait(self._read_event)
File “/usr/lib/python2.7/dist-packages/gevent/socket.py”, line 298, in _wait
self.hub.wait(watcher)
File “/usr/lib/python2.7/dist-packages/gevent/hub.py”, line 341, in wait
result = waiter.get()
File “/usr/lib/python2.7/dist-packages/gevent/hub.py”, line 568, in get
return self.hub.switch()
File “/usr/lib/python2.7/dist-packages/gevent/hub.py”, line 331, in switch
return greenlet.switch(self)
error: [Errno 9] File descriptor was closed in another greenlet

[api-4] process has died [pid 1821, exit code 1, cmd /home/pi/catkin_ws/src/openag_brain/src/openag_brain/software_modules/api.py __name:=api __log:=/home/pi/.ros/log/d76e6c7e-d381-11e6-90c2-0242ac120003/api-4.log].
log file: /home/pi/.ros/log/d76e6c7e-d381-11e6-90c2-0242ac120003/api-4*.log
[ERROR] [WallTime: 1483651358.552622] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino


#2

This happens when you try to run 2 instances of the code at the same side. The second API instance crashes because it can’t listen on the port that the first instance is already using. The openag_brain code starts when you start the Docker container, and I’m guessing you’re logging into the container and starting a second instance.


#3

That may be the case, but it is not evident.

  • When I run:

rostopic list

I only see rosout and rosout_agg, I would think that I would see more topics.

  • I also thought that the API should be up, but when I put the following in a browser:

http://localhost:5984/_openag/api/0.0.1/

I get {“error”:“error”,“reason”:"{conn_failed,{error,econnrefused}}"}

If it is up and running, it has significant problems.

  1. Is there any documentation on how to quickly validate the openag system? (test suite?)
  2. Is there a way to gracefully shut down openag, or at least block it from running on a re-boot?

p.s.
I did a

docker_compose restart

then

rostopic echo diagnostics

and getting a lot of message: no sync with device; however, going into another command line and doing a platformio gives data (until it errors out from multiple access on port).


#4

I don’t think there will be any topics if you don’t have any sensors set up. You could try rosnode list to see if things are running instead. Did you create a firmware_module instance for the sensor you are trying to use?