segment.cpp
Go to the documentation of this file.
1 // BSD 2-Clause License
2 
3 // Copyright (c) 2023, CNRS
4 // Author: Florent Lamiraux
5 
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 
13 // * Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in
15 // the documentation and/or other materials provided with the
16 // distribution.
17 
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 // OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #include <iostream>
32 #include <sot/core/segment.hh>
33 #include <dynamic-graph/factory.h>
35 
36 namespace dynamicgraph {
37 namespace sot {
38 
39 DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Segment, "Segment");
40 
41 Segment::Segment(const std::string& name)
42  : Entity(name),
43  inputSIN_(0x0, "Segment(" + name + ")::input(vector)::in"),
44  outputSOUT_(boost::bind(&Segment::compute, this, _1, _2), inputSIN_,
45  "Segment(" + name + ")::out"),
46  range_(std::make_pair(0, 0)) {
50  std::string docstring(
51  "Set range of input vector to be provided as output\n"
52  " - input: first index, length\n");
53  addCommand("setRange",
54  makeCommandVoid2(*this, &Segment::setRange, docstring));
55 }
56 
57 Vector& Segment::compute(Vector& output, int time) {
58  const Vector& input(inputSIN_(time));
59  output = input.segment(std::get<0>(range_), std::get<1>(range_));
60  return output;
61 }
62 } // namespace sot
63 } // namespace dynamicgraph
void setRange(const int &i0, const int &length)
Definition: segment.hh:46
Eigen::VectorXd Vector
void signalRegistration(const SignalArray< int > &signals)
Segment(const std::string &name)
Definition: segment.cpp:41
SignalPtr< Vector, int > inputSIN_
Definition: segment.hh:54
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
SignalTimeDependent< Vector, int > outputSOUT_
Definition: segment.hh:55
Vector & compute(Vector &output, int time)
Definition: segment.cpp:57
std::pair< int, int > range_
Definition: segment.hh:57
void addCommand(const std::string &name, command::Command *command)
input
x0
CommandVoid2< E, T1, T2 > * makeCommandVoid2(E &entity, boost::function< void(const T1 &, const T2 &)> function, const std::string &docString)


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26