rpng / R-VIO

Robocentric Visual-Inertial Odometry
https://journals.sagepub.com/doi/10.1177/0278364919853361
GNU General Public License v3.0
753 stars 174 forks source link

How to use this code to publish a odom node? #19

Closed sunt40 closed 4 years ago

huaizheng commented 4 years ago

For this, you can instead fill the output of estimator, q and p, into a new 'nav_msgs::Odometry' message and then publish it, based on the current codebase. You can find an example here http://wiki.ros.org/navigation/Tutorials/RobotSetup/Odom.

sunt40 commented 4 years ago

I have read your code but I have no idea how to modify your code to public the /odom topic. Can you give me some further advices? Thank you. @huaizheng

huaizheng commented 4 years ago

Please check my code in rvio/System.cc, where I publish two types of messages at the end, tf and nav_msgs::Path, once having the optimal state estimate. So if you would like to publish other messages, you can put your code there referring to the example in my last comment.

sunt40 commented 4 years ago

The following is what I have added code: `#include <nav_msgs/Odometry.h>

include<tf/transform_broadcaster.h>

nav_msgs::Odometry odom;

mOdomPub = mSystemNode.advertise("/odom", 0);

//broadcast odom geometry_msgs::Odometry odom; //geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th); tf::TransformBroadcaster odom_broadcaster; odom_broadcaster.sendTransform(transformStamped); odom.header.stamp = current_time; odom.header.frame_id = "odom";

odom.pose.pose.position.x = pGk(0);
odom.pose.pose.position.y = pGk(1);
odom.pose.pose.position.z = pGk(2);
odom.pose.pose.orientation = qkG(0);

odom.child_frame_id = "base_link";
odom.twist.twist.linear.x = xv;
odom.twist.twist.linear.y = yv;
odom.twist.twist.linear.z = zv;
mOdompub.publish(odom);`

Obviously,there is a lot of mistakes,so please give me your advice. @huaizheng

sunt40 commented 4 years ago

And, I don't really understand the meaning of many of your parameters. This makes it very difficult to write code.

huaizheng commented 4 years ago

First, if you don't understand the meaning of parameters, the best way is to go back to read the papers where all the equations have been released, and this code is the exact implementation. Also, I have given you my advice about your problem, a ROS-related practice, which definitely should not be difficult to solve by yourself.

sunt40 commented 4 years ago

OK。I have download your paper and I will read it carefully.

sunt40 commented 4 years ago

I am a beginner of VIO and your algorithm is quite novle. Now although I can publish a "odom" topic,I tried to use some parameters but still failed to publish the correct odometry messages. The following image is the details of the "odom" publish. Can you tell me which parameters I should use in your code ? Thank you very much! @huaizheng odom内容

huaizheng commented 4 years ago

I just implemented it myself and have pushed the code, please go and check how I made this work.