-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpy_actusensor_wrapper_epuck.cpp
122 lines (105 loc) · 3.86 KB
/
py_actusensor_wrapper_epuck.cpp
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
115
116
117
118
119
120
121
122
#include "py_actusensor_wrapper_epuck.h"
#include "py_wrapper.h"
using namespace argos;
/****************************************/
/****************************************/
CEPuckWheelsWrapper::CEPuckWheelsWrapper()
{
}
void CEPuckWheelsWrapper::SetSpeed(const Real f_left_wheel_speed, const Real f_right_wheel_speed)
{
if (m_bEPuckWheels)
{
m_pcEPuckWheels->SetLinearVelocity(f_left_wheel_speed, f_right_wheel_speed);
}
else
{
ActusensorsWrapper::Logprint("Differential Steering Actuator not implemented or not stated in XML config.");
}
}
/****************************************/
/****************************************/
CEPuckProximitySensorWrapper::CEPuckProximitySensorWrapper()
{
}
boost::python::list CEPuckProximitySensorWrapper::GetReadings() const
{
if (m_bEPuckProximity)
{
return ActusensorsWrapper::ToPythonList(m_pcEPuckProximity->GetReadings());
}
else
{
ActusensorsWrapper::Logprint("Proximity sensor not implemented or not stated in XML config.");
// TODO: add exception?
}
}
/****************************************/
/****************************************/
CEPuckGroundSensorWrapper::CEPuckGroundSensorWrapper()
{
}
argos::CCI_EPuckGroundSensor::SReadings CEPuckGroundSensorWrapper::GetReadings() const
{
if (m_bEPuckGround)
{
return m_pcEPuckGround->GetReadings();
}
else
{
ActusensorsWrapper::Logprint("Motor Ground Sensor not implemented or not stated in XML config.");
// TODO: add exception?
}
}
/****************************************/
/****************************************/
CEPuckRangeAndBearingWrapper::CEPuckRangeAndBearingWrapper()
{
}
void CEPuckRangeAndBearingWrapper::ClearPackets()
{
m_pcEPuckRABS->ClearPackets();
}
// Send a buffer to all the emitters.
void CEPuckRangeAndBearingWrapper::SetData(const boost::python::list un_data)
{
const UInt8 unData[argos::CCI_EPuckRangeAndBearingActuator::MAX_BYTES_SENT] =
{boost::python::extract<UInt8>(boost::python::object(un_data[0])),
boost::python::extract<UInt8>(boost::python::object(un_data[1])),
boost::python::extract<UInt8>(boost::python::object(un_data[2])),
boost::python::extract<UInt8>(boost::python::object(un_data[3]))};
m_pcEPuckRABA->SetData(unData);
}
// TODO: Set all bits at once
// Return the readings obtained at this control step.
// Each reading contains the range, the horizontal bearing, the vertical bearing and the data table.
// The data table is exposed as a c_byte_array.
boost::python::list CEPuckRangeAndBearingWrapper::GetPackets() const
{
return ActusensorsWrapper::ToPythonList(m_pcEPuckRABS->GetPackets());
}
/****************************************/
/****************************************/
CEPuckLedsActuatorWrapper::CEPuckLedsActuatorWrapper()
{
}
// Set the color of a given led, given its name.
void CEPuckLedsActuatorWrapper::SetSingleColorString(const UInt8 un_led_id, const std::string str_color_name)
{
m_pcEPuckLeds->SetColor(un_led_id, ActusensorsWrapper::CColorWrapper(str_color_name).m_cColor);
}
// Set the color of a given led, given its RGB values.
void CEPuckLedsActuatorWrapper::SetSingleColorRGB(const UInt8 un_led_id, const UInt8 un_red, const UInt8 un_green, const UInt8 un_blue)
{
m_pcEPuckLeds->SetColor(un_led_id, ActusensorsWrapper::CColorWrapper(un_red, un_green, un_blue).m_cColor);
}
// Set the color of every led, given its name.
void CEPuckLedsActuatorWrapper::SetAllColorsString(const std::string str_color_name)
{
m_pcEPuckLeds->SetColors(ActusensorsWrapper::CColorWrapper(str_color_name).m_cColor);
}
// Set the color of every led, given its RGB values.
void CEPuckLedsActuatorWrapper::SetAllColorsRGB(const UInt8 un_red, const UInt8 un_green, const UInt8 un_blue)
{
m_pcEPuckLeds->SetColors(ActusensorsWrapper::CColorWrapper(un_red, un_green, un_blue).m_cColor);
}