~robot3d-team/robot3d/trunk

« back to all changes in this revision

Viewing changes to inc/srInterface/YarpedSim.h

  • Committer: Anne van Rossum
  • Date: 2010-08-10 15:58:55 UTC
  • Revision ID: anne@gamix-20100810155855-kve7x2vwouagdij9
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * File: YarpedSim.h
 
3
 */
 
4
 
 
5
/* 
 
6
 * This file YarpedSim.h is created at Almende B.V. It is open-source software and part
 
7
 * of the Common Hybrid Agent Platform (CHAP). A toolbox with a lot of open-source tools.
 
8
 * Ranging from thread pools, and TCP/IP components to control architectures and learning
 
9
 * algorithms. This software is published under the GNU Lesser General Public license,
 
10
 *
 
11
 * It is not possible to add usage restrictions to an open-source license. Nevertheless,
 
12
 * we personally strongly object against this software used by the military, in the
 
13
 * bio-industry, for animal experimentation, or anything that violates the Universal
 
14
 * Declaration of Human Rights.
 
15
 *
 
16
 * Author:      Anne C. van Rossum
 
17
 * Date:        Aug 2, 2010
 
18
 * Project:     Replicator FP7
 
19
 * Company:     Almende B.V.
 
20
 * Case:        
 
21
 */
 
22
 
 
23
 
 
24
#ifndef YARPEDSIM_H_
 
25
#define YARPEDSIM_H_
 
26
 
 
27
// General files
 
28
#include <string>
 
29
 
 
30
// Delta3D files
 
31
#include <dtGame/gmcomponent.h>
 
32
 
 
33
// YARP files
 
34
#include <yarp/os/BufferedPort.h>
 
35
#include <yarp/os/Bottle.h>
 
36
#include <yarp/os/Vocab.h>
 
37
#include <yarp/os/Network.h>
 
38
 
 
39
// Robot3D files
 
40
#include <srInterface/YarpUtil.h>
 
41
 
 
42
using namespace yarp::os;
 
43
 
 
44
namespace srInterface {
 
45
 
 
46
typedef struct Vec3 {
 
47
    float x;
 
48
    float y;
 
49
    float z;
 
50
} Vec3f;
 
51
 
 
52
/* **************************************************************************************
 
53
 * Interface of YarpedSim
 
54
 * **************************************************************************************/
 
55
 
 
56
/*
 
57
 * The simulator can be interfaced over YARP via this class. It makes it possible to add
 
58
 * and remove robots. It is a Delta3D component and a YARP module at once. The first parent
 
59
 * class describes a ProcessMessage routine that needs to be implemented to receive game
 
60
 * messages. The latter defines runModule, updateModule, etc. This leads to conflicts: which
 
61
 * entity should be able to tick YarpedSim? We choose to call updateModule from the
 
62
 * ProcessMessage routine ourselves. So, runModule will not be called at all.
 
63
 */
 
64
class YarpedSim: public dtGame::GMComponent {
 
65
public:
 
66
        /*
 
67
         * Function: YarpedSim
 
68
         */
 
69
        YarpedSim();
 
70
 
 
71
        /*
 
72
         * Function: ~YarpedSim
 
73
         */
 
74
        virtual ~YarpedSim();
 
75
 
 
76
        /*
 
77
         * Function: ProcessMessage ticks
 
78
         */
 
79
        void ProcessMessage(const dtGame::Message &message);
 
80
 
 
81
        /**
 
82
         * Get AddRobot information from bottle
 
83
         */
 
84
        bool ReadBottleAddRobot(Bottle &bottle, std::string &name, std::string &type,
 
85
                        int &id, osg::Vec3f &position);
 
86
protected:
 
87
 
 
88
        // Add robot
 
89
        void AddRobot(const std::string &name, const std::string &type, const int &id, const osg::Vec3f &position);
 
90
 
 
91
private:
 
92
        // Global port for YARP commands to Robot3D
 
93
        BufferedPort<Bottle> globalYarpPort;
 
94
 
 
95
        //Reference to YARP will be created when this object is created
 
96
        Network network;
 
97
};
 
98
 
 
99
}
 
100
 
 
101
#endif /* YARPEDSIM_H_ */