<commit_before>#!/usr/bin/env python
import roslib; roslib.load_manifest('reactivecontrol')
import rospy
from reactivecontrol.msg import IRdistance
from geometry_msgs.msg import Transform
from std_msgs.msg import Bool

class reactive_control: 
	"""
		Class that controls the reactive control

	"""
	def __init__( self ): 

		

		#publisher for control message
		self.control_pub = rospy.Publisher('reactivecontol/Control', Transform)
		
		#Forcing take over of arbitrator to switch to reactive control 
		self.abitrator_takeover = rospy.Publisher('reactivecontrol/ArbitratorForceTakeover', Bool)
		
		
		# PID stuff 
		self.previous_error = 0.0
		self.setpoint = 25.0
		self.Kp = .01
		self.Kd = 0.0

	def start( self ): 
		"""
			Intializes reactive control
		"""

		# Opening up nodes and such
		rospy.init_node('Reactive_Control')    
		rospy.Subscriber("ircm/IRoutput", IRdistance, self.__input_callback)
		rospy.spin()

	def __input_callback( self, distance ):
		"""	
			Called back whenever new data is recieved from IR Output
		"""			
		
		# Calling the PD control function
		self.__pd_control( distance )

		# Calling the Averge distance following function
		#self.__avg_distance_following( distance )

	def __pd_control( self, distance ): 
		"""
			Control using a PD controller
			PD - Proportional Derivitive  

			NOTE:
				I term is not implemented 
				as reactive control is not always running
				and 'windup' could be a serious issue
		"""
		
		avg_distance = self.__avg_distance( distance )

		if avg_distance is not 0.0: 
			
			error = avg_distance - self.setpoint
		
			derivative = ( error - self.previous_error )
			output = self.Kp * error + self.Kd * derivative

		
			position = Transform()
		
			position.translation.x = 0.0;
			position.translation.z = .5;
			position.translation.y = output;
	
			#rospy.loginfo("Distance " + str( self.__avg_distance( distance ) ) + " Error: " + str(error) + " PD Output: " + str(position.translation.y) )
		
			self.__publish_position( position ) 		

			self.abitrator_takeover.publish(True)
		else:
			rospy.loginfo("No valid IR data infromation")
		

	def __avg_distance( self, distance ):
		"""
			Calculates the distance based on the average of the 
			two IR sensors.  
		"""
<commit_msg>Correct a dismal spelling mistake<commit_after>#!/usr/bin/env python
import roslib; roslib.load_manifest('reactivecontrol')
import rospy
from reactivecontrol.msg import IRdistance
from geometry_msgs.msg import Transform
from std_msgs.msg import Bool

class reactive_control: 
	"""
		Class that controls the reactive control

	"""
	def __init__( self ): 

		

		#publisher for control message
		self.control_pub = rospy.Publisher('reactivecontrol/Control', Transform)
		
		#Forcing take over of arbitrator to switch to reactive control 
		self.abitrator_takeover = rospy.Publisher('reactivecontrol/ArbitratorForceTakeover', Bool)
		
		
		# PID stuff 
		self.previous_error = 0.0
		self.setpoint = 25.0
		self.Kp = .01
		self.Kd = 0.0

	def start( self ): 
		"""
			Intializes reactive control
		"""

		# Opening up nodes and such
		rospy.init_node('Reactive_Control')    
		rospy.Subscriber("ircm/IRoutput", IRdistance, self.__input_callback)
		rospy.spin()

	def __input_callback( self, distance ):
		"""	
			Called back whenever new data is recieved from IR Output
		"""			
		
		# Calling the PD control function
		self.__pd_control( distance )

		# Calling the Averge distance following function
		#self.__avg_distance_following( distance )

	def __pd_control( self, distance ): 
		"""
			Control using a PD controller
			PD - Proportional Derivitive  

			NOTE:
				I term is not implemented 
				as reactive control is not always running
				and 'windup' could be a serious issue
		"""
		
		avg_distance = self.__avg_distance( distance )

		if avg_distance is not 0.0 and avg_distance < 80 and avg_distance > 15: 
			
			error = avg_distance - self.setpoint
		
			derivative = ( error - self.previous_error )
			output = self.Kp * error + self.Kd * derivative

		
			position = Transform()
		
			position.translation.x = 0.0;
			position.translation.z = .5;
			position.translation.y = output;
	
			#rospy.loginfo("Distance " + str( self.__avg_distance( distance ) ) + " Error: " + str(error) + " PD Output: " + str(position.translation.y) )
		
			self.__publish_position( position ) 		

			self.abitrator_takeover.publish(True)
		else:
			rospy.loginfo("No valid IR data infromation or IR data is out of range measured: " str( avg_distance) )
		

	def __avg_distance( self, distance ):
		"""
			Calculates the distance based on the average of the 
			two IR sensors.  
		"""

{'fraction_non_alphanumeric': 0.09122277334483503, 'fraction_numerical': 0.006901013586370498, 'mean_word_length': 3.371347785108388, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6881331', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1427, 'n_words': 416}