- No Title
No Description
Create a new tutorial:
Batmon ROS Package Installation Tutorial
OS Installation
This package was installed and tested on a Raspberry Pi 3 with Ubiquity's Ubuntu 16.04 image installed, which can be found here.
You may need to turn off some of its scripts that autostart.
sudo systemctl disable magni-base
I2C Software Setup on the Pi
Once the image is installed on the pi and it is connected to the internet, \n run these commands to install I2C packages.
sudo apt install i2c-tools sudo apt install libi2c-dev
Now by default the will have an I2C port at /dev/i2c-1
This port does not allow for clock stretching, so we need to disable it and then create a new one on /dev/i2c-3
To disable the port run
sudo raspi-config
A menu should appear, select option 3 for Interfacing Options
Then select P4 for I2C
Then select NO, and then FINISH to exit.
Now we need to add some commands to /boot/config.txt, run:
sudo nano /boot/config.txt
Add the following line to the bottom of that file to set the I2C bus speed to 100khz.
dtparam=i2c_baudrate=100000
The I2C clock line is linked with the VPU core on the Pi, who's frequency can change with load. This can cause issues with communication so add the following line to set the core to a fixed frequency.
core_freq=250
Now to create a new I2C port on /dev/i2c-3 add:
dtoverlay=i2c-gpio,bus=3,i2c_gpio_sda=02,i2c_gpio_scl=03
Save changes to the document and then reboot for them to take effect.
sudo reboot now
Hardware Setup for the Raspberry Pi
Now connect the Batmon into the pins on the Raspberry Pi.
The SDA line should be connected to GPIO3 and the SCL line should be connected to GPIO5
Do not forget to add ground to one of the several ground pins on the board, GPIO9 is the clostest one.
You can find a reference for the pinnout of the pi here.
If the pi was hooked up correctly and the batmon is powered then running the following command should return a matrix of addresses.
i2cdetect -y 3
Note depending on your batmon version the address could be either 0x0E or 0x0B.
If there is an address in the resulting matrix then the hardware was hooked up correctly.
== Ros Setup on the Pi == Ubuquity's image comes preinstalled with ROS, to install the batmon package clone it from the github repo.
First change your directory to the one in which you need to clone it to.
cd catkin_ws/src/
Then clone the GitHub repo:
git clone https://github.com/rotoye/batmon-ros.git raspi_batmon
Now edit /include/raspi_batmon/smbus.h to ensure your ROS node is reading from the correct address.
nano ~/catkin_ws/src/raspi_batmon/include/raspi_batmon/smbus.h
Edit the define for I2CADDRESS3 to match the address that appeared in i2cdetect -y 3
Now if you start the node the data from the batmon should be published in /BatteryState_{SerialNumber} where {SerialNumber} is the serial number of your batmon
e.x /BatteryState_00001
You can start the node with rosrun raspi_batmon i2c_reader
In a separate terminal, you can find the message with rostopic echo /BatteryState_{SerialNumber}
e.x. rostopic echo /BatteryState_00001