Hackers needed: help run 2.0 software on 1.0 HW


#22

Haven’t configured the firmware modules in the database for my sensor config. Only just getting to grips with openag_ python and how it fits in with openag_brain. Have had the database running and changed the camera params in it once. But have yet to find out how to configure firmware modules.

pi@raspberrypi:~ $ rostopic list
/diagnostics
/environment_1/camera_1/camera_info
/environment_1/camera_1/image_raw
/rosout
/rosout_agg

Have copied the command line interface commands can use this one, but the firmware ones will take me some time to work out.

pi@raspberrypi:~ $ openag db show
Using local server at “http://localhost:5984

I have a populated database on this card from about a month ago before making this attempt to catch up with the code changes. I also have the docker containers on this card, but they are stopped at the moment. they have there own database.


Perpetual AMA for Caleb
#23

Just found a post in the, Motherboard Sensors and Wiring, thread on this forum, It’s all about the fact that the seeed base shield I2C pins do not connect up to the I2C sockets on the arduino Mega 2560, so when you connect the TSL2561 light sensor to the shield it is not actually connected to the I2C on the Mega board. The two pins should be connected to SDA pin 20 and SCL pin 21 on the Mega. I’ve put a couple of jumper wires in. I’l try it later and report back.

Ok, have just been trying three different sketches for the sensor, so far only the 2012 seed tech code gives a decent output. It just prints out the, TSL2561, readVisibleLux() code from the Digital_light_TSL2561.h code. This is enough to tell whether or not a light is switched on. i just used an LED light switched on and off with background room illumination to detect a change in the values. The sensor is capable of a lot more but if this is all that is required then, ’ it’s a wrap ’


#24

Hey @gordonb,

Not sure if you are still looking for help with this but I had a go with it last and this weekend and have reached a problem of which I was hoping you could help out. Note, I’m not a programmer but am willing to learn!

What I did so far is install the openag_brain on my raspberry pi, test the tsl2561 code I found on an Arduino, and attempt to wrap the tsl2561 code as instructed in the doc files on the OpenAg github. My github for the tsl2561 files here.

The first error I received appears to be related to the Arduino code:
> In file included from /home/pi/Documents/branch_tsl2561/_build/src/src.ino:1:0:
> .pioenvs/megaatmega2560/module/branch_tsl2561.h:128:30: error: cannot declare variable ‘TSL2561’ to be of abstract type ‘TSL2561_CalculateLux’
> extern TSL2561_CalculateLux TSL2561;
> ^

Here’s the full error log:

`ipi@raspberrypi:~/Documents/branch_tsl2561 $ openag firmware run_module -p csv -t upload
OpenAg firmware project initialized!
Parsing firmware module type "module" from lib folder
Parsing firmware module "module" from modules file
Installing library [ 345 ]:
Already installed
Updating "openag_firmware_module"
Already up-to-date.
[Mon Sep 12 06:28:08 2016] Processing megaatmega2560 (platform: atmelavr, board: megaatmega2560, framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------
avr-g++ -o .pioenvs/megaatmega2560/src/tmp_ino_to.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DPLATFORMIO=021102 -DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560 -DOPENAG_CATEGORY_SENSORS -DOPENAG_CATEGORY_ACTUATORS -DARDUINO=10608 -I.pioenvs/megaatmega2560/FrameworkArduino -I.pioenvs/megaatmega2560/FrameworkArduinoVariant -I.pioenvs/megaatmega2560/openag_firmware_module -I.pioenvs/megaatmega2560/rosserial_arduino_ID345 -I.pioenvs/megaatmega2560/module -Isrc src/tmp_ino_to.cpp
In file included from /home/pi/Documents/branch_tsl2561/_build/src/src.ino:1:0:
.pioenvs/megaatmega2560/module/branch_tsl2561.h:128:30: error: cannot declare variable ‘TSL2561’ to be of abstract type ‘TSL2561_CalculateLux’
extern TSL2561_CalculateLux  TSL2561;
^
.pioenvs/megaatmega2560/module/branch_tsl2561.h:106:7: note:   because the following virtual functions are pure within ‘TSL2561_CalculateLux’:
class TSL2561_CalculateLux : public Module {
^
In file included from .pioenvs/megaatmega2560/module/branch_tsl2561.h:36:0,
from /home/pi/Documents/branch_tsl2561/_build/src/src.ino:1:
.pioenvs/megaatmega2560/openag_firmware_module/openag_module.h:18:18: note: 	virtual void Module::begin()
virtual void begin() = 0;
^
.pioenvs/megaatmega2560/openag_firmware_module/openag_module.h:19:18: note: 	virtual void Module::update()
virtual void update() = 0;
^
/home/pi/Documents/branch_tsl2561/_build/src/src.ino:13:1: error: ‘Tsl2561’ does not name a type
std_msgs::Float32 module_lux_msg;
^
/home/pi/Documents/branch_tsl2561/_build/src/src.ino: In function ‘void setup()’:
/home/pi/Documents/branch_tsl2561/_build/src/src.ino:20:3: error: ‘module’ was not declared in this scope
}
^
/home/pi/Documents/branch_tsl2561/_build/src/src.ino: In function ‘void loop()’:
/home/pi/Documents/branch_tsl2561/_build/src/src.ino:29:3: error: ‘module’ was not declared in this scope
if (module.get_lux(module_lux_msg)) {
^
avr-gcc -o .pioenvs/megaatmega2560/FrameworkArduino/wiring_shift.o -c -std=gnu11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DPLATFORMIO=021102 -DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560 -DOPENAG_CATEGORY_SENSORS -DOPENAG_CATEGORY_ACTUATORS -DARDUINO=10608 -I.pioenvs/megaatmega2560/FrameworkArduino -I.pioenvs/megaatmega2560/FrameworkArduinoVariant .pioenvs/megaatmega2560/FrameworkArduino/wiring_shift.c
avr-ar rcs .pioenvs/megaatmega2560/libopenag_firmware_module.a
avr-ranlib .pioenvs/megaatmega2560/libopenag_firmware_module.a
avr-g++ -o .pioenvs/megaatmega2560/rosserial_arduino_ID345/duration.o -c -fno-exceptions -fno-threadsafe-statics -std=gnu++11 -g -Os -Wall -ffunction-sections -fdata-sections -mmcu=atmega2560 -DF_CPU=16000000L -DPLATFORMIO=021102 -DARDUINO_ARCH_AVR -DARDUINO_AVR_MEGA2560 -DOPENAG_CATEGORY_SENSORS -DOPENAG_CATEGORY_ACTUATORS -DARDUINO=10608 -I.pioenvs/megaatmega2560/FrameworkArduino -I.pioenvs/megaatmega2560/FrameworkArduinoVariant -I.pioenvs/megaatmega2560/openag_firmware_module -I.pioenvs/megaatmega2560/rosserial_arduino_ID345 -I.pioenvs/megaatmega2560/module .pioenvs/megaatmega2560/rosserial_arduino_ID345/duration.cpp
scons: *** [.pioenvs/megaatmega2560/src/tmp_ino_to.o] Error 1
==================================================== [ ERROR ] Took 5.97 seconds ====================================================
Error: Compilation failed

Let me know if you need more information.

Cheers!
-A


#25

@adrianlu awesome, thanks for your contribution. This looks like a C++ type problem. Could you file this issue so we can track it? https://github.com/OpenAgInitiative/openag_brain/issues


#26

Hi , have also been working on code for this sensor, got some pointers from serein which are over on the, Openag-ui web app build diary, thread which might help with your code.
Since then I have changed from trying to modfy the .h and .cpp files for the TSL2561 from Seeed Tech to using the openag_mhz16 sensor code as a model as this is for i2C bus sensors.( The TSL2561 sends it’s data on the i2C bus )
It still uses those files but you create two new .h and .cpp files which call the Seed files. The new .h file is called by the, module.json file in your working directory and passes the information to the system variable, light_illuminance. At least that is how I think it works.
The code, so far is on , https://github.com/MisterBurnley/openag_TSL256, I’m still trying to get it to work, if you would like to look at it and let me know what you think. There is also a lot of info about how the TSL2561 works on the Adafruit website www.adafruit.com/product/439.


#27

Hi gordon, still hacking at getting code working for the TSL2561, I am using the openag_mhz16 code as a model, https://github.com/MisterBurnley/openag_TSL256 and getting the following errors:
pi@raspberrypi:~ cd openag_TSL2561 pi@raspberrypi:~/openag_TSL2561 openag firmware run_module -p csv -t upload
OpenAg firmware project initialized!
Parsing firmware module type “am2315” from server
Parsing firmware module type “atlas_do” from server
Parsing firmware module type “atlas_ec” from server
Parsing firmware module type “atlas_orp” from server
Parsing firmware module type “atlas_ph” from server
Parsing firmware module type “atlas_rgb” from server
Parsing firmware module type “binary_actuator” from server
Parsing firmware module type “dht22” from server
Parsing firmware module type “ds18b20” from server
Parsing firmware module type “gc0012” from server
Parsing firmware module type “mhz16” from server
Parsing firmware module type “pwm_actuator” from server
Parsing firmware module type “software_pwm_actuator” from server
Parsing firmware module type “module” from lib folder
Parsing firmware module “module” from modules file
Error: The /home/pi/openag_TSL2561 is not a PlatformIO project.

To manage libraries in global storage /home/pi/.platformio/lib,
please use platformio lib --global install or specify custom storage platformio lib --storage-dir /path/to/storage/ install.
Check platformio lib --help for details.
Updating "openag_firmware_module"
Already up-to-date.
Traceback (most recent call last):
File “/usr/local/bin/openag”, line 9, in
load_entry_point(‘openag==0.1.4’, ‘console_scripts’, ‘openag’)()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 716, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 696, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1060, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/openag/cli/firmware/init.py”, line 345, in run_module
ctx.invoke(run, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 534, in invoke
return callback(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/openag/cli/firmware/init.py”, line 248, in run
codegen.write_to(f)
File “/usr/local/lib/python2.7/dist-packages/openag/cli/firmware/base.py”, line 304, in write_to
plugin.on_output(mod_name, output_name, f)
File “/usr/local/lib/python2.7/dist-packages/openag/cli/firmware/plugins/csv.py”, line 66, in on_output
"CSV plugin doesn’t support outputs of type " + msg_type
RuntimeError: CSV plugin doesn’t support outputs of type std_msgs/Int64

The openag_mh16 code compiles OK , not sure what to look for next ?


#28

@JohnB I think @DougieFresh knows…


#29

So… the short explanation is that the CSV plugin doesn’t like your message type. You just have to add “std_msgs/Int64” to this line of code. Or you could compile with the ROS plugin instead (openag firmware run_module -p ros -t upload) and use rosserial_python to test it.


#30

Thanks Dougie, have found the csv plugin and added the code, still gives the same error message ?
Using the ROS plugin to compile the code gives much clearer error codes. So have been working with that and made some local changes to see if I could get the code running, still have some more to try, will commit to the repo tomorrow to reflect local copy changes.


#31

22.00 hours GMT over here on the East Coast Uk, well have completed the latest commits of the TSL2561 sensor to the repo, but still no compilation success on my setup. I’m getting a really weird error telling me that the compiler cannot find my openag_lit2561.h file, ??? when using ros to compile yet I know it exists, checked for typos rigourously, saved and re-saved the file ??? also the change to the csv code seems not to be having any effect., the error code is still the same. I have replicated the structure of the mhz16 sensor code as closely as I can so, if that compiles, then logic says that so should my version ? Bit like Where’s Wally, can you spot the mistake ??


#32

@JohnB can you link to your sensor repo?


#33

New to git-hub so at present only used it to store and hand modify code. Have looked for instructions on how to link to a repo, not sure which to follow so if you tell me what to do then I’ll have a go.
Just going to make some more commits and then re-download the repo and try again in case there have been some local corruptions to see if that makes a difference, also think it might have something to do with how I have coded the 12c address, then I’ll try and work out how to clone the repo onto the raspberryPi so I can ‘Push’ and ‘Pull’

Update: have just cloned the updated repo and the , .h , file has been found, latest errors below,
pi@raspberrypi:~/openag_TSL2561 $ openag firmware run_module -p ros -t uploadInitializing PlatformIO project
OpenAg firmware project initialized!
Parsing firmware module type “am2315” from server
Parsing firmware module type “atlas_do” from server
Parsing firmware module type “atlas_ec” from server
Parsing firmware module type “atlas_orp” from server
Parsing firmware module type “atlas_ph” from server
Parsing firmware module type “atlas_rgb” from server
Parsing firmware module type “binary_actuator” from server
Parsing firmware module type “dht22” from server
Parsing firmware module type “ds18b20” from server
Parsing firmware module type “gc0012” from server
Parsing firmware module type “mhz16” from server
Parsing firmware module type “pwm_actuator” from server
Parsing firmware module type “software_pwm_actuator” from server
Parsing firmware module type “module” from lib folder
Parsing firmware module “module” from modules file
Error: The /home/pi/openag_TSL2561 is not a PlatformIO project.

To manage libraries in global storage /home/pi/.platformio/lib,
please use platformio lib --global install or specify custom storage platformio lib --storage-dir /path/to/storage/ install.
Check platformio lib --help for details.
Downloading "openag_firmware_module"
Cloning into ‘openag_firmware_module’…
remote: Counting objects: 27, done.
remote: Total 27 (delta 0), reused 0 (delta 0), pack-reused 27
Unpacking objects: 100% (27/27), done.
Checking connectivity… done.
[Fri Sep 16 11:28:20 2016] Processing megaatmega2560 (platform: atmelavr, board: megaatmega2560, framework: arduino)

Verbose mode can be enabled via -v, --verbose option
Converting src.ino
Collected 28 compatible libraries
Looking for dependencies…
Library Dependency Graph
|-- <rosserial_arduino>
|-- <openag_TSL2561>
| |-- <rosserial_arduino>
| |-- <openag_module>
| |-- v1.0
Compiling .pioenvs/megaatmega2560/src/src.ino.o
Archiving .pioenvs/megaatmega2560/libFrameworkArduinoVariant.a
Indexing .pioenvs/megaatmega2560/libFrameworkArduinoVariant.a
Compiling .pioenvs/megaatmega2560/FrameworkArduino/CDC.o
Compiling .pioenvs/megaatmega2560/FrameworkArduino/HardwareSerial.o
Compiling .pioenvs/megaatmega2560/FrameworkArduino/HardwareSerial0.o
In file included from lib/module/openag_lit2561.h:6:0,
from /home/pi/openag_TSL2561/_build/src/src.ino:1:
lib/module/TSL2561.h:113:35: error: ISO C++ forbids declaration of ‘TSL2561_Address’ with no type [-fpermissive]
TSL2561_Address (int i2c_address);
^
In file included from /home/pi/openag_TSL2561/_build/src/src.ino:1:0:
lib/module/openag_lit2561.h:18:3: error: ‘TSL2561_Address’ does not name a type
TSL2561_Address _sensor;
^
Compiling .pioenvs/megaatmega2560/FrameworkArduino/HardwareSerial1.o
Compiling .pioenvs/megaatmega2560/FrameworkArduino/HardwareSerial2.o
*** [.pioenvs/megaatmega2560/src/src.ino.o] Error 1

back to C++ concept school for me.


#34

@JohnB I’m pretty sure Raspbian Jesse has git installed by default, so you should be able to git clone the repo as usual when logged in to the Raspberry Pi’s terminal program.


#35

Yes git is installed. Have followed instructs on how to set up a local repo and also created an ssh key to my github account from the RPi. Still hacking with the cloned repo code so have not tried to push any changes back to the master yet.
The current errors appear to show that there is something wrong with the way I have coded the inclusion of the TSL2561 .h and ,cpp files, centred around the i2c address. I have followed the mhz16 example but they are not quite the same, but of course I might have some typos as well !!
Don’t want to commit anything to change what is in the repo so need to work out how to show changes on github without changing the master.


#36

@johnb this might help: Video intro to Git and Github.


#37

Ok have watched the push pull video by Daniel and locally committed only the file change I wanted then used git push to send the change to the github repo. That worked OK. I probably need to create another repo that isn’t a clone of the TSL2561 sensor code.
Ok, I can now link to the sensor repo on my github account.


#38

@JohnB, did you managed to get TSL2561 driver working?

To my surprise, I have found that sensor today trying to clean up my hobby drawers (I even don’t remember that I bought one) so I guess I can help to fix the code if that is still required.


#39

Hi Serein, yes just this minute, yeeh!!! just pushed the code up to my GitHub repo, MisterBurnley.
been working on a version based on the, openag_mhz16 co2 sensor code that Leon wrote. Great to know if you get a reading on your sensor.

I’ve stripped it back to the bare minimum doing trial and error until it compiled. have tried both the arduino serial monitor and, platformio serialports monitor, but don’t see any output. Help is definitely still required.

The driver code is from seeed, https://github.com/Seeed-studio/Grove_Digital_Light_sensor.
Info about the sensor is here: http://wiki.seeedstudio.com/wiki/Grove_-_Digital_Light_Sensor.
Info at adafruit about the power supply 3.3v or 5v, basically the newer offerings have a voltage regulator so that you can run it on either voltage the older ones are 3.3v only.
https://learn.adafruit.com/tsl2561/wiring.

I’ve left the i2c address, as you suggested, at 29 as defined in TSL2561.h and that works when I run the code on the arduino ide, but it can be changed on the hardware if there are any conflicts with other sensors that use the i2c bus.

Bought a raspberry pi 3 so that I could put my pi2 into the ’ Fridge Gro Bot ’ and get a working test bed for the version 2 code. So haven’t tried it on the Pi2 yet. Will swap the card into the Pi2 to try it in the next few days.

Update : have compiled the code successfully on the raspberry pi 2.


#40

Hi Serein, have you had a chance to see if the code for the TSL2561 works ?
I’m not getting much joy with the, ui, output, there is no graph plot. Typed in the long_test recipe that Gordon posted but the UI gives, unable to start recipe error.
I have a DHT22 temp and Humidity sensor attached but no readings from that either. I have it plugged into A0, the analogue port but I notice that some online information has it in, D2 ?? Do you know which one we should use to be compatible with the code or does the code need changing ?


#41

No, but will try to take a look over the weekend.

Did you add fixture for this sensor to firmware_module ? If so you can set the pin number in arguments section. Looking at the driver’s source code I see that it uses digitalRead to read the value and based on this conversation you should connect to digital pin indeed. That is all my guess, since I’m using am2315 sensor for air temp and humidity.