22 #include "MATorsoController.hpp" 24 #include "core/MADevice.hpp" 25 #include "types/MABodyMotion.hpp" 26 #include "types/MARobotState.hpp" 27 #include "types/MATorso.hpp" 28 #include "types/MATypeRanges.hpp" 32 #include <boost/math/constants/constants.hpp> 43 MC_WARNING(
"The global torso controller is overridden.");
45 MA::Torso.reset(
this);
51 if (MA::Torso.
get() ==
this)
58 float Pi = boost::math::constants::pi<float>();
69 state.
BodyMotion->AccelX.Degree = (int)(atan(
AccelX->GetSensorValue() / 1000000.0)*180.0 / Pi);
71 state.
BodyMotion->AccelY.Degree = (int)(atan(
AccelY->GetSensorValue() / 1000000.0)*180.0 / Pi);
73 state.
BodyMotion->AccelZ.Degree = (int)(atan(
AccelZ->GetSensorValue() / 1000000.0)*180.0 / Pi);
78 state.
Torso->FreeMemory = GetFreeMemory();
84 return MA::DeviceGeneratorsMap();
88 void MATorsoController::SetAccelRawHighresValues(
MANum<int>& value,
MADevice& device)
const 90 MC::IntList NewValues;
91 const MC::FloatList& OriginalValues = device.GetRealSensorValues();
93 for (
auto& value : OriginalValues)
95 NewValues.push_back((
int)(value / 100));
101 void MATorsoController::SetAccelDegreeHighresValues(
MANum<int>& value,
MADevice& device)
const 103 MC::IntList NewValues;
104 const MC::FloatList& OriginalValues = device.GetRealSensorValues();
106 for (
auto& value : OriginalValues)
108 NewValues.push_back((
int)(atan((value)/ 1000000.0)*180.0 / boost::math::constants::pi<float>()));
116 return MA::DeviceList();
120 void MATorsoController::RequestRestart()
126 void MATorsoController::RequestShutdown()
132 void MATorsoController::RequestDebugMode()
138 int MATorsoController::GetFreeMemory()
const boost::scoped_ptr< MADevice > BackFButton
Touchsensor on the back (fore)
boost::scoped_ptr< MADevice > InfraNear
Infrared sensor (near)
boost::scoped_ptr< MADevice > BackMButton
Touchsensor on the back (middle)
boost::scoped_ptr< MADevice > AccelX
Accelerometer sensor (X dimension)
virtual void UpdateRobotState(MARobotState &state) override
Update the robot state.
boost::scoped_ptr< MADevice > InfraChest
Infrared sensor (chest)
#define MC_WARNING(...)
Warning macro.
Base class for the controllers.
boost::scoped_ptr< MADevice > AccelZ
Accelerometer sensor (Z dimension)
boost::scoped_ptr< MADevice > InfraFar
Infrared sensor (far)
virtual MA::DeviceGeneratorsMap GetSkitTransitionGenerators(MA::SkitBaseSPtr skit) override
Get skit transition generators.
virtual MA::DeviceList GetMotors() const override
Get the list of the motors.
MATorsoController()
Class constructor.
boost::scoped_ptr< MABodyMotion > BodyMotion
Body motion.
boost::scoped_ptr< MADevice > AccelY
Accelerometer sensor (Y dimension)
boost::scoped_ptr< MADevice > BackRButton
Touchsensor on the back (rear)
A wrapper class to cover boost::thread_specific_ptr/folly::ThreadLocal API on certain targets...
void SetHighResolutionValues(const std::vector< T > &new_highres_values)
Set high resolution values.
boost::scoped_ptr< MATorso > Torso
Torso.
virtual ~MATorsoController()
Class destructor.