-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpy_wrapper.h
114 lines (89 loc) · 3.56 KB
/
py_wrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* AUTHOR: Ken Hasselmann <arg AT kenh DOT fr>
*
* Connects ARGoS to python
*
*/
#ifndef PY_WRAPPER_H
#define PY_WRAPPER_H
#include <boost/python.hpp>
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
#include <argos3/core/control_interface/ci_controller.h>
#include "py_actusensor_wrapper_generic.h"
#include "py_actusensor_wrapper_footbot.h"
#include "py_actusensor_wrapper_epuck.h"
#include <argos3/core/utility/logging/argos_log.h>
#include <argos3/core/utility/math/general.h>
#include <string>
#include <iostream>
namespace argos
{
class ActusensorsWrapper
{
public:
ActusensorsWrapper();
~ActusensorsWrapper(){};
static void Logprint(const std::string str_message);
//Sensors
void CreateSensor(const std::string str_name, CCI_Sensor *pc_sensor, TConfigurationNode &t_node);
//Actuators
void CreateActu(const std::string str_name, CCI_Actuator *pc_actu, TConfigurationNode &t_node);
// Wrapper for the CColor class.
class CColorWrapper
{
public:
argos::CColor m_cColor;
// Create a color by providing its name.
CColorWrapper(const std::string str_color_name);
// Create a color by providing its RGB values.
CColorWrapper(const UInt8 un_red, const UInt8 un_green, const UInt8 un_blue);
~CColorWrapper(){};
};
/****************************************/
/****************************************/
// Define a wrapper for each actuator and sensor
// Generic actusensors
CWheelsWrapper m_cWheelsWrapper;
COmnidirectionalCameraWrapper m_cOmnidirectionalCameraWrapper;
CLedsActuatorWrapper m_cLedsWrapper;
CRangeAndBearingWrapper m_cRangeAndBearingWrapper;
// Footbot Actusensors
CGripperWrapper m_cGripperWrapper;
CFootBotProximitySensorWrapper m_cProximitySensorWrapper;
CTurretWrapper m_cTurretWrapper;
CDistanceScannerWrapper m_cDistanceScannerWrapper;
CLightSensorWrapper m_cLightSensorWrapper;
CGroundSensorWrapper m_cGroundSensorWrapper;
CBaseGroundSensorWrapper m_cBaseGroundSensorWrapper;
// E-Puck actusensors
CEPuckWheelsWrapper m_cEPuckWheelsWrapper;
CEPuckProximitySensorWrapper m_cEPuckProximitySensorWrapper;
CEPuckGroundSensorWrapper m_cEPuckGroundSensorWrapper;
CEPuckRangeAndBearingWrapper m_cEPuckRangeAndBearingWrapper;
CEPuckLedsActuatorWrapper m_cEPuckLedsWrapper;
/****************************************/
/****************************************/
// Define functions to access the elements the argos::CByteArray class.
// Original source: https://mail.python.org/pipermail/cplusplus-sig/2003-June/004024.html
static void CByteArraySetItem(argos::CByteArray &c_vec, const UInt32 un_index, const UInt8 un_value);
static UInt8 CByteArrayGetItem(const argos::CByteArray &c_vec, const UInt32 un_index);
// Define getter for the EPuck ground sensor readings.
static Real EPuckGroundReadingsGetItem(const argos::CCI_EPuckGroundSensor::SReadings &c_readings, const UInt32 un_index);
/****************************************/
/****************************************/
// Used to convert vectors to python lists.
// Original source: http://www.boost.org/doc/libs/1_62_0/libs/python/pyste/doc/wrappers.html
template <class T>
static boost::python::list ToPythonList(std::vector<T> c_vec)
{
typename std::vector<T>::iterator iter;
boost::python::list list;
for (iter = c_vec.begin(); iter != c_vec.end(); ++iter)
{
list.append(*iter);
}
return list;
}
};
}
#endif