BotArmControlServer.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <stdlib.h>
00039 #include <time.h>
00040 #include <iostream>
00041 #include <unistd.h>
00042 #include <fcntl.h>
00043 #include <sys/types.h>
00044 #include <sys/stat.h>
00045 #include <signal.h>
00046 #include "Util/Assert.H"
00047 #include "Util/Timer.H"
00048 #include "Util/Types.H"
00049 #include "Component/ModelManager.H"
00050 #include "Corba/Objects/BotArmControlSK.hh"
00051 #include "Corba/Objects/BotArmControlServer.H"
00052 #include "Corba/CorbaUtil.H"
00053
00054 CORBA::ORB_var orb;
00055 CosNaming::Name objectName;
00056
00057 bool Debug = false;
00058
00059
00060 void terminate(int s)
00061 {
00062 LERROR("*** INTERRUPT ***");
00063 unbindObject(orb, "saliency", "BotControllers", objectName);
00064 orb->shutdown(0);
00065 }
00066
00067 void BotArmControlServer::shutdown() {
00068
00069 unbindObject(orb, "saliency", "BotControllers", objectName);
00070 orb->shutdown(0);
00071 }
00072
00073
00074 BotArmControlServer::BotArmControlServer(OptionManager &mgr, bool debug) :
00075 Scorbot(mgr)
00076 {
00077 }
00078
00079
00080 BotArmControlServer::~BotArmControlServer()
00081 {
00082
00083 }
00084
00085
00086 short BotArmControlServer::getEncoder(const short motor) {
00087
00088 return motor+1;
00089 }
00090
00091 void BotArmControlServer::setMotor(const short i, const float val) {
00092 LINFO("i: %i, val: %f",i,val);
00093 }
00094
00095
00096
00097 int main(int argc, char **argv){
00098
00099 MYLOGVERB = LOG_INFO;
00100
00101
00102 ModelManager manager("BotArmControlServer Corba Object");
00103
00104 nub::ref<BotArmControlServer> botArmControlServer(new BotArmControlServer(manager, false));
00105 manager.addSubComponent(botArmControlServer);
00106
00107 if (manager.parseCommandLine((const int)argc, (const char**)argv, "", 0, 0) == false)
00108 return(1);
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 signal(SIGHUP, terminate); signal(SIGINT, terminate);
00138 signal(SIGQUIT, terminate); signal(SIGTERM, terminate);
00139 signal(SIGALRM, terminate);
00140
00141
00142
00143 orb = CORBA::ORB_init(argc, argv);
00144
00145 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
00146 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
00147
00148 BotArmControlServer* myobj = botArmControlServer.get();
00149
00150
00151 PortableServer::ObjectId_var objID = poa->activate_object(myobj);
00152
00153
00154
00155
00156
00157
00158 if( !bindObjectToName(orb, obj, "saliency", "BotControllers", "BotArmControlServer", objectName) )
00159 return 1;
00160 myobj->_remove_ref();
00161
00162 PortableServer::POAManager_var pman = poa->the_POAManager();
00163 pman->activate();
00164
00165
00166 try {
00167 manager.start();
00168
00169 orb->run();
00170 } catch (...) {
00171 LINFO("Error starting server");
00172 }
00173
00174
00175 LINFO("Shutting down");
00176 unbindObject(orb, "saliency", "BotControllers", objectName);
00177
00178 manager.stop();
00179
00180 return 0;
00181 }