root/juggler/branches/2.2/modules/gadgeteer/test/main-inputgroup.cpp

Revision 19729, 4.9 kB (checked in by patrick, 2 years ago)

Copyright update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
2  *
3  * VR Juggler is (C) Copyright 1998-2007 by Iowa State University
4  *
5  * Original Authors:
6  *   Allen Bierbaum, Christopher Just,
7  *   Patrick Hartling, Kevin Meinert,
8  *   Carolina Cruz-Neira, Albert Baker
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the
22  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23  * Boston, MA 02111-1307, USA.
24  *
25  *************** <auto-copyright.pl END do not edit this line> ***************/
26
27 #include <iostream>
28 #include <gadget/InputManager.h>
29 #include <gadget/Devices/Immersion/hci.h>
30 #include <gadget/Devices/Immersion/iboxStandalone.h>
31 #include <gadget/Devices/Ascension/Flock.h>
32 #include <gadget/Devices/Immersion/Ibox.h>
33 #include <vpr/System.h>
34
35 int main()
36 {
37    vrj::Matrix pos_data;
38    gadget::InputManager* input_manager = new gadget::InputManager ;
39
40       // --- Create Dummy -- //
41    std::cout << "\nCreating myDummy: DummyPosition w/X=5.0" << std::endl;
42    gadget::DummyPosition* myDummy = new gadget::DummyPosition;
43    myDummy->SetX(5.0);
44
45       // -- get default pos data -- //
46    std::cout << "get the position data for proxy 0:" << std::endl;
47    data = input_manager->getPosData(pos_data, 0);
48    std::cout  << "  x:" << data->x
49               << "  y:" << data->y
50               << "  z:" << data->z << std::endl;
51
52       // --- Add dummy to input group -- //
53    std::cout << "\nAdding myDummy to InputGroup" << std::endl;
54    int devNum = input_manager->fAddDevice(myDummy);
55    std::cout << "Device added as devNum: " << devNum << std::endl;
56    std::cout << "\nSet proxy 0 to devNum, subnumber 0" << std::endl;
57    input_manager->setPosProxy(0,devNum,0);
58
59       // --- Now get Dummy's data -- //
60    std::cout << "Now get the positional data from posproxy0:" << std::endl;
61    data = input_manager->getPosData(0);
62    std::cout  << "  x:" << data->x
63               << "  y:" << data->y
64               << "  z:" << data->z << std::endl;
65
66
67    std::cout << "\ngetDevice(devNum):" << (input_manager->getDevice(devNum))
68              << std::endl;
69    (input_manager->getDevice(devNum))->UpdateData();
70    std::cout << "\nget the devicename: "
71              << (input_manager->getDevice(devNum))->getDeviceName()
72              << std::endl;
73
74    std::cout << "Doing UpdateAllData:" << std::flush;
75    input_manager->updateAllData();
76    std::cout << "..Done" << std::endl;
77
78 //  std::cout << "get an invalid device: ";
79 //  std::cout << (input_manager->getDevice(3)) << std::endl;
80
81    std::cout << "\ntype something: " << std::flush;
82    std::cin.get();
83
84 #ifdef TRACKERS
85    gadget::Flock* aFlock = new gadget::Flock;
86    aFlock->startSampling();
87    devNum = input_manager->fAddDevice(aFlock);
88    input_manager->SetPosProxy(1,devNum,0);
89    input_manager->SetPosProxy(2,devNum,1);
90
91    std::cout << "Trackers set up.. " << std::endl;
92    //vjSystem::sleep(5);
93
94    POS_DATA *data1,*data2,*data0;
95
96    for (int i = 0; i < 5; i++)
97    {
98       input_manager->UpdateAllData();
99       data0 = input_manager->getPosData(0);
100       data1 = input_manager->getPosData(1);
101       data2 = input_manager->getPosData(2);
102       std::cout << std::endl;
103       std::cout << "X: " << data0->x << "  " << data1->x << "  " << data2->x
104                 << std::endl
105       << "Y: " << data0->y << "  " << data1->y << "  " << data2->y << endl
106       << "Z: " << data0->z << "  " << data1->z << "  " << data2->z << endl;
107
108       vpr::System::sleep(1);
109    }
110
111    aFlock->stopSampling();
112 #endif
113
114    gadget::IBox *myibox = new gadget::IBox;
115    myibox->startSampling();
116    std::cout << "ibox is: " << myibox->getDeviceName();
117    C2Dinput_manageritalProxy dp1(myibox,0);
118    devNum = input_manager->FAddDevice(myibox);
119    input_manager->SetDinput_managerProxy(0,devNum,0);
120    input_manager->SetDinput_managerProxy(1,devNum,1);
121    input_manager->SetDinput_managerProxy(2,devNum,2);
122
123    for (int i = 0; i < 20; i++)
124    {
125       input_manager->UpdateAllData();
126       std::cout << "dinput_managerital0: "
127                 << input_manager->getDinput_managerData(0);
128       std::cout << " dinput_managerital1: "
129                 << input_manager->getDinput_managerData(1);
130       std::cout << " dinput_managerital2: "
131                 << input_manager->getDinput_managerData(2) << std::endl;
132       vpr::System::sleep(1);
133    }
134
135
136    myibox->stopSampling();
137    delete myibox;
138    // delete aFlock;
139    delete myDummy;
140
141    delete input_manager;
142
143    return 0;
144 }
Note: See TracBrowser for help on using the browser.