Robot: Use Base::toRadians to convert degree to radian
This commit is contained in:
@@ -30,20 +30,13 @@
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Writer.h>
|
||||
|
||||
#include "Robot6Axis.h"
|
||||
#include "RobotAlgos.h"
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#endif
|
||||
|
||||
using namespace Robot;
|
||||
using namespace Base;
|
||||
using namespace KDL;
|
||||
@@ -85,12 +78,12 @@ void Robot6Axis::setKinematic(const AxisDefinition KinDef[6])
|
||||
for (int i = 0; i < 6; i++) {
|
||||
temp.addSegment(Segment(Joint(Joint::RotZ),
|
||||
Frame::DH(KinDef[i].a,
|
||||
KinDef[i].alpha * (M_PI / 180),
|
||||
Base::toRadians<double>(KinDef[i].alpha),
|
||||
KinDef[i].d,
|
||||
KinDef[i].theta * (M_PI / 180))));
|
||||
Base::toRadians<double>(KinDef[i].theta))));
|
||||
RotDir[i] = KinDef[i].rotDir;
|
||||
Max(i) = KinDef[i].maxAngle * (M_PI / 180);
|
||||
Min(i) = KinDef[i].minAngle * (M_PI / 180);
|
||||
Max(i) = Base::toRadians<double>(KinDef[i].maxAngle);
|
||||
Min(i) = Base::toRadians<double>(KinDef[i].minAngle);
|
||||
Velocity[i] = KinDef[i].velocity;
|
||||
}
|
||||
|
||||
@@ -103,12 +96,12 @@ void Robot6Axis::setKinematic(const AxisDefinition KinDef[6])
|
||||
|
||||
double Robot6Axis::getMaxAngle(int Axis)
|
||||
{
|
||||
return Max(Axis) * (180.0 / M_PI);
|
||||
return Base::toDegrees<double>(Max(Axis));
|
||||
}
|
||||
|
||||
double Robot6Axis::getMinAngle(int Axis)
|
||||
{
|
||||
return Min(Axis) * (180.0 / M_PI);
|
||||
return Base::toDegrees<double>(Min(Axis));
|
||||
}
|
||||
|
||||
void split(std::string const& string, const char delimiter, std::vector<std::string>& destination)
|
||||
@@ -179,8 +172,8 @@ void Robot6Axis::Save(Writer& writer) const
|
||||
<< "Q2=\"" << Tip.getRotation()[2] << "\" "
|
||||
<< "Q3=\"" << Tip.getRotation()[3] << "\" "
|
||||
<< "rotDir=\"" << RotDir[i] << "\" "
|
||||
<< "maxAngle=\"" << Max(i) * (180.0 / M_PI) << "\" "
|
||||
<< "minAngle=\"" << Min(i) * (180.0 / M_PI) << "\" "
|
||||
<< "maxAngle=\"" << Base::toDegrees<double>(Max(i)) << "\" "
|
||||
<< "minAngle=\"" << Base::toDegrees<double>(Min(i)) << "\" "
|
||||
<< "AxisVelocity=\"" << Velocity[i] << "\" "
|
||||
<< "Pos=\"" << Actual(i) << "\"/>" << std::endl;
|
||||
}
|
||||
@@ -212,8 +205,8 @@ void Robot6Axis::Restore(XMLReader& reader)
|
||||
Velocity[i] = 1.0;
|
||||
}
|
||||
// read the axis constraints
|
||||
Min(i) = reader.getAttributeAsFloat("maxAngle") * (M_PI / 180);
|
||||
Max(i) = reader.getAttributeAsFloat("minAngle") * (M_PI / 180);
|
||||
Min(i) = Base::toRadians<double>(reader.getAttributeAsFloat("maxAngle"));
|
||||
Max(i) = Base::toRadians<double>(reader.getAttributeAsFloat("minAngle"));
|
||||
if (reader.hasAttribute("AxisVelocity")) {
|
||||
Velocity[i] = reader.getAttributeAsFloat("AxisVelocity");
|
||||
}
|
||||
@@ -292,11 +285,11 @@ bool Robot6Axis::calcTcp()
|
||||
|
||||
bool Robot6Axis::setAxis(int Axis, double Value)
|
||||
{
|
||||
Actual(Axis) = RotDir[Axis] * Value * (M_PI / 180); // degree to radiants
|
||||
Actual(Axis) = RotDir[Axis] * Base::toRadians<double>(Value);
|
||||
return calcTcp();
|
||||
}
|
||||
|
||||
double Robot6Axis::getAxis(int Axis)
|
||||
{
|
||||
return RotDir[Axis] * (Actual(Axis) / (M_PI / 180)); // radian to degree
|
||||
return RotDir[Axis] * Base::toDegrees<double>(Actual(Axis));
|
||||
}
|
||||
|
||||
@@ -35,15 +35,6 @@ using namespace Robot;
|
||||
using namespace std;
|
||||
using namespace KDL;
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
// FeatureView
|
||||
//===========================================================================
|
||||
|
||||
@@ -42,14 +42,6 @@
|
||||
#include "Trajectory.h"
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#endif
|
||||
|
||||
using namespace Robot;
|
||||
using namespace Base;
|
||||
|
||||
|
||||
@@ -31,15 +31,6 @@
|
||||
#include "Waypoint.h"
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#endif
|
||||
|
||||
using namespace Robot;
|
||||
using namespace Base;
|
||||
using namespace KDL;
|
||||
|
||||
Reference in New Issue
Block a user