0
$\begingroup$

Rosanswers logo

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

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hi,

Even if your files are inside UWSim they are just sending messages to each other through ROS, so no simulation is involved (That is the reason why you are getting CPU time). Unfortunately, as you said, UWSim does not offer this kind of simulation capabilities at this moment.

So, depending on the precision required I would suggest to implement it yourself adding delays, missing packages... depending on the position of both AUV's. Adding a accoustic signal sim node that receives messages, keeps track of the vehicle's position and resends messages to the possible listeners, so each AUV should have a publisher and subscriber that will send/receive to the sim node.


Originally posted by Javier Perez with karma: 486 on 2016-01-27

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by ZYS on 2016-01-27:
Thanks for your suggestion. In order to get the time delay, I must know the distance between both AUV. But the GPS doesn't work underwater on the UWSim. How can I know the position of the target AUV?

Comment by Javier Perez on 2016-01-28:
You can get it using TF, just look for the transform from world to [nameofvehicle]. And check WorldToROSTF is configured in the scene (default scene has it).

Comment by ZYS on 2016-01-28:
Thanks for your suggestion.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.