Use of light Sensor with turtlebot3 using ROS

Hi, I want to use the light sensor with the turtlebot3 and get the data using ROS Noetic.
I followed the steps that are mentioned in turtlebot3 emanual(link: ‘OpenCR 1.0’), after that when I try to use the command ’ ./update.sh $OPENCR_PORT $OPENCR_MODEL.opencr’(link: ‘TurtleBot3’) it shows error and the port"/dev/ttyACM0" is not being recognized.

Moreover, in the code of the light sensor mentioned in the turtlebot3 emanual, there is no line ROS code is written so, I am concern about how can I run the ROS nodes for light sensor.

Kindly help me to run the light sensor with turtlebot3 using ROS Noetic.

This error is because the serial port used in the default TurtleBot3 configuration isn’t accessible on your system. There are two common causes for this issue:

  • The port may be called something different on your system. Sometimes the port may have a different number assigned.
  • Your user doesn’t have access to write to the serial port. Running as sudo or changing the permissions for the serial port will resolve this.

I’m not sure what exactly you are asking for with your second point, but documentation on the TB3 SLAM package can be found on the ROS wiki.

Hi, Jonathon,

Thank you for your reply:

  1. For the port recognizing: Initially it was detecting and I tried basic teleoperation, but after uploading the light sensor code to OpenCR, it is not recognizing despite I am following all steps to install packages again from the website.

  2. I want to use light sensor with turtlebot3, I followed all the steps that are mentioned on the official turtlebot3 Emanual, but I
    don’t know how to run the code using ROS since in the light sensor code mentioned on the website, there is no line of ROS. My objective is get the light sensor data to my system using ROS subscriber. Please help me with this issue asap since my deadline is coming.

Thank you
Regards
Shivam

  1. When you uploaded the light sensor code to the OpenCR board, it removed the code required to use the OpenCR for the TurtleBot3. You will need to reinstall the OpenCR TurtleBot firmware using the update command to use it with ROS again.
  2. The Arduino sketch files used for TB3 operation on ROS are available here, just be sure to use the one for your TB3 configuration. You will need to integrate your sensor reading code into this sketch to report the sensor as an ROS publisher, and upload it to your OpenCR.

Hello Jonathon,

Following your previous advice; I have been able to compile my light sensor code with the Arduino sketch files that you sent me. I am now trying to upload the code onto my OpenCR. Unfortunately, I have been facing a consistent error message “cmd_read_board_name fail : 0xF020” which has been stifling my progress. If you have any advice as to how I could successfully upload my code to the OpenCR. Please do not hesitate to share it with me. I will once again be posting the error message(s) down below

I appreciate your help thus far, you have been a godsend!

Thanks
Shivam

Arduino: 1.8.19 (Linux), Board: “OpenCR Board, OpenCR Bootloader”

ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
sketch/turtlebot3_core.ino.cpp.o: In function geometry_msgs::Point::Point()': /home/ahmed/snap/arduino/85/.arduino15/packages/OpenCR/hardware/OpenCR/1.5.2/libraries/turtlebot3_ros_lib/geometry_msgs/Point.h:25: warning: undefined reference to illumCallback(sensor_msgs::Illuminance const&)’
/home/ahmed/snap/arduino/85/.arduino15/packages/OpenCR/hardware/OpenCR/1.5.2/libraries/turtlebot3_ros_lib/geometry_msgs/Point.h:25: warning: undefined reference to `illuminanceCallback(sensor_msgs::Illuminance const&)’
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
ERROR: ld.so: object ‘/snap/arduino/85/$LIB/bindtextdomain.so’ from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
Sketch uses 184552 bytes (23%) of program storage space. Maximum is 786432 bytes.
Global variables use 46732 bytes of dynamic memory.
opencr_ld ver 1.0.2
An error occurred while uploading the sketch
opencr_ld_main

file name : /tmp/arduino_build_759338/turtlebot3_core.ino.bin
file size : 181 KB
Open port OK
Clear Buffer Start
Clear Buffer End

cmd_read_board_name fail : 0xF020

Hello,

I once again have another error which I am currently struggling to solve. I have successfully uploaded the compiled code onto the turtlebot. I am now encountering an error which outputs “Tried to publish before configured, topic id 131”. This error is appearing inside of the terminal window in which I am launching the roslaunch command.

If you have any suggestions as to how I could solve this error, it would be greatly appreciated. Your help has not gone unappreciated!

Once again, I will be posting the error message(s) below.

SUMMARY

PARAMETERS

  • /rosdistro: noetic
  • /rosversion: 1.15.11
  • /turtlebot3_core/baud: 115200
  • /turtlebot3_core/port: /dev/ttyACM0
  • /turtlebot3_core/tf_prefix:
  • /turtlebot3_lds/frame_id: base_scan

NODES
/
turtlebot3_core (rosserial_python/serial_node.py)
turtlebot3_diagnostics (turtlebot3_bringup/turtlebot3_diagnostics)
turtlebot3_lds (ld08_driver/ld08_driver)

ROS_MASTER_URI=http://192.168.0.196:11311

process[turtlebot3_core-1]: started with pid [2244]
process[turtlebot3_lds-2]: started with pid [2245]
process[turtlebot3_diagnostics-3]: started with pid [2246]
/dev/ttyACM0 OpenCR Virtual ComPort in FS Mode
/dev/ttyUSB0 CP2102 USB to UART Bridge Controller
FOUND LiDAR_LD08 @port :/dev/ttyUSB0
[INFO] [1683900507.010733]: ROS Serial Python Node
[INFO] [1683900507.050099]: Connecting to /dev/ttyACM0 at 115200 baud
[INFO] [1683900509.170383]: Requesting topics…
[INFO] [1683900509.360679]: Note: publish buffer size is 1024 bytes
[INFO] [1683900509.368741]: Setup publisher on sensor_state [turtlebot3_msgs/SensorState]
[INFO] [1683900509.386934]: Setup publisher on firmware_version [turtlebot3_msgs/VersionInfo]
[INFO] [1683900509.769946]: Setup publisher on imu [sensor_msgs/Imu]
[INFO] [1683900509.788884]: Setup publisher on cmd_vel_rc100 [geometry_msgs/Twist]
[INFO] [1683900509.928308]: Setup publisher on odom [nav_msgs/Odometry]
[INFO] [1683900509.947655]: Setup publisher on joint_states [sensor_msgs/JointState]
[ERROR] [1683900509.959059]: Creation of publisher failed: Checksum does not match: 4ddae7f048e32fda22cac764685e3974,476f837fa6771f6e16e3bf4ef96f8770
[INFO] [1683900509.976326]: Setup publisher on magnetic_field [sensor_msgs/MagneticField]
[INFO] [1683900509.994108]: Setup publisher on illuminance [sensor_msgs/Illuminance]
[INFO] [1683900510.575230]: Setup publisher on /tf [tf/tfMessage]
[INFO] [1683900510.600442]: Note: subscribe buffer size is 1024 bytes
[INFO] [1683900510.608574]: Setup subscriber on cmd_vel [geometry_msgs/Twist]
[INFO] [1683900510.632532]: Setup subscriber on sound [turtlebot3_msgs/Sound]
[INFO] [1683900510.657214]: Setup subscriber on motor_power [std_msgs/Bool]
[INFO] [1683900510.799895]: Setup subscriber on reset [std_msgs/Empty]
[INFO] [1683900510.827401]: Setup subscriber on illuminance_topic [sensor_msgs/Illuminance]
[INFO] [1683900512.516045]: Setup TF on Odometry [odom]
[INFO] [1683900512.527190]: Setup TF on IMU [imu_link]
[INFO] [1683900512.537803]: Setup TF on MagneticField [mag_link]
[INFO] [1683900512.548656]: Setup TF on JointState [base_link]
[ERROR] [1683900512.622545]: Tried to publish before configured, topic id 131
[INFO] [1683900512.630870]: Requesting topics…
[INFO] [1683900515.182262]: Calibration End
[INFO] [1683900515.281515]: Setup publisher on sensor_state [turtlebot3_msgs/SensorState]
[INFO] [1683900515.293434]: Setup publisher on firmware_version [turtlebot3_msgs/VersionInfo]
[INFO] [1683900515.304815]: Setup publisher on imu [sensor_msgs/Imu]
[INFO] [1683900515.315969]: Setup publisher on cmd_vel_rc100 [geometry_msgs/Twist]
[INFO] [1683900515.327994]: Setup publisher on odom [nav_msgs/Odometry]
[INFO] [1683900515.339780]: Setup publisher on joint_states [sensor_msgs/JointState]
[ERROR] [1683900515.351288]: Creation of publisher failed: Checksum does not match: 4ddae7f048e32fda22cac764685e3974,476f837fa6771f6e16e3bf4ef96f8770
[INFO] [1683900515.362460]: Setup publisher on magnetic_field [sensor_msgs/MagneticField]
[INFO] [1683900515.373108]: Setup publisher on illuminance [sensor_msgs/Illuminance]
[INFO] [1683900515.388594]: Setup publisher on /tf [tf/tfMessage]
[ERROR] [1683900515.414794]: Tried to publish before configured, topic id 131
[INFO] [1683900515.423299]: Requesting topics…
[ERROR] [1683900515.500528]: Tried to publish before configured, topic id 131
[INFO] [1683900515.508704]: Requesting topics…
[ERROR] [1683900515.606293]: Tried to publish before configured, topic id 131
[INFO] [1683900515.614474]: Requesting topics…
[ERROR] [1683900515.712783]: Tried to publish before configured, topic id 131
[INFO] [1683900515.721219]: Requesting topics…
[ERROR] [1683900515.817456]: Tried to publish before configured, topic id 131
[INFO] [1683900515.826375]: Requesting topics…
[ERROR] [1683900515.924927]: Tried to publish before configured, topic id 131
[INFO] [1683900515.933353]: Requesting topics…
[ERROR] [1683900516.029583]: Tried to publish before configured, topic id 131
[INFO] [1683900516.038178]: Requesting topics…
[ERROR] [1683900516.136255]: Tried to publish before configured, topic id 131
[INFO] [1683900516.144432]: Requesting topics…
[ERROR] [1683900516.242981]: Tried to publish before configured, topic id 131
[INFO] [1683900516.255962]: Requesting topics…
[ERROR] [1683900516.349010]: Tried to publish before configured, topic id 131
[INFO] [1683900516.359220]: Requesting topics…
[ERROR] [1683900516.454101]: Tried to publish before configured, topic id 131
[INFO] [1683900516.462500]: Requesting topics…
[ERROR] [1683900516.560683]: Tried to publish before configured, topic id 131
[INFO] [1683900516.569119]: Requesting topics…
[ERROR] [1683900516.666463]: Tried to publish before configured, topic id 131
[INFO] [1683900516.675929]: Requesting topics…
[ERROR] [1683900516.772262]: Tried to publish before configured, topic id 131
[INFO] [1683900516.780741]: Requesting topics…
[ERROR] [1683900516.878323]: Tried to publish before configured, topic id 131
[INFO] [1683900516.886464]: Requesting topics…
[ERROR] [1683900516.983977]: Tried to publish before configured, topic id 131
[INFO] [1683900516.992582]: Requesting topics…
[ERROR] [1683900517.090626]: Tried to publish before configured, topic id 131
[INFO] [1683900517.099993]: Requesting topics…
[ERROR] [1683900517.195957]: Tried to publish before configured, topic id 131
[INFO] [1683900517.204731]: Requesting topics…
[ERROR] [1683900517.302357]: Tried to publish before configured, topic id 131
[INFO] [1683900517.311394]: Requesting topics…
[ERROR] [1683900517.409309]: Tried to publish before configured, topic id 131
[INFO] [1683900517.417980]: Requesting topics…
[ERROR] [1683900517.514630]: Tried to publish before configured, topic id 131
[INFO] [1683900517.522785]: Requesting topics…
[ERROR] [1683900517.620395]: Tried to publish before configured, topic id 131
[INFO] [1683900517.628755]: Requesting topics…
[ERROR] [1683900517.726996]: Tried to publish before configured, topic id 131
[INFO] [1683900517.736757]: Requesting topics…
[ERROR] [1683900517.832256]: Tried to publish before configured, topic id 131
[INFO] [1683900517.841942]: Requesting topics…
[ERROR] [1683900517.938394]: Tried to publish before configured, topic id 131
[INFO] [1683900517.946741]: Requesting topics…
[ERROR] [1683900518.044103]: Tried to publish before configured, topic id 131
[INFO] [1683900518.052497]: Requesting topics…
[ERROR] [1683900518.150921]: Tried to publish before configured, topic id 131
[INFO] [1683900518.159199]: Requesting topics…
[ERROR] [1683900518.256355]: Tried to publish before configured, topic id 131
[INFO] [1683900518.268796]: Requesting topics…
[ERROR] [1683900518.363236]: Tried to publish before configured, topic id 131
[INFO] [1683900518.372053]: Requesting topics…
[ERROR] [1683900518.468915]: Tried to publish before configured, topic id 131
[INFO] [1683900518.477276]: Requesting topics…
[ERROR] [1683900518.575635]: Tried to publish before configured, topic id 131
[INFO] [1683900518.583779]: Requesting topics…
[ERROR] [1683900518.681004]: Tried to publish before configured, topic id 131
[INFO] [1683900518.688285]: Requesting topics…
[ERROR] [1683900518.788034]: Tried to publish before configured, topic id 131
[INFO] [1683900518.796459]: Requesting topics…
[ERROR] [1683900518.892877]: Tried to publish before configured, topic id 131
[INFO] [1683900518.901203]: Requesting topics…
[ERROR] [1683900518.999357]: Tried to publish before configured, topic id 131
[INFO] [1683900519.007996]: Requesting topics…
[ERROR] [1683900519.105942]: Tried to publish before configured, topic id 131
[INFO] [1683900519.114193]: Requesting topics…
[ERROR] [1683900519.210918]: Tried to publish before configured, topic id 131
[INFO] [1683900519.219976]: Requesting topics…
[ERROR] [1683900519.317809]: Tried to publish before configured, topic id 131
[INFO] [1683900519.325730]: Requesting topics…
[ERROR] [1683900519.423393]: Tried to publish before configured, topic id 131
[INFO] [1683900519.431180]: Requesting topics…
[ERROR] [1683900519.528815]: Tried to publish before configured, topic id 131
[INFO] [1683900519.537341]: Requesting topics…
[ERROR] [1683900519.635484]: Tried to publish before configured, topic id 131
[INFO] [1683900519.643493]: Requesting topics…
[ERROR] [1683900519.741331]: Tried to publish before configured, topic id 131
[INFO] [1683900519.750513]: Requesting topics…
[ERROR] [1683900519.847476]: Tried to publish before configured, topic id 131
[INFO] [1683900519.856041]: Requesting topics…
[ERROR] [1683900519.953346]: Tried to publish before configured, topic id 131
[INFO] [1683900519.961526]: Requesting topics…
[ERROR] [1683900520.059836]: Tried to publish before configured, topic id 131
[INFO] [1683900520.068238]: Requesting topics…
[ERROR] [1683900520.166660]: Tried to publish before configured, topic id 131
[INFO] [1683900520.175626]: Requesting topics…
[ERROR] [1683900520.271887]: Tried to publish before configured, topic id 131
[INFO] [1683900520.280701]: Requesting topics…
[ERROR] [1683900520.378589]: Tried to publish before configured, topic id 131
[INFO] [1683900520.387222]: Requesting topics…
[ERROR] [1683900520.484359]: Tried to publish before configured, topic id 131
[INFO] [1683900520.493086]: Requesting topics…
[ERROR] [1683900520.590338]: Tried to publish before configured, topic id 131
[INFO] [1683900520.601810]: Requesting topics…
[ERROR] [1683900520.696205]: Tried to publish before configured, topic id 131
[INFO] [1683900520.707582]: Requesting topics…
[ERROR] [1683900520.803065]: Tried to publish before configured, topic id 131
[INFO] [1683900520.811908]: Requesting topics…
[ERROR] [1683900520.908197]: Tried to publish before configured, topic id 131
[INFO] [1683900520.916443]: Requesting topics…
[ERROR] [1683900521.014306]: Tried to publish before configured, topic id 131
[INFO] [1683900521.022191]: Requesting topics…
[ERROR] [1683900521.121219]: Tried to publish before configured, topic id 131
[INFO] [1683900521.129365]: Requesting topics…
[ERROR] [1683900521.227399]: Tried to publish before configured, topic id 131
[INFO] [1683900521.235855]: Requesting topics…
[ERROR] [1683900521.333848]: Tried to publish before configured, topic id 131
[INFO] [1683900521.341993]: Requesting topics…
[ERROR] [1683900521.439842]: Tried to publish before configured, topic id 131
[INFO] [1683900521.448417]: Requesting topics…
[ERROR] [1683900521.546689]: Tried to publish before configured, topic id 131
[INFO] [1683900521.556238]: Requesting topics…
[ERROR] [1683900521.651885]: Tried to publish before configured, topic id 131
[INFO] [1683900521.660089]: Requesting topics…
[ERROR] [1683900521.758190]: Tried to publish before configured, topic id 131
[INFO] [1683900521.766633]: Requesting topics…
[ERROR] [1683900521.863825]: Tried to publish before configured, topic id 131
[INFO] [1683900521.872302]: Requesting topics…
[ERROR] [1683900521.970611]: Tried to publish before configured, topic id 131
[INFO] [1683900521.979039]: Requesting topics…
[ERROR] [1683900522.075222]: Tried to publish before configured, topic id 131
[INFO] [1683900522.085348]: Requesting topics…
[ERROR] [1683900522.182034]: Tried to publish before configured, topic id 131
[INFO] [1683900522.191419]: Requesting topics…
[ERROR] [1683900522.287741]: Tried to publish before configured, topic id 131
[INFO] [1683900522.296138]: Requesting topics…
^C[turtlebot3_diagnostics-3] killing on exit
[turtlebot3_lds-2] killing on exit
[turtlebot3_core-1] killing on exit
[INFO] [1683900522.375562]: Sending tx stop request
[INFO] [1683900522.383736]: shutdown hook activated
^C[turtlebot3_lds-2] escalating to SIGTERM
shutting down processing monitor…
… shutting down processing monitor complete
done

Thank you
Shivam

According to this issue on the official TB3 GitHub it might be an issue with mismatched TB3 firmware and the version of ROS you are using?

I would recommend opening an issue on that repository as well, so that the official TB3 maintainers can provide you some assistance.

I see,

Thank you for the response. I will go through the issue you have posted and also create a new issue on that repository.

Hello, Jonathon

I apologize for the frequent questions. However, I am now facing an issue that pertains to the bringup of the tb3. Currently, when I attempt to bringup the tb3 from my PC. The terminal gets stuck on “Setup publisher for illumination [std_msgs/float32]”.

So, I was wondering if you have any insight as to how I could go about resolving this problem. I feel like we are getting very close to obtaining a functioning light sensor on the tb3. Any advice or inputs that you have are greatly appreciated. Once again, I will post more details below

Thanks,
Shivam

[INFO] [1684173995.072374]: Requesting topics…
[INFO] [1684173995.219677]: Note: publish buffer size is 1024 bytes
[INFO] [1684173995.228194]: Setup publisher on illumination [std_msgs/Float32]

Also, I have combined the light sensor code with the illumination example which is provided with the ROS Turtlebot3_core from the github you have sent me previously. I will post this down below

#include <ros.h>
#include <std_msgs/Float32.h>

ros::NodeHandle nh;
std_msgs::Float32 illumination_msg;
ros::Publisher pub_illumination(“illumination”, &illumination_msg);

void setup()
{
nh.initNode();
nh.advertise(pub_illumination);

Serial.begin(9600);
pinMode(BDPIN_LED_USER_1, OUTPUT);
pinMode(BDPIN_LED_USER_2, OUTPUT);
pinMode(BDPIN_LED_USER_3, OUTPUT);
}

void loop()
{
int reading;
static unsigned long pre_time = 0;

if(analogRead(0)<200)
{
digitalWrite(BDPIN_LED_USER_1, LOW);
digitalWrite(BDPIN_LED_USER_2, LOW);
digitalWrite(BDPIN_LED_USER_3, LOW);
}
else if(analogRead(0)>200 && analogRead(0)<300)
{
digitalWrite(BDPIN_LED_USER_1, HIGH);
digitalWrite(BDPIN_LED_USER_2, LOW);
digitalWrite(BDPIN_LED_USER_3, LOW);
}
else if(analogRead(0)>300 && analogRead(0)<400)
{
digitalWrite(BDPIN_LED_USER_1, HIGH);
digitalWrite(BDPIN_LED_USER_2, HIGH);
digitalWrite(BDPIN_LED_USER_3, LOW);
}
else if(analogRead(0)>400 && analogRead(0)<500)
{
digitalWrite(BDPIN_LED_USER_1, HIGH);
digitalWrite(BDPIN_LED_USER_2, HIGH);
digitalWrite(BDPIN_LED_USER_3, HIGH);
}
Serial.println(analogRead(0), DEC);
delay(100);

illumination_msg.data = reading;
pub_illumination.publish(&illumination_msg);
pre_time = millis();
Serial.println(illumination_msg.data);

nh.spinOnce();
}