~shadowrobot/sr-ros-interface/stable

« back to all changes in this revision

Viewing changes to sr_movements/src/partial_movement.cpp

  • Committer: Ugo Cupcic
  • Date: 2011-09-27 16:23:25 UTC
  • mto: (1.39.1 sr-ros-interface)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: ugo@shadowrobot.com-20110927162325-1864bw3axyhk93g2
sr_movements: This package reads a specified bitmap and send targets by replaying the drawn movement.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @file   partial_movement.cpp
 
3
 * @author Ugo Cupcic <ugo@shadowrobot.com>
 
4
 * @date   Tue Sep 27 10:05:01 2011
 
5
 *
 
6
*
 
7
* Copyright 2011 Shadow Robot Company Ltd.
 
8
*
 
9
* This program is free software: you can redistribute it and/or modify it
 
10
* under the terms of the GNU General Public License as published by the Free
 
11
* Software Foundation, either version 2 of the License, or (at your option)
 
12
* any later version.
 
13
*
 
14
* This program is distributed in the hope that it will be useful, but WITHOUT
 
15
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
16
* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
17
* more details.
 
18
*
 
19
* You should have received a copy of the GNU General Public License along
 
20
* with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
*
 
22
 * @brief  This is the main class from which all the different types of movement
 
23
 *         will inherit.
 
24
 *
 
25
 */
 
26
 
 
27
#include "sr_movements/partial_movement.hpp"
 
28
 
 
29
namespace shadowrobot
 
30
{
 
31
  PartialMovement::PartialMovement()
 
32
  {}
 
33
 
 
34
  PartialMovement::~PartialMovement()
 
35
  {}
 
36
 
 
37
  double PartialMovement::get_target(double percentage)
 
38
  {
 
39
    if( percentage < 0.0)
 
40
      percentage = 0.0;
 
41
    if( percentage > 1.0)
 
42
      percentage = 1.0;
 
43
 
 
44
    int index = static_cast<int>( steps.size() * static_cast<double>(percentage) );
 
45
    return steps[index];
 
46
  }
 
47
}
 
48
 
 
49
/* For the emacs weenies in the crowd.
 
50
Local Variables:
 
51
   c-basic-offset: 2
 
52
End:
 
53
*/
 
54