ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Wed, 27 Dec 2017 04:55:33 -0600Problem with data from subscriber not going anywherehttps://answers.ros.org/question/278225/problem-with-data-from-subscriber-not-going-anywhere/ Related question: https://answers.ros.org/question/278181/issues-with-seg-faults-and-node-not-publishing-anything/
In my code there are two subscriber functions. I want to pass the shared pointer data to other data defined in my file. My code is below:
std::vector<double> imu_, euler_t;
ros::Publisher escs_pub;
ros::Subscriber imu_sub;
ros::Subscriber DOF_sub;
double I_cm_xx, I_cm_yy, I_cm_zz, P_q, P_w;
void KeyboardCallback(const maple::Euler_Thrust::ConstPtr& msg){
euler_t.clear();
euler_t.resize(4);
euler_t.push_back((msg->psi)*3.14159265359/180);
euler_t.push_back((msg->phi)*3.14159265359/180);
euler_t.push_back((msg->theta)*3.14159265359/180);
euler_t.push_back(msg->thrust);
}
void imuCallback(const sensor_msgs::Imu::ConstPtr &imu) {
imu_.clear();
imu_.resize(7);
imu_.push_back(imu->orientation.x);
imu_.push_back(imu->orientation.y);
imu_.push_back(imu->orientation.z);
imu_.push_back(imu->orientation.w);
imu_.push_back(imu->angular_velocity.x);
imu_.push_back(imu->angular_velocity.y);
imu_.push_back(imu->angular_velocity.z);
}
int main(int argc, char **argv){
ros::init(argc, argv, "P_2");
ros::NodeHandle nh;
ros::NodeHandle pnh("~");
pnh.param("I_cm_xx", I_cm_xx, 0.0118);
pnh.param("I_cm_yy", I_cm_yy, 0.0118);
pnh.param("I_cm_zz", I_cm_zz, 0.0181);
pnh.param("P_q", P_q, 2.27);
pnh.param("P_w", P_w, 0.85);
while(ros::ok()){
ROS_INFO("oy1");
escs_pub = nh.advertise<maple::ESCs>("ESCs",1);
DOF_sub = nh.subscribe("KeyboardTeleop", 1, KeyboardCallback);
imu_sub = nh.subscribe("imu", 1, imuCallback);
my_pkg::std_msg msg;
double q_ref_w = cos(euler_t[0]/2)*cos(euler_t[1]/2)*cos(euler_t[2]/2); //THIS IS WHERE THE SEGMENTATION FAULT OCCURS, BECAUSE THE EULER_T VECTOR IS EMPTY OR UNPOPULATED!!!!!!
//more math
escs_pub.publish(msg);
ros::spin();
}
return 0;
}
I'm so lost... When excluding any operations with the vectors doing ROS_INFO inside the subscriber functions shows that they do indeed get the data too. I made this code as simple as it can be and it's still not working. I have a feeling it's a problem with the vectors not being passed the values in the right order and I tried that but nothing works. Please, any help would be massively appreciatedhanjuku-joshiWed, 27 Dec 2017 04:55:33 -0600https://answers.ros.org/question/278225/What is the proper way to obtain the fixed-axis covariance matrix from quaternions?https://answers.ros.org/question/138541/what-is-the-proper-way-to-obtain-the-fixed-axis-covariance-matrix-from-quaternions/[REP 103](http://www.ros.org/reps/rep-0103.html) defines the standard for rotation representation as quaternions, but the covariance matrix associated to it is given in terms of fixed axis rotations. In my work, I use quaternions directly for attitude estimation and obtain covariances in terms of the quaternion parameters.
How can I convert these covariances to the convention used by ROS, so they can be published appropriately?
PS: I have searched ROS Answers and found a few discussions briefly addressing this topic, but usually referring to [external documents](http://answers.ros.org/question/9446/how-do-i-compute-the-covariance-matrix-for-an-orientation-sensor/) or [additional packages](http://answers.ros.org/question/9446/how-do-i-compute-the-covariance-matrix-for-an-orientation-sensor/). I think it would be useful to have a single definitive reference for this here, so that implementations don't depend on the reader's interpretation of what is expected.georgebrindeiroTue, 11 Mar 2014 01:45:17 -0500https://answers.ros.org/question/138541/