本文整理汇总了C++中eigen::Quaterniond::x方法的典型用法代码示例。如果您正苦于以下问题:C++ Quaterniond::x方法的具体用法?C++ Quaterniond::x怎么用?C++ Quaterniond::x使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::Quaterniond
的用法示例。
在下文中一共展示了Quaterniond::x方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printQuatAngles
void printQuatAngles(Eigen::Quaterniond& quat)
{
double heading = atan2(2*quat.y()*quat.w()-2*quat.x()*quat.z(), 1 -2 * quat.y()*quat.y()-2*quat.z()*quat.z());
double attitude = asin(2*quat.x()*quat.y() + 2 *quat.z()*quat.w());
double bank = atan2(2*quat.x()*quat.w()- 2 * quat.y()*quat.z(), 1 - 2 *quat.x() * quat.x() -2 * quat.z() * quat.z());
cout << "heading: " << Angle(heading).deg() << " attitude: " << Angle(attitude).deg() << " bank: " << Angle(bank).deg() << endl;
}
示例2: asin
static inline Eigen::Vector3d
_quat_to_roll_pitch_yaw(const Eigen::Quaterniond&q)
{
double roll_a = 2 * (q.w() * q.x() + q.y() * q.z());
double roll_b = 1 - 2 * (q.x() * q.x() + q.y() * q.y());
double roll = atan2(roll_a, roll_b);
double pitch_sin = 2 * (q.w() * q.y() - q.z() * q.x());
double pitch = asin(pitch_sin);
double yaw_a = 2 * (q.w() * q.z() + q.x() * q.y());
double yaw_b = 1 - 2 * (q.y() * q.y() + q.z() * q.z());
double yaw = atan2(yaw_a, yaw_b);
return Eigen::Vector3d(roll, pitch, yaw);
}
示例3: transform
/**
* @function pose2Affine3d
*/
Eigen::Affine3d DartLoader::pose2Affine3d( urdf::Pose _pose ) {
Eigen::Quaterniond quat;
_pose.rotation.getQuaternion(quat.x(), quat.y(), quat.z(), quat.w());
Eigen::Affine3d transform(quat);
transform.translation() = Eigen::Vector3d(_pose.position.x, _pose.position.y, _pose.position.z);
return transform;
}
示例4: pick_positive
Eigen::Quaterniond pick_positive(const Eigen::Quaterniond& other) {
if (other.w() < 0) {
return Eigen::Quaterniond(-other.w(), -other.x(), -other.y(), -other.z());
} else {
return other;
}
}
示例5: set_attitude
void RigidBody::set_attitude(Eigen::Quaterniond _attitude)
{
attitude.w() = _attitude.w();
attitude.x() = _attitude.x();
attitude.y() = _attitude.y();
attitude.z() = _attitude.z();
}
示例6: getRobotState
void App::getRobotState(drc::robot_state_t& robot_state_msg, int64_t utime_in, Eigen::VectorXd q, std::vector<std::string> jointNames){
robot_state_msg.utime = utime_in;
// Pelvis Pose:
robot_state_msg.pose.translation.x =q(0);
robot_state_msg.pose.translation.y =q(1);
robot_state_msg.pose.translation.z =q(2);
Eigen::Quaterniond quat = euler_to_quat( q(3), q(4), q(5));
robot_state_msg.pose.rotation.w = quat.w();
robot_state_msg.pose.rotation.x = quat.x();
robot_state_msg.pose.rotation.y = quat.y();
robot_state_msg.pose.rotation.z = quat.z();
robot_state_msg.twist.linear_velocity.x = 0;
robot_state_msg.twist.linear_velocity.y = 0;
robot_state_msg.twist.linear_velocity.z = 0;
robot_state_msg.twist.angular_velocity.x = 0;
robot_state_msg.twist.angular_velocity.y = 0;
robot_state_msg.twist.angular_velocity.z = 0;
// Joint States:
for (size_t i = 0; i < jointNames.size(); i++) {
robot_state_msg.joint_name.push_back( jointNames[i] );
robot_state_msg.joint_position.push_back( q(i) );
robot_state_msg.joint_velocity.push_back( 0);
robot_state_msg.joint_effort.push_back( 0 );
}
robot_state_msg.num_joints = robot_state_msg.joint_position.size();
}
示例7: transform
/**
* @function pose2Affine3d
*/
Eigen::Isometry3d DartLoader::toEigen(const urdf::Pose& _pose) {
Eigen::Quaterniond quat;
_pose.rotation.getQuaternion(quat.x(), quat.y(), quat.z(), quat.w());
Eigen::Isometry3d transform(quat);
transform.translation() = Eigen::Vector3d(_pose.position.x, _pose.position.y, _pose.position.z);
return transform;
}
示例8: generatePoseMessage
geometry_msgs::PoseStamped MutualPoseEstimation::generatePoseMessage(const Eigen::Vector3d &position, Eigen::Matrix3d rotation){
geometry_msgs::PoseStamped estimated_position;
estimated_position.header.frame_id = "ardrone_base_frontcam";//ardrone_base_link
//estimated_position.pose.position.x = position[2] + 0.21; // z
//estimated_position.pose.position.y = -position[0]; // x
//estimated_position.pose.position.z = -position[1]; //-y
estimated_position.pose.position.x = position[0] + 0.21;
estimated_position.pose.position.y = position[1];
estimated_position.pose.position.z = position[2];
/*rotation = Eigen::AngleAxisd(M_PI, Eigen::Vector3d::UnitZ())
* rotation;*/
Eigen::Quaterniond q = Eigen::Quaterniond(rotation);
// estimated_position.pose.orientation.x = q.z();
// estimated_position.pose.orientation.y = -q.x();
// estimated_position.pose.orientation.z = -q.y();
// estimated_position.pose.orientation.w = q.w();
estimated_position.pose.orientation.x = q.x();
estimated_position.pose.orientation.y = q.y();
estimated_position.pose.orientation.z = q.z();
estimated_position.pose.orientation.w = q.w();
return estimated_position;
}
开发者ID:MobileRobotics-Ulaval,项目名称:CollaborativeDroneLocalization,代码行数:26,代码来源:mutual_pose_estimation.cpp
示例9: quaternionEigenToMsg
void quaternionEigenToMsg(const Eigen::Quaterniond &e, geometry_msgs::Quaternion &m)
{
m.x = e.x();
m.y = e.y();
m.z = e.z();
m.w = e.w();
}
示例10:
bool constraint_samplers::IKConstraintSampler::sample(planning_models::KinematicState::JointStateGroup *jsg, const planning_models::KinematicState &ks, unsigned int max_attempts)
{
// make sure we at least have a chance of sampling using IK; we need at least some kind of constraint
if (!sampling_pose_.position_constraint_ && !sampling_pose_.orientation_constraint_)
return false;
// load an IK solver if we need to
if (!loadIKSolver())
{
kb_.reset();
return false;
}
for (unsigned int a = 0 ; a < max_attempts ; ++a)
{
// sample a point in the constraint region
Eigen::Vector3d point;
Eigen::Quaterniond quat;
if (!samplePose(point, quat, ks, max_attempts))
return false;
geometry_msgs::Pose ik_query;
ik_query.position.x = point.x();
ik_query.position.y = point.y();
ik_query.position.z = point.z();
ik_query.orientation.x = quat.x();
ik_query.orientation.y = quat.y();
ik_query.orientation.z = quat.z();
ik_query.orientation.w = quat.w();
if (callIK(ik_query, ik_timeout_, jsg))
return true;
}
return false;
}
示例11: PoseAffineToGeomMsg
geometry_msgs::Pose PoseAffineToGeomMsg(const Eigen::Affine3d &e) {
geometry_msgs::Pose m;
m.position.x = e.translation().x();
m.position.y = e.translation().y();
m.position.z = e.translation().z();
// This is a column major vs row major matrice faux pas!
#if 0
MatrixEXd em = e.rotation();
Eigen::Quaterniond q = EMatrix2Quaterion(em);
#endif
Eigen::Quaterniond q(e.rotation());
m.orientation.x = q.x();
m.orientation.y = q.y();
m.orientation.z = q.z();
m.orientation.w = q.w();
#if 0
if (m.orientation.w < 0) {
m.orientation.x *= -1;
m.orientation.y *= -1;
m.orientation.z *= -1;
m.orientation.w *= -1;
}
#endif
}
示例12: rotateSatelliteFrame
Eigen::Quaterniond VizHelperNode::rotateSatelliteFrame(const iri_common_drivers_msgs::SatellitePseudorange &sat, ros::Time time_ros)
{
Eigen::Quaterniond rotation;
Eigen::Vector3d satVelocity(sat.v_x * scale, sat.v_y * scale, sat.v_z * scale);
//quaternione che fa ruotare l'asse x in modo che combaci con il vettore velocita'
rotation.setFromTwoVectors(Eigen::Vector3d::UnitX(), satVelocity);
geometry_msgs::Quaternion odom_quat;
odom_quat.x = rotation.x();
odom_quat.y = rotation.y();
odom_quat.z = rotation.z();
odom_quat.w = rotation.w();
// Publish the transform over tf
geometry_msgs::TransformStamped odom_trans;
odom_trans.header.stamp = time_ros;
odom_trans.header.frame_id = WORLD_FRAME; //frame padre
odom_trans.child_frame_id = getSatelliteFrame(sat.sat_id); //frame figlio (che sto creando ora)
odom_trans.transform.translation.x = sat.x * scale;//traslazione dell'origine
odom_trans.transform.translation.y = sat.y * scale;
odom_trans.transform.translation.z = sat.z * scale;
odom_trans.transform.rotation = odom_quat; //rotazione
//send the transform
transBroadcaster.sendTransform(odom_trans);
return rotation;
}
示例13: publishOdometry
void VizHelperNode::publishOdometry(const iri_common_drivers_msgs::SatellitePseudorange &sat, const Eigen::Quaterniond &rotation, ros::Time time_ros)
{
/// publish the odometry message over ROS
nav_msgs::Odometry odom;
odom.header.stamp = time_ros;
odom.header.frame_id = WORLD_FRAME;
//set the position
odom.pose.pose.position.x = sat.x * scale;
odom.pose.pose.position.y = sat.y * scale;
odom.pose.pose.position.z = sat.z * scale;
//set the orientation
odom.pose.pose.orientation.x = rotation.x();
odom.pose.pose.orientation.y = rotation.y();
odom.pose.pose.orientation.z = rotation.z();
odom.pose.pose.orientation.w = rotation.w();
//set the velocity
odom.child_frame_id = getSatelliteFrame(sat.sat_id);
odom.twist.twist.linear.x = sat.v_x * scale;
odom.twist.twist.linear.y = sat.v_y * scale;
odom.twist.twist.linear.z = sat.v_z * scale;
odom.twist.twist.angular.x = 0;
odom.twist.twist.angular.y = 0;
odom.twist.twist.angular.z = 0;
//publish the message
//TODO fare i singoli odom publisher
// odomPub[index].publish(odom);
odomAllPub.publish(odom);
}
示例14: getOdomPose
bool RosMessageContext::getOdomPose(Eigen::Isometry3d& _trans, double time){
bool transformFound = true;
_tfListener->waitForTransform(_odomReferenceFrameId, _baseReferenceFrameId,
ros::Time(time), ros::Duration(1.0));
try{
tf::StampedTransform t;
_tfListener->lookupTransform(_odomReferenceFrameId, _baseReferenceFrameId,
ros::Time(time), t);
Eigen::Isometry3d transform;
transform.translation().x()=t.getOrigin().x();
transform.translation().y()=t.getOrigin().y();
transform.translation().z()=t.getOrigin().z();
Eigen::Quaterniond rot;
rot.x()=t.getRotation().x();
rot.y()=t.getRotation().y();
rot.z()=t.getRotation().z();
rot.w()=t.getRotation().w();
transform.linear()=rot.toRotationMatrix();
_trans = transform;
transformFound = true;
}
catch (tf::TransformException ex){
ROS_ERROR("%s",ex.what());
transformFound = false;
}
return transformFound;
}
示例15: quaternionEigenToTF
void quaternionEigenToTF(const Eigen::Quaterniond& e, tf::Quaternion& t)
{
t[0] = e.x();
t[1] = e.y();
t[2] = e.z();
t[3] = e.w();
}