Skip to content
Snippets Groups Projects
Commit 36402467 authored by Laia Freixas Mateu's avatar Laia Freixas Mateu
Browse files

started implementing usage of robot_pose_ekf

parent 5df4d0bb
No related branches found
No related tags found
1 merge request!3Kalman filter, solves #2
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
// [publisher subscriber headers] // [publisher subscriber headers]
#include <geometry_msgs/TransformStamped.h> #include <geometry_msgs/TransformStamped.h>
#include <nav_msgs/Odometry.h>
// [service client headers] // [service client headers]
// [action server client headers] // [action server client headers]
...@@ -53,6 +54,7 @@ class HtcViveTrackerAlgNode : public algorithm_base::IriBaseAlgorithm<HtcViveTra ...@@ -53,6 +54,7 @@ class HtcViveTrackerAlgNode : public algorithm_base::IriBaseAlgorithm<HtcViveTra
// [subscriber attributes] // [subscriber attributes]
ros::Publisher pose_publisher_; ros::Publisher pose_publisher_;
ros::Publisher vo_publisher_;
tf::TransformListener tf_listener_; tf::TransformListener tf_listener_;
// //
// [service attributes] // [service attributes]
...@@ -149,6 +151,9 @@ class HtcViveTrackerAlgNode : public algorithm_base::IriBaseAlgorithm<HtcViveTra ...@@ -149,6 +151,9 @@ class HtcViveTrackerAlgNode : public algorithm_base::IriBaseAlgorithm<HtcViveTra
void PrintAllDeviceNames(); void PrintAllDeviceNames();
tf::Quaternion ApplyRotationForIRIStandardCoordinates(const tf::Quaternion & orig); tf::Quaternion ApplyRotationForIRIStandardCoordinates(const tf::Quaternion & orig);
nav_msgs::Odometry CreateOdometryFromPoseVel(const geometry_msgs::PoseStamped & pose, const Velocity & vel);
}; };
#endif #endif
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
output = "screen"> output = "screen">
<param name="~target_frame_name" type="string" value="$(arg target_frame)"/> <param name="~target_frame_name" type="string" value="$(arg target_frame)"/>
<remap from="~new_pose" to="/iri_wam/pose_surface"/> <remap from="~new_pose" to="/iri_wam/pose_surface"/>
<remap from="~vo" to="/vo"/>
</node> </node>
</launch> </launch>
...@@ -5,4 +5,10 @@ ...@@ -5,4 +5,10 @@
<!-- Initialize tf-to-pose node from chaperone to tracker1--> <!-- Initialize tf-to-pose node from chaperone to tracker1-->
<arg name="target_frame" value ="$(arg device)"/> <arg name="target_frame" value ="$(arg device)"/>
</include> </include>
<include file="$(find robot_pose_ekf)/robot_pose_ekf.launch"/>
<param name="robot_pose_ekf/odom_used" value="false"/>
<param name="robot_pose_ekf/imu_used" value="false"/>
<param name="robot_pose_ekf/vo_used" value="false"/>
</launch> </launch>
...@@ -34,6 +34,7 @@ HtcViveTrackerAlgNode::HtcViveTrackerAlgNode(void) : ...@@ -34,6 +34,7 @@ HtcViveTrackerAlgNode::HtcViveTrackerAlgNode(void) :
this->source_frame_name_ = "chaperone"; this->source_frame_name_ = "chaperone";
pose_publisher_ = this->public_node_handle_.advertise<geometry_msgs::PoseStamped>("new_pose",100); pose_publisher_ = this->public_node_handle_.advertise<geometry_msgs::PoseStamped>("new_pose",100);
vo_publisher_ = this->public_node_handle_.advertise<nav_msgs::Odometry>("vo",100);
// [init publishers] // [init publishers]
...@@ -89,6 +90,9 @@ void HtcViveTrackerAlgNode::PublishPoseOfDeviceToFollow(void){ ...@@ -89,6 +90,9 @@ void HtcViveTrackerAlgNode::PublishPoseOfDeviceToFollow(void){
if (is_transform_possible) { if (is_transform_possible) {
this->tf_listener_.lookupTransform(this->source_frame_name_, this->target_frame_name_, ros::Time(0), stamped_transform); this->tf_listener_.lookupTransform(this->source_frame_name_, this->target_frame_name_, ros::Time(0), stamped_transform);
geometry_msgs::PoseStamped tf_pose = this->alg_.PoseFromTF(stamped_transform); geometry_msgs::PoseStamped tf_pose = this->alg_.PoseFromTF(stamped_transform);
Velocity device_vel = this->alg_.GetDeviceVelocity(this->target_frame_name_);
nav_msgs::Odometry current_vo = this->CreateOdometryFromPoseVel(tf_pose, device_vel);
this->vo_publisher_.publish(current_vo);
this->pose_publisher_.publish(tf_pose); this->pose_publisher_.publish(tf_pose);
} }
else { else {
...@@ -225,6 +229,28 @@ bool HtcViveTrackerAlgNode::get_button_serverCallback(iri_htc_vive_tracker::GetB ...@@ -225,6 +229,28 @@ bool HtcViveTrackerAlgNode::get_button_serverCallback(iri_htc_vive_tracker::GetB
if (!res.success) res.message = this->alg_.DEVICE_NOT_FOUND_MSG; if (!res.success) res.message = this->alg_.DEVICE_NOT_FOUND_MSG;
return true; return true;
} }
nav_msgs::Odometry HtcViveTrackerAlgNode::CreateOdometryFromPoseVel(const geometry_msgs::PoseStamped & pose, const Velocity & vel){
geometry_msgs::TwistWithCovariance twist_msg;
twist_msg.twist.linear.x = vel.linear_velocity.x;
twist_msg.twist.linear.y = vel.linear_velocity.y;
twist_msg.twist.linear.z = vel.linear_velocity.z;
twist_msg.twist.angular.x = vel.angular_velocity.x;
twist_msg.twist.angular.y = vel.angular_velocity.y;
twist_msg.twist.angular.z = vel.angular_velocity.z;
//TODO Fill covariance
geometry_msgs::PoseWithCovariance pose_msg;
pose_msg.pose = pose.pose;
//TODO Fill covariance
nav_msgs::Odometry odom;
odom.header.stamp = ros::Time::now();
odom.header.frame_id = this->alg_.WORLD_NAME;
odom.child_frame_id = this->target_frame_name_;
odom.pose = pose_msg;
odom.twist = twist_msg;
return odom;
}
/* main function */ /* main function */
int main(int argc,char *argv[]) int main(int argc,char *argv[])
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment