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 
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
input
input
dynamicgraph
dynamicgraph::sot::Segment::outputSOUT_
SignalTimeDependent< Vector, sigtime_t > outputSOUT_
Definition: segment.hh:55
dynamicgraph::Entity
dynamicgraph::sot::Segment::setRange
void setRange(const size_type &i0, const size_type &length)
Definition: segment.hh:46
boost
dynamicgraph::sot::Segment::Segment
Segment(const std::string &name)
Definition: segment.cpp:41
dynamicgraph::sot::DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
dynamicgraph::sigtime_t
int64_t sigtime_t
segment.hh
dynamicgraph::sot::Segment::compute
Vector & compute(Vector &output, sigtime_t time)
Definition: segment.cpp:57
dynamicgraph::Vector
Eigen::VectorXd Vector
dynamicgraph::command::makeCommandVoid2
CommandVoid2< E, T1, T2 > * makeCommandVoid2(E &entity, boost::function< void(const T1 &, const T2 &)> function, const std::string &docString)
dynamicgraph::sot::Segment::inputSIN_
SignalPtr< Vector, sigtime_t > inputSIN_
Definition: segment.hh:54
dynamicgraph::sot::Segment
Definition: segment.hh:41
x0
x0
dynamicgraph::Entity::addCommand
void addCommand(const std::string &name, command::Command *command)
dynamicgraph::sot::Segment::range_
std::pair< size_type, size_type > range_
Definition: segment.hh:57
all-commands.h
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
compile.name
name
Definition: compile.py:23


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31