22 #include "MABodyTypes.hpp" 24 #include "MARobotState.hpp" 25 #include "MABodyMotion.hpp" 26 #include "MATypeRanges.hpp" 28 #include <boost/bind.hpp> 33 Value(value, minimum, maximum)
39 UpDownValue(0, -100, 100)
73 Ret = 90+(int)round(UpDown*90 / 100);
79 Ret = (int)-(round(UpDown*(-MA::Joint1Min-90) / 100)+90);
81 Ret = (int)(round(UpDown*(MA::Joint1Max-90) / 100)+90);
86 void MALegPosition::NotifyNumUpdate(
MANum<float>& number)
107 float MALegPosition::DegreeToForeBack(
int degree)
const 111 if (unlikely(degree >= 90))
114 if (unlikely(degree <= -90))
117 Ret = (float)(degree*100) / 90;
122 float MALegPosition::DegreeToUpDown(
int degree)
const 126 if (likely(
MCAbs(degree) <= 90))
128 Ret = -(float)((90-
MCAbs(degree))*100) / 90;
131 if (unlikely(degree < -90))
132 Ret = -(
float)((degree+90)*100) / (-MA::Joint1Min-90);
134 if (unlikely(degree > 90))
135 Ret = (
float)((degree-90)*100) / (MA::Joint1Max-90);
147 Value = (float)((degree-MA::Joint2Min)*100) / (-MA::Joint2Min+MA::Joint2Max);
153 return (
int)round((
float)
Value*(-MA::Joint2Min+MA::Joint2Max) / 100)+MA::Joint2Min;
164 Value = degree <= 0 ? 0 : (float)(degree*100) / MA::Joint3Max;
170 return (
int)round((
float)
Value*MA::Joint3Max / 100);
181 Value = -(float)(degree*100) / MA::NeckPanMax;
187 return -(int)round((
float)
Value*MA::NeckPanMax / 100);
210 void MAHeadPosition::FromJointDegrees(
int neck_tilt1,
int neck_tilt2)
212 MANum<int> NeckTilt1(neck_tilt1, MA::NeckT1Min, MA::NeckT1Max);
213 MANum<int> NeckTilt2(neck_tilt2, MA::NeckT2Min, MA::NeckT2Max);
214 int ZeroDegreeCorrection = (MA::RobotState.get() && MA::RobotState->BodyMotion->Sitting > 80) ? 35 : 0;
215 int ZeroDegree = -NeckTilt1-ZeroDegreeCorrection;
217 ForeBackValue = -(float)((
int)NeckTilt1+ZeroDegreeCorrection);
222 int MAHeadPosition::ToNeckTilt1Degree()
const 224 int ZeroDegreeCorrection = (MA::RobotState.get() && MA::RobotState->BodyMotion->Sitting > 80) ? 35 : 0;
231 int MAHeadPosition::ToNeckTilt2Degree()
const 233 int ZeroDegreeCorrection = (MA::RobotState.get() && MA::RobotState->BodyMotion->Sitting > 80) ? 35 : 0;
234 MANum<int> Degree((
int)
UpDownValue-ToNeckTilt1Degree()-ZeroDegreeCorrection, MA::NeckT2Min, MA::NeckT2Max);
247 Value = degree <= -60.0 ? 100.0 : 100.0-(float)((degree-MA::MouthMin)*100) / (MA::MouthMax-MA::MouthMin);
253 return MA::MouthMin+(int)round((
float)(100.0-
Value)*(MA::MouthMax-MA::MouthMin) / 100);
MANum< float > Value
Current value.
virtual int ToJointDegree() const override
Transform to a joint degree value.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
MABodyPartFeature(int value=0, int minimum=-100, int maximum=100)
Struct constructor.
MAMouthOpened(int value=0)
Struct constructor.
MANum< float > UpDownValue
Current up-down direction value.
boost::shared_ptr< ValueChangeSignalType > & GetValueChangeSignal()
Get the value change signal.
void SetBlockedNotifications(bool new_state)
Set the notifications to be blocked.
The forward-backward/upward-downward feature of a leg joint.
MANum< float > UpDownValue
Current up-down direction value.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
virtual int ToJointDegree() const override
Transform to a joint degree value.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
MANum< float > ForeBackValue
Current fore-back direction value.
T MCAbs(const T &value)
Calculate absolute value.
MAHeadPosition()
Struct constructor.
MASidelong(int value=0)
Struct constructor.
A base class for the limb features.
virtual int ToJointDegree() const override
Transform to a joint degree value.
virtual int ToJointDegree() const override
Transform to a joint degree value.
virtual int ToJointDegree() const override
Transform to a joint degree value.
#define MC_UNUSED(a)
Helper macro to avoid compiler warning about unused function parameters.
virtual int ToJointDegree() const override
Transform to a joint degree value.
MABentStretched(int value=0)
Struct constructor.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
virtual void FromJointDegree(int degree) override
Compute from a joint degree value.
MALeftRightTurned(int value=0)
Struct constructor.
MA_SLOT_CLASS MALegPosition()
Struct constructor.
MANum< float > ForeBackValue
Current fore-back direction value.