User Tools

Site Tools


avatar_furo_source_codes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
avatar_furo_source_codes [2022/06/27 01:45] gleeavatar_furo_source_codes [2022/06/30 08:58] (current) glee
Line 188: Line 188:
   
  print(output_y)  print(output_y)
 +
 +def head_vel_callback(headCTR):
 + head_roll = headCTR.data
 +
 + if head_roll==4:
 + rospy.loginfo("Head downward")
 + GPIO.output(DIG2, GPIO.HIGH)
 + p1.start(0) # set AN2 as HIGH, M2B will turn ON
 + p2.start(30) # set Direction for M2  
 + #delay for 2 second
 +
 + if head_roll==2:
 + rospy.loginfo("Head upward")
 + GPIO.output(DIG2, GPIO.LOW)         
 + p1.start(0)                       
 + p2.start(30)                       
 +                           
 +     
 + if head_roll==5:
 + rospy.loginfo("STOP")
 + p1.start(0)                          # Direction can ignore
 + p2.start(0)                          # Direction can ignore
 +                             #delay for 3 second
 +
 +def listener():
 + rospy.init_node("furo_head")
 + rospy.Subscriber("cmd_head",Float32, head_vel_callback)
 + rospy.Subscriber("target_coordinate",Point, head_motion_callback)
 +
 + rate = rospy.Rate(200)
 + while not rospy.is_shutdown():
 + rate.sleep()
 +
 +
 +if __name__ == '__main__':
 + listener()
 </code> </code>
  
Line 601: Line 637:
 The ''**finalheadmotor.py**'' controls the motor controller of Furo's head.\\ The ''**finalheadmotor.py**'' controls the motor controller of Furo's head.\\
 Directory: ''**head_motor/src/finalheadmotor.py **'' Directory: ''**head_motor/src/finalheadmotor.py **''
-<code python | finalheadmotor.py>\\+<code python | finalheadmotor.py>
 #!/usr/bin/env python #!/usr/bin/env python
 # -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
avatar_furo_source_codes.1656319552.txt.gz · Last modified: 2022/06/27 01:45 by glee