Go to the documentation of this file.
31 m_usbSerialNumber =
"SONAR001";
33 m_sensorLabel =
"SONAR1";
50 std::vector<double> aux;
54 iniSection,
"USB_serialNumber", m_usbSerialNumber,
true);
55 m_gain = configSource.
read_int(iniSection,
"gain", m_gain,
true);
57 configSource.
read_float(iniSection,
"maxRange", m_maxRange,
true);
58 m_minTimeBetweenPings = configSource.
read_float(
59 iniSection,
"minTimeBetweenPings", m_minTimeBetweenPings,
true);
61 ASSERT_(m_maxRange > 0 && m_maxRange <= 11);
66 iniSection,
"firingOrder", m_firingOrder, m_firingOrder,
true);
71 configSource.
read_vector(iniSection,
"sonarGains", aux, aux,
true);
75 for (itSonar = m_firingOrder.begin(), itAux = aux.begin();
76 itSonar != m_firingOrder.end(); ++itSonar, ++itAux)
77 m_sonarGains[*itSonar] = *itAux;
79 ASSERT_(aux.size() == m_firingOrder.size());
83 for (itSonar = m_firingOrder.begin(); itSonar != m_firingOrder.end();
87 iniSection,
format(
"pose%i", *itSonar), aux, aux,
90 aux[0], aux[1], aux[2],
DEG2RAD((
float)aux[3]),
94 ASSERT_(m_sonarGains.size() == m_firingOrder.size());
109 if (!checkConnectionAndConnect())
return false;
113 arch.sendMessage(msg);
115 if (arch.receiveMessage(msgRx))
137 if (!isOpen())
return false;
145 for (i = 0; i < 16; i++)
147 if (i < m_firingOrder.size())
148 msg.
content[i] = m_firingOrder[i];
153 arch.sendMessage(msg);
154 if (!arch.receiveMessage(msgRx))
return false;
168 for (i = 0; i < 16; i++)
170 if (m_sonarGains.find(i) != m_sonarGains.end())
171 msg.
content[i] = m_sonarGains[i];
175 arch.sendMessage(msg);
176 if (!arch.receiveMessage(msgRx))
return false;
182 msg.
content[0] = (int)((m_maxRange / 0.043f) - 1);
183 arch.sendMessage(msg);
184 if (!arch.receiveMessage(msgRx))
return false;
193 arch.sendMessage(msg);
194 if (!arch.receiveMessage(msgRx))
return false;
224 if (!checkConnectionAndConnect())
return false;
229 arch.sendMessage(msg);
231 if (arch.receiveMessage(msgRx))
233 if (msgRx.
content.empty())
return false;
240 for (
size_t i = 0; i <
data.size() / 2; i++)
244 if (sonar_range_cm != 0xFFFF && sonar_idx < 16)
248 m_sonarPoses[sonar_idx];
276 if (!checkConnectionAndConnect())
return false;
281 msg.
content[0] = currentAddress;
283 arch.sendMessage(msg);
285 std::this_thread::sleep_for(10ms);
287 return arch.receiveMessage(msgRx);
301 if (isOpen())
return true;
305 OpenBySerialNumber(m_usbSerialNumber);
306 std::this_thread::sleep_for(10ms);
308 std::this_thread::sleep_for(10ms);
310 SetTimeouts(300, 100);
312 return sendConfigCommands();
328 mrpt::make_aligned_shared<mrpt::obs::CObservationRange>();
std::shared_ptr< CObservationRange > Ptr
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
unsigned __int16 uint16_t
void doProcess()
This method will be invoked at a minimum rate of "process_rate" (Hz)
Contains classes for various device interfaces.
uint32_t type
An identifier of the message type (only the least-sig byte is typically sent)
#define ASSERT_(f)
Defines an assertion mechanism.
float sensedDistance
The measured range, in meters (or a value of 0 if there was no detected echo).
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &iniSection)
Loads specific configuration for the device from a given source of configuration parameters,...
TMeasurementList sensedData
All the measurements.
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object...
This "software driver" implements the communication protocol for interfacing a Ultrasonic range finde...
uint16_t sensorID
Some kind of sensor ID which identifies it on the bus (if applicable, 0 otherwise)
GLsizei GLsizei GLenum GLenum const GLvoid * data
float sensorConeApperture
Cone aperture of each ultrasonic beam, in radians.
This class allows loading and storing values and vectors of different types from a configuration text...
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
std::vector< uint8_t > content
The contents of the message (memory is automatically handled by the std::vector object)
bool queryFirmwareVersion(std::string &out_firmwareVersion)
Query the firmware version on the device (can be used to test communications).
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
bool programI2CAddress(uint8_t currentAddress, uint8_t newAddress)
Requests a command of "change address" for a given SRF10 device.
float minSensorDistance
The data members.
float read_float(const std::string §ion, const std::string &name, float defaultValue, bool failIfNotFound=false) const
math::TPose3D sensorPose
The 6D position of the sensor on the robot.
void getContentAsString(std::string &str)
Gets the contents of the message as a string.
#define IMPLEMENTS_GENERIC_SENSOR(class_name, NameSpace)
This must be inserted in all CGenericSensor classes implementation files:
Declares a class derived from "CObservation" that encapsules a single range measurement,...
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
bool sendConfigCommands()
Sends the configuration (max range, gain,...) to the USB board.
bool getObservation(mrpt::obs::CObservationRange &obs)
Request the latest range measurements.
GLsizei const GLchar ** string
bool checkConnectionAndConnect()
Tries to connect to the USB device (if disconnected).
void read_vector(const std::string §ion, const std::string &name, const VECTOR_TYPE &defaultValue, VECTOR_TYPE &outValues, bool failIfNotFound=false) const
Reads a configuration parameter of type vector, stored in the file as a string: "[v1 v2 v3 ....
OBSERVATION_T::Ptr getObservation(mrpt::obs::CSensoryFrame::Ptr &observations, mrpt::obs::CObservation::Ptr &observation, bool priority_to_sf=true)
Given an mrpt::obs::CSensoryFrame and a mrpt::obs::CObservation pointer if a OBSERVATION_T type obser...
void memcpy(void *dest, size_t destSize, const void *src, size_t copyCount) noexcept
An OS and compiler independent version of "memcpy".
double DEG2RAD(const double x)
Degrees to radians.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at mié 12 jul 2023 10:03:34 CEST | |