<commit_before>#!/usr/bin/env python3
import rospy
import struct
from pymodbus.client.sync import ModbusSerialClient as modbus
from sensor_msgs.msg import Temperature
from std_msgs.msg import Float32
from geometry_msgs.msg import PoseWithCovarianceStamped

def publish():
	sensor = modbus(method='rtu', port='/dev/ucfsub/depth', baudrate=115200)
	sensor.connect()

	rospy.init_node('Depth')
	tempPub = rospy.Publisher('ExternalTemperature', Temperature, queue_size=1)
	depthPub = rospy.Publisher('depth', Float32, queue_size=1)
	posePub = rospy.Publisher('/depth/pose', PoseWithCovarianceStamped, queue_size=1)
	
	temp = Temperature()
	depth = Float32()
	
	updateRate = rospy.get_param("/updateRate", 30)
	freq = rospy.Rate(updateRate)
	loop = 0
	
	pose = PoseWithCovarianceStamped()
	pose.header.frame_id = "odom"
	pose.pose.covariance = [0.0]*36
	pose.pose.covariance[14] = 0.01
	pose.pose.pose.orientation.x = 0.0
	pose.pose.pose.orientation.y = 0.0
	pose.pose.pose.orientation.z = 0.0
	pose.pose.pose.orientation.w = 1.0
	pose.pose.pose.position.x = 0.0
	pose.pose.pose.position.y = 0.0
        
	while not rospy.is_shutdown():
		if loop >= updateRate:
			rr = sensor.read_holding_registers(address=8, count=2, unit=1)
			temp.temperature = struct.unpack('>f',struct.pack('>HH', *rr.registers))[0]
			tempPub.publish(temp)
			loop = 0
		loop += 1
			
		rr = sensor.read_holding_registers(address=2, count=2, unit=1)
		depth.data = struct.unpack('>f',struct.pack('>HH', *rr.registers))[0]
		depthPub.publish(depth)

		pose.pose.pose.position.z = depth.data * 10.2
		pose.header.stamp = rospy.Time.now()
		posePub.publish(pose)
		freq.sleep()

if __name__ == '__main__':
	try:
		publish()
	except rospy.ROSInterruptException:
		pass<commit_msg>Made depth sensor publish depth instead of pressure to float32 topic<commit_after>#!/usr/bin/env python3
import rospy
import struct
from pymodbus.client.sync import ModbusSerialClient as modbus
from sensor_msgs.msg import Temperature
from std_msgs.msg import Float32
from geometry_msgs.msg import PoseWithCovarianceStamped

def publish():
	sensor = modbus(method='rtu', port='/dev/ucfsub/depth', baudrate=115200)
	sensor.connect()

	rospy.init_node('Depth')
	tempPub = rospy.Publisher('ExternalTemperature', Temperature, queue_size=1)
	depthPub = rospy.Publisher('depth', Float32, queue_size=1)
	posePub = rospy.Publisher('/depth/pose', PoseWithCovarianceStamped, queue_size=1)
	
	temp = Temperature()
	depth = Float32()
	
	updateRate = rospy.get_param("/updateRate", 30)
	freq = rospy.Rate(updateRate)
	loop = 0
	
	pose = PoseWithCovarianceStamped()
	pose.header.frame_id = "odom"
	pose.pose.covariance = [0.0]*36
	pose.pose.covariance[14] = 0.01
	pose.pose.pose.orientation.x = 0.0
	pose.pose.pose.orientation.y = 0.0
	pose.pose.pose.orientation.z = 0.0
	pose.pose.pose.orientation.w = 1.0
	pose.pose.pose.position.x = 0.0
	pose.pose.pose.position.y = 0.0
        
	while not rospy.is_shutdown():
		if loop >= updateRate:
			rr = sensor.read_holding_registers(address=8, count=2, unit=1)
			temp.temperature = struct.unpack('>f',struct.pack('>HH', *rr.registers))[0]
			tempPub.publish(temp)
			loop = 0
		loop += 1
			
		rr = sensor.read_holding_registers(address=2, count=2, unit=1)
		depth.data = 10.2*struct.unpack('>f',struct.pack('>HH', *rr.registers))[0]

		pose.pose.pose.position.z = depth.data
		pose.header.stamp = rospy.Time.now()
		posePub.publish(pose)
		depthPub.publish(depth)
		freq.sleep()

if __name__ == '__main__':
	try:
		publish()
	except rospy.ROSInterruptException:
		pass
{'fraction_non_alphanumeric': 0.14047954866008464, 'fraction_numerical': 0.030465444287729196, 'mean_word_length': 4.619651347068146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2496045', 'n_tokens_mistral': 1480, 'n_tokens_neox': 1315, 'n_words': 240}