test_marker.cpp
Go to the documentation of this file.
1 // Copyright (C) 2009-2010 Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
2 // Author Martí Morta Garriga (mmorta@iri.upc.edu)
3 // All rights reserved.
4 //
5 // This file is part of IRI EPOS2 Driver
6 // IRI EPOS2 Driver is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #include <stdio.h>
20 #include <unistd.h>
21 
22 #include <iostream>
23 #include <bitset>
24 #include "Epos2.h"
25 
26 using namespace std;
27 
42 int main(void){
43 
44  CEpos2 controller;
45 
46 
47  cout << "Epos2 Position Marker:" << endl;
48 
49  try{
50 
51  controller.init();
52  controller.setVerbose(false);
53 
54  // enable motor in velocity mode
55  controller.enableController();
56 
57  char digin = 2;
58  controller.setPositionMarker(0,0,0,digin);
59 
60  cout << " DIGITAL INPUTS:\n";
61  for(int i=1;i<=10;i++)
62  cout << " DigIN " << i << ": " << controller.getDigInState(i) << endl;
63  cout
64  << "\n State: " << bitset<16>(controller.getDigInStateMask())
65  << "\n Functionalities: " << bitset<16>(controller.getDigInFuncMask())
66  << "\n Polarity: " << bitset<16>(controller.getDigInPolarity())
67  << "\n Execution: " << bitset<16>(controller.getDigInExecutionMask())
68  << "\n";
69 
70  // if(controller.getDigInState(digin) == 4 && false)
71  // {
72  // controller.enableMotor(controller.VELOCITY);
73  // controller.setTargetVelocity(300);
74  // controller.startVelocity();
75 
76  int num_positions = 1;
77 
78  while(num_positions < 11){
79  controller.waitPositionMarker();
80  cout << " > New Position: " << endl
81  << " Hist(0): " << controller.getPositionMarker() << endl
82  << " Hist(1): " << controller.getPositionMarker(1) << endl
83  << " Hist(2): " << controller.getPositionMarker(2) << endl;
84  num_positions++;
85  }
86  // controller.stopVelocity();
87  // }
88  controller.close();
89 
90  }catch(std::exception &e){
91  controller.init();
92  controller.close();
93  cout << e.what() << endl;
94  }
95 
96  return 1;
97 
98 }
99 
void waitPositionMarker()
wait for marker position reached
Definition: Epos2.cpp:1546
void setPositionMarker(char polarity=0, char edge_type=0, char mode=0, char digitalIN=2)
Sets the configuration of a marker position.
Definition: Epos2.cpp:1530
int getDigInExecutionMask()
Gives Digital Inputs Execution Mask.
Definition: Epos2.cpp:1618
int getDigInPolarity()
Gives Digital Inputs Polarity Mask.
Definition: Epos2.cpp:1613
void setVerbose(bool verbose)
Definition: Epos2.cpp:90
int getDigInStateMask()
Gives Digital Inputs State Mask.
Definition: Epos2.cpp:1603
int main(void)
Definition: test_marker.cpp:42
void enableController()
function to facititate transitions from the start of the controller to switch it on ...
Definition: Epos2.cpp:632
void close()
Disconnects hardware.
Definition: Epos2.cpp:58
Implementation of a driver for EPOS2 Motor Controller.
Definition: Epos2.h:60
void init()
Connects hardware.
Definition: Epos2.cpp:49
int getDigInFuncMask()
Gives Digital Inputs Functionalities Mask.
Definition: Epos2.cpp:1608
int getDigInState(int digitalIN=2)
Gives the state of a certain digital Input.
Definition: Epos2.cpp:1598
long getPositionMarker(int buffer=0)
gets the position marked by the sensor
Definition: Epos2.cpp:1512


epos2_motor_controller
Author(s): Martí Morta Garriga , Jochen Sprickerhof
autogenerated on Mon Jul 22 2019 03:19:01