Hackers needed: help run 2.0 software on 1.0 HW


#17

Have the TSL2561 grove light sensor and been trying to read some data from it using the seeed studio software library flashed into my arduino mega from the arduino ide on my raspberry pi, nothing.
Checked my arduino was working by flashing it with the code for the temperature and humidity sensor code for my am2302 sensor. This worked fine.
Has anyone else tried the TSL2561 sensor and got it working ? If you have then maybe mine is a dud.
Just found the adafruit code and flashed it to the arduino, the sensor gives a readout so I guess it is working.


#18

Hi Dougie, I am right in thinking that I should run sudo pip install in the ~/catkin_ws diectory, and do i need to execute, source ~/catkin_ws/devel/setup.bash, before doing so ?


#19

It shouldn’t matter where you run pip install from because it installs the package globally anyway. Also, it doesn’t matter whether or not the ROS workspace is active when you do it.


#20

Thanks for that, I have executed the code on both cards with the same result, the brain starts up and gets as far as the sensor_persistence_1-10, process then starts walltime warnings.
I only have two sensors plugged into the arduino, the temperature/humidity sensor which I tested using a standalone sketch and know is working and the TSL2561 which is giving the saturated value from the adafruit sketch but, is the sensor that needs an openag driver.
I’ll post the error printout for info purposes ( need to log into the Forum from the pi ), but at this point I’m convinced that the TLS2561 isn’t working. I’ll have a go at connecting it to the arduino without the Grove Base Shield and see if it works. so unless there is something simple I’ve missed no need to spend time on this.

process[master]: started with pid [1376]
ROS_MASTER_URI=http://localhost:11311

setting /run_id to 64e8c858-71ec-11e6-a2b8-b827eb391475
process[rosout-1]: started with pid [1389]
started core service [/rosout]
process[arduino_handler-2]: started with pid [1392]
process[environment_1/recipe_handler_1-3]: started with pid [1393]
process[environment_1/camera_1-4]: started with pid [1394]
process[environment_1/video_writer_1-5]: started with pid [1408]
process[api-6]: started with pid [1410]
process[topic_connector-7]: started with pid [1411]
process[topic_filter-8]: started with pid [1412]
process[image_persistence_1-9]: started with pid [1422]
process[sensor_persistence_1-10]: started with pid [1427]
[WARN] [WallTime: 1472917120.911186] Copyright © 2000-2005 Brian Dean, http://www.bdmicro.com/
[WARN] [WallTime: 1472917120.922600] Copyright © 2007-2009 Joerg Wunsch
[WARN] [WallTime: 1472917121.020952] User configuration file does not exist or is not a regular file, skipping
[WARN] [WallTime: 1472917121.024414] Using Port : /dev/ttyACM0
[WARN] [WallTime: 1472917121.027626] Using Programmer : wiring
[WARN] [WallTime: 1472917121.030677] Overriding Baud Rate : 115200
[WARN] [WallTime: 1472917121.380595] AVR Part : ATmega2560
[WARN] [WallTime: 1472917121.384732] Chip Erase delay : 9000 us
[WARN] [WallTime: 1472917121.388768] PAGEL : PD7
[WARN] [WallTime: 1472917121.400560] BS2 : PA0
[WARN] [WallTime: 1472917121.403637] RESET disposition : dedicated
[WARN] [WallTime: 1472917121.406987] RETRY pulse : SCK
[WARN] [WallTime: 1472917121.410361] serial program mode : yes
[WARN] [WallTime: 1472917121.414032] parallel program mode : yes
[WARN] [WallTime: 1472917121.417544] Timeout : 200
[WARN] [WallTime: 1472917121.421925] StabDelay : 100
[WARN] [WallTime: 1472917121.426129] CmdexeDelay : 25
[WARN] [WallTime: 1472917121.429933] SyncLoops : 32
[WARN] [WallTime: 1472917121.433818] ByteDelay : 0
[WARN] [WallTime: 1472917121.438638] PollIndex : 3
[WARN] [WallTime: 1472917121.441667] PollValue : 0x53
[WARN] [WallTime: 1472917121.444496] Memory Detail :
[WARN] [WallTime: 1472917121.447605] Block Poll Page Polled
[WARN] [WallTime: 1472917121.450710] Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
[WARN] [WallTime: 1472917121.453593] ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
[WARN] [WallTime: 1472917121.456710] eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.460341] flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
[WARN] [WallTime: 1472917121.463572] lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.466604] hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.470591] efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.474683] lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
[WARN] [WallTime: 1472917121.478755] calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
[WARN] [WallTime: 1472917121.482714] signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
[WARN] [WallTime: 1472917121.487968] Programmer Type : Wiring
[WARN] [WallTime: 1472917121.491204] Description : Wiring
[WARN] [WallTime: 1472917121.494156] Programmer Model: AVRISP
[WARN] [WallTime: 1472917121.497451] Hardware Version: 15
[WARN] [WallTime: 1472917121.501365] Firmware Version Master : 2.10
[WARN] [WallTime: 1472917121.505875] Vtarget : 0.0 V
[WARN] [WallTime: 1472917121.509414] SCK period : 0.1 us
[WARN] [WallTime: 1472917121.514668] Reading | ################################################## | 100% 0.02s
[WARN] [WallTime: 1472917123.430715] Writing | ################################################## | 100% 1.92s
[WARN] [WallTime: 1472917124.851137] Reading | ################################################## | 100% 1.41s


#21

Have you configured firmware modules in the database for your sensor configuration? What happens if you run rostopic list with that script running?


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