Since the transponder is not available on UWSim, I replace it with AUV. My idea is to make the target AUV send acoustic signal to transponder AUV and measure the travelling time of acoustic signal so that the distance between them can be calculated. In order to achieve this goal, I add talker.cpp and listener.cpp on UWSim and they can be run without error. Target AUV is talker and transponder AUV is listener and I make talker send message to listener. The code of listener and talker is shown below: talker.cpp #include "ros/ros.h"
#include "std_msgs/String.h"
#include
int main(int argc, char **argv)
{
ros::init(argc, argv, "girona500_target");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
ros::Rate loop_rate(10);
int count = 0;
while (ros::ok())
{
std_msgs::String msg;
std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();
ROS_INFO("%s", msg.data.c_str());
chatter_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
++count;
}
return 0;
}
listener.cpp:
#include "ros/ros.h"
#include "std_msgs/String.h"
void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("I heard: [%s]", msg->data.c_str());
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "girona500_t1");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
ros::spin();
return 0;
}
And the result is shown as below:
[ INFO] [1453837950.717697349]: hello world 3
[ INFO] [1453837950.817694234]: hello world 4
[ INFO] [1453837950.917714057]: hello world 5
[ INFO] [1453837950.717996492]: I heard: [hello world 3]
[ INFO] [1453837950.817922821]: I heard: [hello world 4]
[ INFO] [1453837950.917917595]: I heard: [hello world 5]
Unfortunately, the time in the result is CPU time. It is not the travelling time of acoustic signal. So, does anyone know how to get the travelling time of acoustic signal or is it possible to get the travelling time of acoustic signal.
Originally posted by ZYS on ROS Answers with karma: 108 on 2016-01-27
Post score: 0