How to set up and test a fixture?


#1

Software is working (UI talks to Docker based brain and default fixtures loaded successfully, db works as well). Great!

But I can’t get my head around setting up and testing a fixture - and making it output to the UI. My aim is to set up the DHT22 (in fact it is a DHT11 but it is compatible).

Combing through documentation, forum and source code I’m still struggling. Help much appreciated!

Thanks
Rasmus


#2

@bjerngaard Given that the DHT22 is already defined in the default fixture, therefore being loaded as a fixture_module_type, you’ll only need to create a fixture that adds that module as a firmware_module

Then you’d just have to run rosrun openag_brain load_fixture your_custom_fixture.json

Here is a first attempt on building a fixture for this specific example, you’d only have to make sure that you are setting the proper arguments (pin where you have connected the sensor to)

{
  "firmware_module": [
    {
      "arguments": [
        30
      ],
      "type": "dht22",
      "environment": "environment_1",
      "_id": "dht22_1"
    }
  ]
}


#3

I made a firmware module for DHT11, you can find it here. The sensors are pretty similar, but if you read a DHT11 with the DHT22 module, you will get readings like 233°C, because the way the data is to be interpreted is not the same.

I also managed to make it work with a fixture, which is in the end of this post. The variables are being shown in the GUI. However, I cannot make the recipe work yet.


#4

@david and @aguadopd thanks for the input (and sorry for the delayed response - have been traveling).

I created and loaded the fixture definition you suggested, @david.

Here are some instruction for others:

  1. use ‘nano’ to create the file defining your fixture in the Raspberry Pi operating system.
  2. then copy that file into the Docker environment using:

docker cp your_fixture.json openagbraindockerrpi_brain_1:/home/pi/your_fixture.json

  1. run openag using your fixture:

docker exec openagbraindockerrpi_brain_1 /home/pi/catkin_ws/devel/env.sh rosrun openag_brain load_fixture ~/your_fixture

Tip: Use

docker exec -it openagbraindockerrpi_brain_1 bash

to bash into the Docker environment and check that everything looks alright (the ‘exit’ command will get you out again)


#5

How do you debug (check that everything looks alright)?
I have created two fixtures, and so far they do not seem to be running or returning data.

  1. the *.h and *.cpp files run fine in Arduino with the sensors
  2. added library.json and module.json
  3. put them in git
  4. created json files for deployment
  5. ran load_fixture with no errors

docker exec openagbraindockerrpi_brain_1 /home/pi/catkin_ws/devel/env.sh rosrun openag_brain load_fixture /home/pi/openag_bpm180

The first time the outputs showed up in

rostopic list

but I have not seen them in the list since then (subsequent load_fixture runs)
The data is in the database as firmware_module and firmware_module_type
There is no data (envoronment), so it appears that no code was compiled or deployed to the Arduino.

How do I dig into more detail?


#6

have you tried

rosrun openag_brain flash?

That flashes the arduino.


#7

Thanks, that is moving things forward.
I had assumed that the initialization process (reboot) would flash the Arduino. I wonder what other assumptions I have are incorrect.

When running flash, I am getting an error (progress!).

/tmp/tmpUq91q7/src/src.ino:2:27: fatal error: openag_bpm180.h: No such file or directory
include openag_bpm180.h

openag_bpm180 is my sensor (Bosch barometric sensor)
I was assuming that the url in firmware_module_type would point it to github, and it would fetch the code. Is there a directory where the code (*.h and *.cpp) needs to be copied to?

I assume firmware_module_type is a ‘descriptor’ of a sensor (code), while firmware_module is an instance of an actual physical sensor. Thus, I could have multiple temperature sensors (multiple firmware_module entries) pointing to the same firmware_module_type. These would differ by name and output name (and pin or address):
“ceiling_temp”: {“variable”: “temperature”}
“wall_temp”: {“variable”: “temperature”}
“floor_temp”: {“variable”: “temperature”}


#8

Hi webbhm,
I am just starting to work on other fixture, and I am following the “need hackers to test” thread: Hackers needed: help run 2.0 software on 1.0 HW
It seems that *.cpp and *.h are rterieved from github, as long it is specified in type as git.


#9

Getting some qualified success.

The file not found error is generic to local or github. It turns out I didn’t have the *.h file properly committed in Github, and once it was committed, the build progressed.

Warning: rosrun openag_brain flash is tempermental. More times than not I got timeout errors (especially when verifying the upload). I also got an error of 99-platformio-udev.rules not found, but this can be ignored as the system figures out the port (reboot helped here). Keep re-running the flash, and It does eventually give a successful flash.

I am still not sure what it takes to build a sensor. My code, BPM180 barometric sensor - which works in Arduino, would compile and show up in rostopic, but would not give any output. I backed off and loaded the hardware_fixture and hardware_fixture_type from http://forum.openag.media.mit.edu/t/hackers-needed-help-run-2-0-software-on-1-0-hw/694/64 (since I have a TSL2561 LUX sensor) and it happily outputs data through rostopic, the database and the UI.

  • I know I a working build of OpenAg
  • I have a repeatable process for setting up a sensor
  • The data flow works from the Adruino through the UI

Next steps are to get the TSL2561 working with my code, then getting the BPM180 running. At that point I will try to document the steps for building and installing a new sensor.