Go to the documentation of this file.00001
00002 '''
00003 Created on Feb 04, 2013
00004
00005 @author: dnad
00006 '''
00007 import rospy;
00008 import math;
00009 from auv_msgs.msg import NavSts;
00010 from std_msgs.msg import String;
00011
00012 class WaveSim:
00013 def __init__(self):
00014 self.timebase = 0;
00015 self.Ts=0.1;
00016 self.H=rospy.get_param("wavesim/wave_height",4);
00017 self.T=rospy.get_param("wavesim/wave_period",5.6);
00018 self.L=rospy.get_param("wavesim/wave_length",50);
00019 self.k=2*math.pi/self.L;
00020 self.w=2*math.pi/self.T;
00021
00022 def onMeas(self, data):
00023 wave=String();
00024 self.timebase=self.timebase+self.Ts;
00025 theta=-self.k*data.position.north-self.w*self.timebase;
00026 elev=self.H/2*math.cos(theta);
00027 hv=math.pi*self.H/self.T*math.exp(self.k*elev)*math.cos(theta);
00028 wave.data=" ".join([str(-hv),'0','0']);
00029 wave_pub.publish(wave);
00030
00031 if __name__ == "__main__":
00032 rospy.init_node("cart2_wavesim");
00033
00034 sim = WaveSim();
00035
00036 rospy.Subscriber("meas_sim", NavSts, sim.onMeas)
00037 wave_pub = rospy.Publisher("currents",String)
00038
00039 while not rospy.is_shutdown():
00040 rospy.spin();
00041
00042
00043