avatar_furo_source_codes
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
avatar_furo_source_codes [2022/06/27 01:30] – glee | avatar_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(" | ||
+ | GPIO.output(DIG2, | ||
+ | p1.start(0) # | ||
+ | p2.start(30) # | ||
+ | # | ||
+ | |||
+ | if head_roll==2: | ||
+ | rospy.loginfo(" | ||
+ | GPIO.output(DIG2, | ||
+ | p1.start(0) | ||
+ | p2.start(30) | ||
+ | | ||
+ | | ||
+ | if head_roll==5: | ||
+ | rospy.loginfo(" | ||
+ | p1.start(0) | ||
+ | p2.start(0) | ||
+ | #delay for 3 second | ||
+ | |||
+ | def listener(): | ||
+ | rospy.init_node(" | ||
+ | rospy.Subscriber(" | ||
+ | rospy.Subscriber(" | ||
+ | |||
+ | rate = rospy.Rate(200) | ||
+ | while not rospy.is_shutdown(): | ||
+ | rate.sleep() | ||
+ | |||
+ | |||
+ | if __name__ == ' | ||
+ | listener() | ||
</ | </ | ||
Line 200: | Line 236: | ||
Directory: '' | Directory: '' | ||
CMakeList Directory: '' | CMakeList Directory: '' | ||
- | \\ | ||
<code cpp | CMakeLists.txt> | <code cpp | CMakeLists.txt> | ||
cmake_minimum_required(VERSION 2.8.3) | cmake_minimum_required(VERSION 2.8.3) | ||
Line 253: | Line 288: | ||
target_link_libraries(furo ${catkin_LIBRARIES}) | target_link_libraries(furo ${catkin_LIBRARIES}) | ||
</ | </ | ||
- | \\ | ||
\\ | \\ | ||
The '' | The '' | ||
Line 287: | Line 321: | ||
</ | </ | ||
</ | </ | ||
- | |||
The '' | The '' | ||
Directory: '' | Directory: '' | ||
Line 601: | Line 634: | ||
rospy.loginfo(" | rospy.loginfo(" | ||
| | ||
- | </ | + | </ |
+ | The '' | ||
+ | Directory: '' | ||
+ | <code python | finalheadmotor.py> | ||
+ | # | ||
+ | # -*- coding: utf-8 -*- | ||
+ | import rospy | ||
+ | from geometry_msgs.msg import Twist | ||
+ | from std_msgs.msg import Float32 | ||
+ | import RPi.GPIO as GPIO | ||
+ | from time import sleep | ||
+ | GPIO.setmode(GPIO.BOARD) | ||
+ | GPIO.setwarnings(False) | ||
+ | AN2 =33 | ||
+ | AN1 = 32 | ||
+ | DIG2 = 18 | ||
+ | DIG1 = 37 | ||
+ | GPIO.setup(AN2, | ||
+ | GPIO.setup(AN1, | ||
+ | GPIO.setup(DIG2, | ||
+ | GPIO.setup(DIG1, | ||
+ | sleep(1) | ||
+ | p1=GPIO.PWM(AN1, | ||
+ | p2=GPIO.PWM(AN2, | ||
+ | |||
+ | __author__= " | ||
+ | |||
+ | class callback: | ||
+ | |||
+ | def head_vel_callback(self, | ||
+ | head_roll = headCTR.data | ||
+ | |||
+ | if head_roll==1:# | ||
+ | rospy.loginfo(" | ||
+ | GPIO.output(DIG1, | ||
+ | p1.start(60) # | ||
+ | p2.start(0) | ||
+ | |||
+ | |||
+ | elif head_roll==5: | ||
+ | rospy.loginfo(" | ||
+ | GPIO.output(DIG1, | ||
+ | p1.start(60) | ||
+ | p2.start(0) | ||
+ | |||
+ | elif head_roll==3: | ||
+ | rospy.loginfo(" | ||
+ | GPIO.output(DIG2, | ||
+ | p1.start(0) | ||
+ | p2.start(60) | ||
+ | |||
+ | elif head_roll==2: | ||
+ | rospy.loginfo(" | ||
+ | GPIO.output(DIG2, | ||
+ | p1.start(0) | ||
+ | p2.start(60) | ||
+ | | ||
+ | | ||
+ | elif head_roll==4: | ||
+ | rospy.loginfo(" | ||
+ | p1.start(0) #speed 0 out of 100 | ||
+ | p2.start(0) | ||
+ | | ||
+ | |||
+ | |||
+ | def __init__(self): | ||
+ | rospy.Subscriber(" | ||
+ | |||
+ | rate = rospy.Rate(10) | ||
+ | while not rospy.is_shutdown(): | ||
+ | rate.sleep() | ||
+ | | ||
+ | print(1) | ||
+ | |||
+ | if __name__ == ' | ||
+ | rospy.init_node(' | ||
+ | try: | ||
+ | wow = callback() | ||
+ | except rospy.ROSInitException: | ||
+ | pass | ||
+ | </ | ||
avatar_furo_source_codes.1656318655.txt.gz · Last modified: 2022/06/27 01:30 by glee