Fawkes API Fawkes Development Version
reverse_angle.cpp
1
2/***************************************************************************
3 * reverse_angle.cpp - Reverse the angle in which laser data is taken
4 *
5 * Created: Wed Jan 06 17:15:38 2010
6 * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#include "reverse_angle.h"
24
25#include <core/exception.h>
26#include <utils/math/angle.h>
27#include <utils/time/time.h>
28
29#include <cstdlib>
30
31/** @class LaserReverseAngleDataFilter "reverse_angle.h"
32 * Reverse the angle of beams.
33 * This filter will reverse the direction in which the beams are stored.
34 * If the original interface stores the data in clockwise direction, the
35 * outcome will be in counter-clockwise direction and vice versa. This is
36 * required for example to convert between the (clockwise) RCSoftX angles,
37 * and the (counter-clockwise) angles in the Fawkes coordinate system.
38 * @author Tim Niemueller
39 */
40
41/** Constructor.
42 * @param filter_name name of this filter instance
43 * @param in_data_size number of entries input value arrays
44 * @param in vector of input arrays
45 */
47 unsigned int in_data_size,
48 std::vector<LaserDataFilter::Buffer *> &in)
49: LaserDataFilter(filter_name, in_data_size, in, in.size())
50{
51}
52
53void
55{
56 const unsigned int vecsize = std::min(in.size(), out.size());
57 const unsigned int arrsize = std::min(in_data_size, out_data_size);
58 for (unsigned int a = 0; a < vecsize; ++a) {
59 out[a]->frame = in[a]->frame;
60 out[a]->timestamp->set_time(in[a]->timestamp);
61 float *inbuf = in[a]->values;
62 float *outbuf = out[a]->values;
63 for (unsigned int i = 0; i < arrsize; ++i) {
64 outbuf[i] = inbuf[arrsize - i];
65 }
66 }
67}
Laser data filter.
Definition: filter.h:33
unsigned int out_data_size
Number of entries in output arrays.
Definition: filter.h:87
unsigned int in_data_size
Number of entries in input arrays.
Definition: filter.h:88
std::vector< Buffer * > out
Vector of output arrays.
Definition: filter.h:90
std::vector< Buffer * > in
Vector of input arrays.
Definition: filter.h:89
void filter()
Filter the incoming data.
LaserReverseAngleDataFilter(const std::string &filter_name, unsigned int data_size, std::vector< LaserDataFilter::Buffer * > &in)
Constructor.