Skip to content
Snippets Groups Projects
Commit 432fb627 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Florent Lamiraux
Browse files

Add class Client and make class ClientCpp deprecated.

parent f59813f3
No related branches found
No related tags found
No related merge requests found
Subproject commit a831f5403a93b67c6cb8675625e79dd676a565f3
Subproject commit 271ca4fb6fe78a3f8e2473e095d0f99a7f25e205
......@@ -23,6 +23,7 @@ module corbaserver {
typedef float Transform [7];
typedef float Position [3];
typedef float Color [4];
typedef unsigned long WindowID;
/// Corba exception travelling through the Corba channel
interface GraphicalInterface {
......
......@@ -11,13 +11,35 @@
#include <iostream>
#include <omniORB4/CORBA.h>
#include <gepetto/viewer/corba/deprecated.hh>
#include <gepetto/viewer/corba/se3.hh>
#include <gepetto/viewer/corba/graphical-interface.hh>
namespace graphics {
namespace corbaServer {
class Client
{
public:
typedef CORBA::ULong WindowID;
Client (int argc, char* argv[]);
~Client ();
void connect (const char* iiop = "corbaloc:rir:/NameService");
gepetto::corbaserver::GraphicalInterface_var& gui () {
return gui_;
}
private:
gepetto::corbaserver::GraphicalInterface_var gui_;
CORBA::ORB_var orb_;
};
/// \deprecated Use class Client instead.
class ClientCpp
{
private:
......@@ -89,7 +111,7 @@ public:
bool startCapture (const WindowID windowId, const char* filename, const char* extension);
bool stopCapture (const WindowID windowId);
bool writeNodeFile (const WindowID windowId, const char* filename);
}; //end of class ClientCpp
} GEPETTO_VIEWER_CORBA_DEPRECATED; //end of class ClientCpp
} //end of namespace corbaserver
} //end of namespace graphics
......
......@@ -29,16 +29,17 @@ ENDFOREACH()
ADD_LIBRARY(${LIBRARY_NAME}
SHARED
graphical-interfaceSK.cc
graphical-interface.impl.cpp
graphical-interface.impl.hh
windows-manager.cpp
server.cc
client.cc
server-private.cc
server-private.hh
client-cpp.cc
${CMAKE_CURRENT_BINARY_DIR}/gepetto/corbaserver/graphical-interface_idl.py
${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/graphical-interface.hh
${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/graphical-interfaceSK.cc
)
PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} omniORB4)
......@@ -63,23 +64,11 @@ FOREACH (IDL ${IDL_SOURCES})
MAIN_DEPENDENCY
${CMAKE_SOURCE_DIR}/idl/gepetto/viewer/${IDL}.idl
)
ADD_CUSTOM_COMMAND(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/${IDL}.hh
COMMAND ${OMNIIDL}
ARGS -bcxx -C${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba
-I${CMAKE_SOURCE_DIR}/idl
${CMAKE_SOURCE_DIR}/idl/gepetto/viewer/${IDL}.idl
MAIN_DEPENDENCY
${CMAKE_SOURCE_DIR}/idl/gepetto/viewer/${IDL}.idl
)
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_CURRENT_BINARY_DIR}/${IDL}_idl.py
${CMAKE_CURRENT_BINARY_DIR}/${IDL}.hh
${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/${IDL}.hh
GENERATED=ON
PROPERTIES GENERATED ON
)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${IDL}.hh
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/${IDL}.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gepetto/viewer/corba)
STRING(REGEX REPLACE "-" "_"
......@@ -114,7 +103,8 @@ INSTALL(
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/idl/gepetto/corbaserver
)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/graphical-interface.hh
INSTALL (FILES
${CMAKE_CURRENT_BINARY_DIR}/gepetto/viewer/corba/graphical-interface.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gepetto/viewer/corba
)
......
// Copyright (c) 2015, Joseph Mirabel
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
//
// This file is part of gepetto-viewer-corba.
// gepetto-viewer-corba is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either version
// 3 of the License, or (at your option) any later version.
//
// gepetto-viewer-corba is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// gepetto-viewer-corba. If not, see <http://www.gnu.org/licenses/>.
#include "gepetto/viewer/corba/client.hh"
#include <iostream>
namespace graphics {
namespace corbaServer {
using CORBA::Exception;
using CORBA::Object_var;
using CORBA::SystemException;
using CORBA::ORB_init;
using CORBA::PolicyList;
using omniORB::fatalException;
Client::Client(int argc, char *argv[]) :
orb_ (CORBA::ORB_init (argc, argv))
{
}
void Client::connect (const char* iiop)
{
// Get a reference to the Naming Service
CORBA::Object_var rootContextObj = orb_->string_to_object(iiop);
CosNaming::NamingContext_var nc =
CosNaming::NamingContext::_narrow(rootContextObj.in());
// Bind robotObj with name Robot to the hppContext:
CosNaming::Name name;
name.length(2);
name[0].id = (const char *) "gepetto";
name[0].kind = (const char *) "viewer";
name[1].id = (const char *) "corbaserver";
name[1].kind = (const char *) "gui";
// Invoke the root context to retrieve the object reference
CORBA::Object_var managerObj = nc->resolve(name);
// Narrow the previous object to obtain the correct type
gui_ = gepetto::corbaserver::GraphicalInterface::_narrow(managerObj.in());
}
/// \brief Shutdown CORBA server
Client::~Client()
{
if (!CORBA::is_nil(orb_)) {
try {
orb_->destroy();
std::cout << "Ending CORBA..." << std::endl;
} catch(const CORBA::Exception& e) {
std::cout << "orb->destroy failed" << std::endl;
}
}
}
} // end of namespace corbaServer.
} // end of namespace graphics.
......@@ -12,7 +12,7 @@
#include <omniORB4/CORBA.h>
#include "gepetto/viewer/corba/server.hh"
#include "graphical-interface.hh"
#include "gepetto/viewer/corba/graphical-interface.hh"
namespace graphics {
namespace corbaServer {
......
......@@ -8,24 +8,38 @@
#include <gepetto/viewer/corba/client.hh>
void se3ToCorba(CORBA::Float* corbaPosition, const se3::SE3& se3position)
{
Eigen::Quaternion<float> q(se3position.rotation());
corbaPosition[0] = se3position.translation()(0);
corbaPosition[1] = se3position.translation()(1);
corbaPosition[2] = se3position.translation()(2);
corbaPosition[3] = q.w();
corbaPosition[4] = q.x();
corbaPosition[5] = q.y();
corbaPosition[6] = q.z();
}
int main(int, const char **)
{
using namespace graphics;
using namespace corbaServer;
using namespace std;
ClientCpp client;
Client client (0, NULL);
client.connect ();
se3::SE3 position1 = se3::SE3::Random();
se3::SE3 position2 = se3::SE3::Random();
se3::SE3 position3 = se3::SE3::Random();
se3::SE3 position4 = se3::SE3::Random();
se3::SE3 position5 = se3::SE3::Random();
CORBA::Float pos[7];
ClientCpp::WindowID windowId = client.createWindow("window1");
client.createScene("scene1");
client.addSceneToWindow("scene1",windowId);
client.addURDF("scene1/hrp2", "/local/mgeisert/devel/src/hrp2/hrp2_14_description/urdf/hrp2_14_capsule.urdf", "/local/mgeisert/devel/src/hrp2/");
Client::WindowID windowId = client.gui()->createWindow("window1");
client.gui()->createScene("scene1");
client.gui()->addSceneToWindow("scene1",windowId);
client.gui()->addURDF("scene1/hrp2", "/local/mgeisert/devel/src/hrp2/hrp2_14_description/urdf/hrp2_14_capsule.urdf", "/local/mgeisert/devel/src/hrp2/");
sleep(5);
......@@ -35,18 +49,23 @@ int main(int, const char **)
float pos2[3] = {0.,1.,0.};
float pos3[3]= {0.,1.,1.};
float color[4] = {1.,1.,1.,1.};
client.addTriangleFace("scene1/triangle", pos1, pos2, pos3, color);
client.gui()->addTriangleFace("scene1/triangle", pos1, pos2, pos3, color);
sleep(15);
client.applyConfiguration("scene1/hrp2/RLEG_LINK0", position1);
client.applyConfiguration("scene1/hrp2/RLEG_LINK1", position2);
client.applyConfiguration("scene1/hrp2/LLEG_LINK1", position3);
client.applyConfiguration("scene1/hrp2/LLEG_LINK2", position4);
client.applyConfiguration("scene1/hrp2/BODY", position5);
se3ToCorba (pos, position1);
client.gui()->applyConfiguration("scene1/hrp2/RLEG_LINK0", pos);
se3ToCorba (pos, position2);
client.gui()->applyConfiguration("scene1/hrp2/RLEG_LINK1", pos);
se3ToCorba (pos, position3);
client.gui()->applyConfiguration("scene1/hrp2/LLEG_LINK1", pos);
se3ToCorba (pos, position4);
client.gui()->applyConfiguration("scene1/hrp2/LLEG_LINK2", pos);
se3ToCorba (pos, position5);
client.gui()->applyConfiguration("scene1/hrp2/BODY", pos);
client.refresh();
client.gui()->refresh();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment