test_homing.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 
40 int main(void){
41 
42  CEpos2 controller;
43 
44 
45  cout << "Epos2 Homing:" << endl;
46 
47  try{
48 
49  controller.init();
50  controller.setVerbose(false);
51 
52  // enable motor in velocity mode
53  controller.enableController();
54  // Using sensor:
55  // 11 Home Switch Negative Speed & Index
56  // 7 Home Switch Positive Speed & Index
57  // 27 Home Switch Negative Speed
58  // 23 Home Switch Positive Speed
59  controller.setHoming(11,600,50,1000,4);
60 
61  cout << " DIGITAL INPUTS:\n";
62  for(int i=1;i<=10;i++)
63  cout << " DigIN " << i << ": " << controller.getDigInState(i) << endl;
64  cout
65  << "\n State: " << bitset<16>(controller.getDigInStateMask())
66  << "\n Functionalities: " << bitset<16>(controller.getDigInFuncMask())
67  << "\n Polarity: " << bitset<16>(controller.getDigInPolarity())
68  << "\n Execution: " << bitset<16>(controller.getDigInExecutionMask())
69  << "\n";
70 
71  controller.enableMotor(controller.HOMING);
72  controller.doHoming(true);
73  cout << " Home is done!\n\n";
74 
75  controller.close();
76 
77  }catch(std::exception &e){
78  controller.init();
79  controller.close();
80  cout << e.what() << endl;
81  }
82 
83  return 1;
84 
85 }
86 
void enableMotor(long opmode)
function to facititate transitions from switched on to operation enabled
Definition: Epos2.cpp:696
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
void enableController()
function to facititate transitions from the start of the controller to switch it on ...
Definition: Epos2.cpp:632
int main(void)
Definition: test_homing.cpp:40
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
void setHoming(int home_method=11, int speed_pos=100, int speed_zero=100, int acc=1000, int digitalIN=2)
Sets the configuration of a homing operation.
Definition: Epos2.cpp:1562
void doHoming(bool blocking=false)
starts a homing operation
Definition: Epos2.cpp:1577
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


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