-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements on the BCB battery module #727
Conversation
- thread_period was not found in the conf file and most probably assumed to be zero. - A mutex was missing in the close method. - The voltage and current values were not divided by 1000 (the board sends the values in mV and mA) - It was not properly checked if the char were read correctly or not - The sync mechanism is too restrictive and seems to be not working on Linux - The methods returning the battery status and temperature were always returning false, avoiding the BatteryWrapper to stream the values. - The print of the received buffer was not readable.
PR to fix the configuration files in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks heaps @S-Dafarra for this work 👍🏻
I believe it's important that @randaz81 reviews this.
⚠ Please, don't merge the PR straight away as I will most likely squash and merge it.
Any news @randaz81 ? |
CCing some people I bothered during the process @maggia80 @MrAndrea @kouroshD @DanielePucci |
Merging. Anyway, we can always modify anything needed later on. |
It reports the info listed in robotology/icub-main#727. Related issue
…100) It reports the info listed in robotology/icub-main#727. Related issue
@S-Dafarra can we do a test tomorrow with the robot? |
We can try with the purple if that is available. The greeny is currently busy with some experiments. |
…100) It reports the info listed in robotology/icub-main#727. Related issue
Intro
This PR attempts at improving the
bcbBattery
module, fixing the following issues:thread_period
was not found in the conf file and most probably assumed to be zero.In addition, I added the following:
yarprobotinterface
).How to test it on the robot head
(I will move these lines to a proper place afterward, this is just for reference)
Bluetooth setup
First, it is necessary to understand the Bluetooth ID relative to the BCB board installed on the robot. For example, in
iCubGenova04
this is namedRNBT-8223
(in general it should beRNBT-
something) and has the address00:06:66:E7:82:23
.First, you need to pair it. In order to do so, you can use
bluetoothctl
. In particular, after runningbluetoothctl
, you can trust the device withand then
It may ask you to enter
yes
just to check that the passcode is correct.After that, it is not possible to connect since the board is not compatible with
BlueZ
. In order to use it as a serial device, it is possible to userfcomm
:This connects to the Bluetooth and creates a serial device named
/dev/rfcomm0
inraw
mode. The problem withrfcomm connect
is that it keeps the connection with the Bluetooth board even when not necessary. Alternatively, it is possible to useThis connects to the Bluetooth only when the port
/dev/rfcomm0
is opened. The drawback is that this interprets the serial communication as TTY. This causes the\r
chars to be changed into\n
, hence messing up with the communication protocol of the BCB board. This can be fixed by usingOn the robot side, whenever we connect to the BCB board, a blue LED should light up between the "Motors" and "CPU" button. .
Unfortunately, it seems that the LED to notify that a connection is done is not installed in the BCB currently on
iCubGenova04
. Still, there is a blue LED visible from inside the backpack. This gets constant blue when connected to the Bluetooth (i.e. when opening the file/dev/rfcomm0
).When nothing is connected, it blinks:
VID_20210216_173130.mp4
How to run the connection automatically at startup
The connections made via
rfcomm
get reset when shutting down. In order to have them working at startup, I created a system service as follows. First I created the filebattery_bluetooth.service
in the folder/etc/systemd/system/
as followsbattery_bluetooth.service
contentThis service runs once the
battery_bluetooth.sh
script once at startup after running thebluetooth
service.battery_bluetooth.sh
contentThe scripts first tries to connect using
rfcomm connect
. If it works (hencerfcomm connect
is still alive), releases the connection. Then it tries runningrfcomm bind
andstty
checking the outputs in case of errors. If there is any error, it tries again at most 10 times.This service can be enabled at startup with
and started with
In case there were errors starting the service, it is possible to inspect the output of the script with
This script can also be run after startup in case the connection is not working, with
Running the module
In case of
iCubGenova04
, I already added the configuration files and they are installed. Hence, to run the module it is sufficient to runotherwise, it is possible to go to the
battery
folder in theexperimentalSetups
ofrobots-configuration
and runOnce it is running, it is possible to visualize the battery status from anywhere in
yarp
network by running