2 #include <visp3/core/vpConfig.h>
3 #ifdef VISP_HAVE_MODULE_AR
4 #include <visp3/ar/vpAROgre.h>
6 #include <visp3/blob/vpDot2.h>
7 #include <visp3/gui/vpDisplayFactory.h>
8 #include <visp3/robot/vpSimulatorCamera.h>
9 #include <visp3/vision/vpPose.h>
10 #include <visp3/visual_features/vpFeatureBuilder.h>
11 #include <visp3/vs/vpServo.h>
12 #include <visp3/vs/vpServoDisplay.h>
14 #if defined(ENABLE_VISP_NAMESPACE)
18 void display_trajectory(
const vpImage<unsigned char> &I,
const std::vector<vpDot2> &dot,
unsigned int thickness);
19 #if defined(VISP_HAVE_OGRE)
24 void display_trajectory(
const vpImage<unsigned char> &I,
const std::vector<vpDot2> &dot,
unsigned int thickness)
26 static std::vector<vpImagePoint> traj[4];
27 for (
unsigned int i = 0; i < 4; i++) {
28 traj[i].push_back(dot[i].getCog());
30 for (
unsigned int i = 0; i < 4; i++) {
31 for (
unsigned int j = 1; j < traj[i].size(); j++) {
37 #if defined(VISP_HAVE_OGRE)
55 #if defined(VISP_HAVE_OGRE) && defined(VISP_HAVE_DISPLAY)
56 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
57 std::shared_ptr<vpDisplay> display;
63 unsigned int thickness = 3;
75 std::vector<vpPoint> point;
76 point.push_back(
vpPoint(-0.1, -0.1, 0));
77 point.push_back(
vpPoint(0.1, -0.1, 0));
78 point.push_back(
vpPoint(0.1, 0.1, 0));
79 point.push_back(
vpPoint(-0.1, 0.1, 0));
88 ogre.
init(background,
false,
true);
93 std::vector<std::string> name(4);
94 for (
unsigned int i = 0; i < 4; i++) {
98 ogre.
load(name[i],
"Sphere.mesh");
100 ogre.
setScale(name[i], 0.02f, 0.02f,
109 light->setDiffuseColour(1., 1., 1.);
110 light->setSpecularColour(1., 1., 1.);
111 light->setType(Ogre::Light::LT_POINT);
112 #if (VISP_HAVE_OGRE_VERSION < (1 << 16 | 10 << 8 | 0))
113 light->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3]));
115 Ogre::SceneNode *spotLightNode = ogre.
getSceneManager()->getRootSceneNode()->createChildSceneNode();
116 spotLightNode->attachObject(light);
117 spotLightNode->setPosition((Ogre::Real)cdMo[0][3], (Ogre::Real)cdMo[1][3], (Ogre::Real)(-cdMo[2][3]));
129 ogre_get_render_image(ogre, background, cdMo, I);
132 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
142 std::vector<vpDot2> dot(4);
145 for (
unsigned int i = 0; i < 4; i++) {
147 dot[i].setGraphics(
true);
148 dot[i].setGraphicsThickness(thickness);
149 dot[i].initTracking(I);
155 ogre_get_render_image(ogre, background, cMo, I);
163 for (
unsigned int i = 0; i < 4; i++) {
172 dot[i].setGraphics(
true);
173 dot[i].initTracking(I);
178 for (
unsigned int i = 0; i < 4; i++) {
181 point[i].changeFrame(cMo, cP);
189 robot.setSamplingTime(0.040);
190 robot.getPosition(wMc);
196 robot.getPosition(wMc);
200 ogre_get_render_image(ogre, background, cMo, I);
204 for (
unsigned int i = 0; i < 4; i++) {
209 for (
unsigned int i = 0; i < 4; i++) {
212 point[i].changeFrame(cMo, cP);
218 display_trajectory(I, dot, thickness);
230 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
231 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
232 if (display !=
nullptr) {
239 std::cout <<
"Catch an exception " << std::endl;
240 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
241 if (display !=
nullptr) {
247 #if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_11)
248 if (display !=
nullptr) {
Implementation of an augmented reality viewer using Ogre3D 3rd party.
void setCameraParameters(const vpCameraParameters &cameraP)
void setShowConfigDialog(bool showConfigDialog)
void getRenderingOutput(vpImage< vpRGBa > &I, const vpHomogeneousMatrix &cMo)
void setMaterial(const std::string &entityName, const std::string &materialName)
void setRotation(const std::string &sceneName, const vpRotationMatrix &wRo)
void addResource(const std::string &resourceLocation)
Ogre::SceneManager * getSceneManager()
virtual void init(vpImage< unsigned char > &I, bool bufferedKeys=false, bool hidden=false)
virtual void display(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMw)
void load(const std::string &entityName, const std::string &model)
void setPosition(const std::string &sceneName, const vpTranslationVector &wTo)
void setScale(const std::string &sceneName, float factorx, float factory, float factorz)
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
static const vpColor green
Class that defines generic functionalities for display.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void display(const vpImage< unsigned char > &I)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void flush(const vpImage< unsigned char > &I)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
error that can be emitted by ViSP classes.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpImagePoint &t)
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
static void convert(const vpImage< unsigned char > &src, vpImage< vpRGBa > &dest)
unsigned int getWidth() const
unsigned int getHeight() const
static double rad(double deg)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
Implementation of a rotation matrix and operations on such kind of matrices.
static void display(const vpServo &s, const vpCameraParameters &cam, const vpImage< unsigned char > &I, vpColor currentColor=vpColor::green, vpColor desiredColor=vpColor::red, unsigned int thickness=1)
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
void addFeature(vpBasicFeature &s_cur, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
void setServo(const vpServoType &servo_type)
vpColVector computeControlLaw()
Class that defines the simplest robot: a free flying camera.
Class that consider the case of a translation vector.
std::shared_ptr< vpDisplay > createDisplay()
Return a smart pointer vpDisplay specialization if a GUI library is available or nullptr otherwise.
vpDisplay * allocateDisplay()
Return a newly allocated vpDisplay specialization if a GUI library is available or nullptr otherwise.
VISP_EXPORT int wait(double t0, double t)