Skip to content

Commit 27dec8c

Browse files
committed
fixed time stamp issue in visual tracker
1 parent 47075ef commit 27dec8c

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

source/dbrt/tracker/visual_tracker_node.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,12 @@ int main(int argc, char** argv)
116116
while (ros::ok())
117117
{
118118
visualization_rate.sleep();
119-
auto current_state = tracker_ros.current_state();
119+
State state;
120+
ros::Time time;
121+
tracker_ros.get_current_state(state, time);
120122

121-
// std::cout << "PUBLISHING ESTIMATED JONT ANGLES AND TF WITH"
122-
// "NOW() TIMESTAMP. THIS HAS TO BE FIXED!"
123-
// << std::endl;
124-
ros::Time time = ros::Time::now();
125-
tracker_publisher->publish_tf(current_state, time);
123+
state[2] = 3;
124+
tracker_publisher->publish_tf(state, time);
126125

127126
ros::spinOnce();
128127
}

source/dbrt/tracker/visual_tracker_ros.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ void VisualTrackerRos::track(const sensor_msgs::Image& ros_image)
3838
ros_image, camera_data_->downsampling_factor());
3939

4040
current_state_ = tracker_->track(image);
41+
current_time_ = ros_image.header.stamp;
4142
// current_pose_.pose = ri::to_ros_pose(current_state_);
4243
// current_pose_.header.stamp = ros_image.header.stamp;
4344
// current_pose_.header.frame_id= ros_image.header.frame_id;
@@ -87,8 +88,10 @@ bool VisualTrackerRos::process()
8788
return true;
8889
}
8990

90-
auto VisualTrackerRos::current_state() const -> const State&
91+
void VisualTrackerRos::get_current_state(State& state, ros::Time& time) const
9192
{
92-
return current_state_;
93+
state = current_state_;
94+
time = current_time_;
9395
}
96+
9497
}

source/dbrt/tracker/visual_tracker_ros.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <memory>
2323
#include <mutex>
2424
#include <dbrt/tracker/visual_tracker.h>
25+
#include <ros/time.h>
2526

2627
namespace dbrt
2728
{
@@ -57,13 +58,14 @@ class VisualTrackerRos
5758
*/
5859
void update_obsrv(const sensor_msgs::Image& ros_image);
5960

60-
const State& current_state() const;
61+
void get_current_state(State& state, ros::Time& time) const;
6162
const std::shared_ptr<VisualTracker>& tracker() { return tracker_; }
6263

6364
protected:
6465
bool obsrv_updated_;
6566
bool running_;
6667
State current_state_;
68+
ros::Time current_time_;
6769
sensor_msgs::Image current_ros_image_;
6870
std::mutex obsrv_mutex_;
6971
std::mutex state_mutex_;

0 commit comments

Comments
 (0)