44 _forwardSafetyDist(0.),
52 double angle, fov, res, maxrange, acc;
54 is >> type >> angle >> fov >> res >> maxrange >> acc >> remission_mode;
59 LaserParameters(type, beams, angle, res, maxrange, acc, remission_mode);
61 for (
int i = 0; i < beams; i++) is >>
_ranges[i];
65 for (
int i = 0; i < beams; i++) is >>
_remissions[i];
69 is >> x >> y >> theta;
71 is >> x >> y >> theta;
90 for (
size_t i = 0; i <
ranges().size(); ++i) os <<
" " <<
ranges()[i];
96 os <<
" " << p.x() <<
" " << p.y() <<
" " << p.z();
98 os <<
" " << p.x() <<
" " << p.y() <<
" " << p.z();
111#ifdef G2O_HAVE_OPENGL
112RobotLaserDrawAction::RobotLaserDrawAction()
114 _beamsDownsampling(nullptr),
116 _maxRange(nullptr) {}
118bool RobotLaserDrawAction::refreshPropertyPtrs(
119 HyperGraphElementAction::Parameters* params_) {
121 if (_previousParams) {
122 _beamsDownsampling = _previousParams->makeProperty<
IntProperty>(
123 _typeName +
"::BEAMS_DOWNSAMPLING", 1);
125 _typeName +
"::POINT_SIZE", 1.0f);
127 _typeName +
"::MAX_RANGE", -1.);
129 _beamsDownsampling = 0;
136HyperGraphElementAction* RobotLaserDrawAction::operator()(
137 HyperGraph::HyperGraphElement* element,
138 HyperGraphElementAction::Parameters* params_) {
139 if (
typeid(*element).name() != _typeName)
return nullptr;
141 refreshPropertyPtrs(params_);
142 if (!_previousParams) {
145 if (_show && !_show->value())
return this;
146 RobotLaser* that =
static_cast<RobotLaser*
>(element);
149 if (_maxRange && _maxRange->value() >= 0) {
153 auto r2 = std::pow(_maxRange->value(), 2);
154 for (
size_t i = 0; i < points.size(); i++) {
155 if (points[i].squaredNorm() < r2) npoints[k++] = points[i];
162 const SE2& laserPose = that->laserParams().laserPose;
163 glTranslatef((
float)laserPose.translation().x(),
164 (
float)laserPose.translation().y(), 0.f);
165 glRotatef((
float)
RAD2DEG(laserPose.rotation().angle()), 0.f, 0.f, 1.f);
166 glColor4f(1.f, 0.f, 0.f, 0.5f);
168 if (_beamsDownsampling)
step = _beamsDownsampling->value();
170 glPointSize(_pointSize->value());
174 for (
size_t i = 0; i < points.size(); i +=
step) {
175 glVertex3f((
float)points[i].x(), (
float)points[i].y(), 0.f);
virtual bool refreshPropertyPtrs(HyperGraphElementAction::Parameters *params_)
const std::vector< double > & ranges() const
the range measurements by the laser
std::vector< double > _remissions
std::vector< double > _ranges
LaserParameters _laserParams
std::vector< Vector2 > Point2DVector
double _loggerTimestamp
timestamp when the measurement was recorded
double loggerTimestamp() const
const std::string & hostname() const
std::string _hostname
name of the computer/robot generating the data
double _timestamp
timestamp when the measurement was generated
laser measurement obtained by a robot
virtual bool read(std::istream &is)
read the data from a stream
double _forwardSafetyDist
virtual bool write(std::ostream &os) const
write the data to a stream
double _laserTv
velocities and safety distances of the robot.
const SE2 & odomPose() const
void setOdomPose(const SE2 &odomPose)
Vector3 toVector() const
convert to a 3D vector (x, y, theta)
SE2 inverse() const
invert :-)
Property< int > IntProperty
Property< float > FloatProperty
parameters for a 2D range finder