Somehow you've landed here 🤔
I am probably building something or learning some stuff. Feel free to look around, check my contributions below, website and LinkedIn profile.
An Arduino library to read Maxbotix ultrasonic sensors.
License: MIT License
Somehow you've landed here 🤔
I am probably building something or learning some stuff. Feel free to look around, check my contributions below, website and LinkedIn profile.
Hi,
I have a problem when use this library, i use two maxbotix in arduino nano, and when i read from Serial, using Rx SoftwareSerial.h, i don't receive anything from Monitor Serie.
But if i use one maxbotix with serial, and another with Digital, the program work without any problem.
This is my code:
#include "Maxbotix.h"
#include <ros.h>
#include <ros/time.h>
#include <sensor_msgs/Range.h>
//Sonar A (EZ4)
//#ifdef MAXBOTIX_WITH_SOFTWARE_SERIAL
Maxbotix rangeSensorTXA(6, Maxbotix::TX, Maxbotix::LV);
//#endif
//Set up the ros node and publisher
sensor_msgs::Range sonar_TXA_msg;
ros::Publisher pub_sonar_TXA("sonarTXA", &sonar_TXA_msg);
//sonar B (EZ0)
//#ifdef MAXBOTIX_WITH_SOFTWARE_SERIAL
Maxbotix rangeSensorTXB(8, Maxbotix::TX, Maxbotix::LV);
//#endif
//Set up the ros node and publisher
sensor_msgs::Range sonar_TXB_msg;
ros::Publisher pub_sonar_TXB("sonarTXB", &sonar_TXB_msg);
ros::NodeHandle nh;
void setup()
{
Serial.begin(9600);
//seleccionamos los pin de control
//Sonar A
pinMode(5, OUTPUT);
//Sonar B
pinMode(4, OUTPUT);
nh.initNode();
//mensaje SERIAL A
nh.advertise(pub_sonar_TXA);
sonar_TXA_msg.radiation_type = sensor_msgs::Range::ULTRASOUND;
sonar_TXA_msg.header.frame_id = "/sonar_range";
sonar_TXA_msg.field_of_view = 0.4;
sonar_TXA_msg.min_range = 0.15;
sonar_TXA_msg.max_range = 6.45;
//mensaje SERIAL B
nh.advertise(pub_sonar_TXB);
sonar_TXB_msg.radiation_type = sensor_msgs::Range::ULTRASOUND;
sonar_TXB_msg.header.frame_id = "/sonar_range";
sonar_TXB_msg.field_of_view = 0.7;
sonar_TXB_msg.min_range = 0.15;
sonar_TXB_msg.max_range = 6.45;
}
long range_timer;
void loop()
{
if ((millis() - range_timer) > 1000)
{
//SERIAL A
digitalWrite(5, HIGH);
delayMicroseconds(50);
digitalWrite(5, LOW);
sonar_TXA_msg.range = rangeSensorTXA.getRange();
sonar_TXA_msg.header.stamp = nh.now();
Serial.print("TXA = ");
Serial.println(sonar_TXA_msg.range);
pub_sonar_TXA.publish(&sonar_TXA_msg);
//SERIAL B
digitalWrite(4, HIGH);
delayMicroseconds(50);
digitalWrite(4, LOW);
sonar_TXB_msg.range = rangeSensorTXB.getRange();
sonar_TXB_msg.header.stamp = nh.now();
Serial.print("TXB = ");
Serial.println(sonar_TXB_msg.range);
pub_sonar_TXB.publish(&sonar_TXB_msg);
Serial.println(" ");
range_timer = millis();
}
nh.spinOnce();
}
Thanks so much and sorry for my english.
Skained
I am working to use the library to calculate the MB1010 LV-MaxSonar®-EZ1™ range. However, looking through your code, the calculation you make is:
result = toCentimeters(analogRead(pin) / 2.0);
How does the Analog Value In/2 = the value converted to inches? Or is this just a random number that got it close to the actual value but not really?
rangeSensorTx features in both Simple and Advanced examples, but has been disabled in the library files.
You can either remove rangeSensorTX from the examples, or restore RxSoftwareSerial as it has been disabled for a reason not known to me.
Not sure whats going on here, but this is the error that I get when trying to verify the Simple code:
MaxbotixSonar/Maxbotix.cpp.o: In function Maxbotix::getRange()': /usr/share/arduino/libraries/MaxbotixSonar/Maxbotix.cpp:77: undefined reference to
operator new[](unsigned int)'
/usr/share/arduino/libraries/MaxbotixSonar/Maxbotix.cpp:67: undefined reference to `operator delete'
collect2: ld returned 1 exit status
Any help would be greatly appreciated!
I am getting about 7 errors which prevent me from compiling
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.