树莓派AI视觉小车--4.小车基本运动

调用上一章节所提到的小车基本运动代码库ROBOTCAR.pyhttps://blog.csdn.net/weixin_44845743/article/details/143571579?spm=1001.2014.3001.5502 开始小车的基本运动:

1. 小车前进

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.t_up(50,3)      # 机器人前进
            clbrobot.t_stop(1) # 机器人停止         
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

2. 小车后退

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.t_down(50,3)    # 机器人后退
            clbrobot.t_stop(1) # 机器人停止
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

3. 小车左转

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True: 
            clbrobot.turnLeft(50,3)  # 机器人左转
            clbrobot.t_stop(1) # 机器人停止           
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

4. 小车右转

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.turnRight(50,3) # 机器人右转
            clbrobot.t_stop(1) # 机器人停止          
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

5. 小车左移

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.moveLeft(50,3)  # 机器人左移
            clbrobot.t_stop(1) # 机器人停止         
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

6. 小车右移

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.moveRight(50,3) # 机器人右移
            clbrobot.t_stop(1) # 机器人停止       
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

7. 小车前左斜

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.forward_Left(50,3) # 机器人前左斜
            clbrobot.t_stop(1) # 机器人停止    
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

8. 小车后右斜

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.backward_Right(50,3) # 机器人后右斜
            clbrobot.t_stop(1) # 机器人停止          
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

9. 小车前右斜

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.forward_Right(50,3)  # 机器人前右斜
            clbrobot.t_stop(1) # 机器人停止          
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()

10. 小车后左斜

python 复制代码
from LOBOROBOT import LOBOROBOT  # 载入机器人库
import  RPi.GPIO as GPIO
import os

if __name__ == "__main__":
    clbrobot = LOBOROBOT() # 实例化机器人对象
    try:
        while True:
            clbrobot.backward_Left(50,3)  # 机器人后左斜
            clbrobot.t_stop(5)       # 机器人停止            
    except KeyboardInterrupt:
        clbrobot.t_stop(0) # 机器人停止
        GPIO.cleanup()
相关推荐
人工智能培训6 分钟前
具身智能视觉、触觉、力觉、听觉等信息如何实时对齐与融合?
人工智能·深度学习·大模型·transformer·企业数字化转型·具身智能
wenzhangli77 分钟前
能力中心 (Agent SkillCenter):开启AI技能管理新时代
人工智能
后端小肥肠41 分钟前
别再盲目抽卡了!Seedance 2.0 成本太高?教你用 Claude Code 100% 出片
人工智能·aigc·agent
每日新鲜事1 小时前
热销复盘:招商林屿缦岛203套售罄背后的客户逻辑分析
大数据·人工智能
Coder_Boy_1 小时前
基于SpringAI的在线考试系统-考试系统开发流程案例
java·数据库·人工智能·spring boot·后端
挖坑的张师傅1 小时前
对 AI Native 架构的一些思考
人工智能
LinQingYanga2 小时前
极客时间多模态大模型训练营毕业总结(2026年2月8日)
人工智能
pccai-vip2 小时前
过去24小时AI创业趋势分析
人工智能
SEO_juper2 小时前
AI SEO实战:整合传统技术与AI生成搜索的优化框架
人工智能·chatgpt·facebook·seo·geo·aeo
pp起床2 小时前
Gen_AI 补充内容 Logit Lens 和 Patchscopes
人工智能·深度学习·机器学习