首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏CreateAMind

    ROS探索总结(十二)——坐标系统

    /usr/bin/env python import roslib roslib.load_manifest('learning_tf') import rospy import ') turtle_vel = rospy.Publisher('turtle2/command_velocity', turtlesim.msg.Velocity) rate = rospy.Rate(10.0) while not rospy.is_shutdown(): try: (trans,rot) = listener.lookupTransform () rate = rospy.Rate(10.0) while not rospy.is_shutdown(): br.sendTransform((0.0, 2.0 () rate = rospy.Rate(10.0) while not rospy.is_shutdown(): t = rospy.Time.now().to_sec

    1.6K10发布于 2018-07-24
  • 来自专栏机器人课程与技术

    蓝桥ROS之f1tenth简单PID沿墙跑起来(Python)

    ("WallFollow_node", anonymous=True) wf = WallFollow() rospy.sleep(0.1) rospy.spin() if _ = rospy.Subscriber("/scan", LaserScan, callback) rospy.spin() dist.py  import rospy import math from ('dist_finder',anonymous = True) rospy.Subscriber("scan",LaserScan,callback) rospy.spin() control.py rospy.init_node('pid_controller', anonymous=True) rospy.Subscriber("error", pid_input, control) rospy.spin rospy.init_node('pid_controller', anonymous=True) rospy.Subscriber("error", pid_input, control) rospy.spin

    61320编辑于 2022-05-10
  • 来自专栏杨丝儿的小站

    【机器人】ROS1工程案例:基础部分

    catkin_create_pkg communicate_bot rospy ✨开始编程 包内src路径下放置我们的代码。 /usr/bin/env python3 import rospy from std_msgs.msg import Int32 class Publisher(): count = 0 def Publisher(): pass def publish(self): rospy.init_node('topic_publisher') # 初始化节点 pub = rospy.Publisher('counter', Int32, queue_size=10) rate = rospy.Rate(2) ,如何处理数据 sub = rospy.Subscriber('counter', Int32, lambda msg : print(msg.data)) rospy.spin

    43630编辑于 2022-02-28
  • 来自专栏机器人课程与技术

    ROS1云课→31欢乐卷假期

    rospy.wait_for_message('initialpose', PoseWithCovarianceStamped) self.last_location = Pose() (1) rospy.loginfo("Starting navigation test") # Begin the main loop and run through a sequence of locations while not rospy.is_shutdown(): # If n_successes += 1 distance_traveled += distance rospy.loginfo( () except rospy.ROSInterruptException: rospy.loginfo("AMCL navigation test finished.") --

    1.4K20编辑于 2022-10-04
  • 来自专栏机器人课程与技术

    ROS暑期学校分享-2023

    (): pub = rospy.Publisher('chatter', String, queue_size=10) rospy.init_node('talker', anonymous =True) rate = rospy.Rate(10) # 10hz while not rospy.is_shutdown(): hello_str = "hello world %s" % rospy.get_time() rospy.loginfo(hello_str) pub.publish(hello_str) rate = rospy.Rate(10):创建一个速率对象rate,以10Hz的频率发布消息。 while not rospy.is_shutdown()::进入一个无限循环,直到ROS节点关闭。 相应的,代码中的rospy.loginfo()也记录了这个浮点数。

    54620编辑于 2023-08-02
  • 来自专栏小黑鸭的学习记录

    ROS学习记录②:Topic通讯和代码练习

    roscpp rosmsg 使用Clion打开目录 hello_topic ,在 scripts 目录下新建Python文件 publisher_node 创建节点 rospy.init_node(' 此时应在开头添加 from std_msgs.msg import String 定时发布消息 rate = rospy.Rate(4) count = 0 while not rospy.is_shutdown (topic_name, String, queue_size=100) count = 0 rate = rospy.Rate(4) while not rospy.is_shutdown rospy.Subscriber(topic_name, String, topic_callback) rospy.spin() 实现订阅回调 def topic_callback(msg): (motor_topic_name, Int32, motor_callback) rospy.spin() 5.5.3 编码器功能实现 完整代码如下: #!

    2.3K10发布于 2020-11-24
  • 来自专栏机器人课程与技术

    蓝桥ROS机器人之turtlesim贪吃蛇移植到Win11中

    一些群聊及主动学习或者交流,多有如下情况: ---- import rospy from tanksim.msg import Pose from tanksim.srv import Spawn , self.tank_poseCallback) self.pub = rospy.Publisher(self.tank_name + '/cmd_vel', Twist, ("/" + tname + '/set_pen') try: client = rospy.ServiceProxy("/" + tname + '/set_pen', SetPen) client(0,0,0,0,1) except rospy.ServiceException as e ('snake_tank', anonymous=True) rospy.Subscriber('/tank1/pose', Pose, tank1_poseCallback) rospy.wait_for_service

    34830编辑于 2022-05-01
  • 来自专栏机器人课程与技术

    贪吃蛇复现-CoCube

    贪吃蛇复现-CoCube python代码如下: import rospy from turtlesim.msg import Pose from turtlesim.srv import Spawn ("turtle Created [%s] [%f] [%f]", name, x, y) rospy.Subscriber(self.turtle_name + '/pose' , Pose, self.turtle_poseCallback) self.pub = rospy.Publisher(self.turtle_name + '/cmd_vel ("/" + tname + '/set_pen') try: client = rospy.ServiceProxy("/" + tname + rospy.wait_for_service("/turtle1/set_pen") try: client = rospy.ServiceProxy('/turtle1/set_pen

    57020编辑于 2022-12-11
  • 来自专栏机器人课程与技术

    蓝桥ROS机器人之turtlesim贪吃蛇

    只有运行结果和之前的提示: 从turtlesim到贪吃蛇……(补充) 解压缩: 创建工作区并编译后执行: roslaunch tank_snake_game start.launch import rospy , self.tank_poseCallback) self.pub = rospy.Publisher(self.tank_name + '/cmd_vel', Twist, ("/" + tname + '/set_pen') try: client = rospy.ServiceProxy("/" + tname + '/set_pen', SetPen) client(0,0,0,0,1) except rospy.ServiceException as e ('snake_tank', anonymous=True) rospy.Subscriber('/tank1/pose', Pose, tank1_poseCallback) rospy.wait_for_service

    45410编辑于 2022-04-28
  • 来自专栏机器人课程与技术

    从turtlesim到贪吃蛇……

    ---- 部分提示如下:  import rospy from tanksim.msg import Pose from tanksim.srv import Spawn from tanksim.srv , self.tank_poseCallback) self.pub = rospy.Publisher(self.tank_name + '/cmd_vel', Twist, ("/" + tname + '/set_pen') try: client = rospy.ServiceProxy("/" + tname + '/set_pen', SetPen) client(0,0,0,0,1) except rospy.ServiceException as e ('snake_tank', anonymous=True) rospy.Subscriber('/tank1/pose', Pose, tank1_poseCallback) rospy.wait_for_service

    41820编辑于 2022-05-01
  • 来自专栏机器人课程与技术

    美美的圣诞树画出来-CoCube

    ('sketcher', anonymous=False) # Publisher self.pub = rospy.Publisher('/turtle1/cmd_vel ) # Rate to control frequency of operation of node self.rate = rospy.Rate(1) # 10hz ("Press Ctrl+C to terminate the program") rospy.spin() else: ("Image Loaded") rospy.loginfo("Select minimum and maximum threshold") def find_contours ('/reset', Empty) reset_serv() except rospy.ServiceException as e: rospy.loginfo(

    72730编辑于 2023-01-01
  • 来自专栏小黑鸭的学习记录

    ROS学习记录⑥:动态配置参数

    新建功能包 cd catkin_ws/src catkin_create_pkg pid roscpp rospy rosmsg std_msgs dynamic_reconfigure 2. class UpdatePID(): def __init__(self): rospy.init_node("update_pid") rospy.on_shutdown (self.shutdown) # 执行频率 rate = rospy.Rate(20) # 声明一个消息发布者, 将消息发布到 driver self.publisher_pid = rospy.Publisher("/pid", Float32MultiArray, queue_size=100) ") # 让ros节点跑起来 while not rospy.is_shutdown(): rate.sleep()

    1.4K10发布于 2020-11-24
  • 来自专栏SAP Technical

    python逐行读取txt文件里的数据并且赋值给变量

    /usr/bin/env python import roslib #roslib.load_manifest('learning_tf') import rospy import math import test_pose.pose.orientation.z = float(pose[5]) test_pose.pose.orientation.w = float(pose[6]) rate = rospy.Rate (1) rospy.loginfo(test_pose) pose_pub.publish(test_pose) rate.sleep () f.close() if __name__ == '__main__': rospy.init_node('read_txt_pose ', anonymous=True) pose_pub = rospy.Publisher('txt_pose', PoseStamped, queue_size=10) txt_read

    1.2K30编辑于 2023-10-13
  • 来自专栏小黑鸭的学习记录

    ROS学习记录①:安装、起步和IDE工具

    2.3 Package创建 在workspace的src目录下 catkin_create_pkg hello_ros rospy roscpp rosmsg catkin_create_pkg是创建 第一个参数hello_ros是指创建的package名称,后面的参数roscpp,rospy,rosmsg是指当前创建的这个package需要提供哪些环境依赖。 34 PM # @Author : Chenan_Wang # @File : hello_node.py # @Software: CLion # ROS 的 Python 环境 import rospy if __name__ == '__main__': # ros的节点,需要传入节点的名称 -- 在rosmaster中注册 rospy.init_node('itcast_node # (hz赫兹) 10 --1秒执行10次 rate = rospy.Rate(1) while not rospy.is_shutdown(): print 'hello

    1.6K20发布于 2020-11-24
  • 来自专栏小黑鸭的学习记录

    ROS学习记录③:Service通讯和代码练习

    安装 pyserial pip install pyserial 工作空间下创建功能包 cd ros_ws/first_ws/src catkin_create_pkg hello_service rospy roscpp rosmsg 使用Clion打开目录 hello_service ,在 scripts 目录下新建Python文件 server_node 6.1.1 创建节点 rospy.init_node from rospy_tutorials.srv import AddTwoInts, AddTwoIntsRequest, AddTwoIntsResponse def callback(request ('client_node') 6.3.2 调用Service # 确保servers是存在的,等待服务开启,阻塞代码 rospy.wait_for_service(service_name) # 创建服务 from rospy_tutorials.srv import AddTwoInts, AddTwoIntsRequest, AddTwoIntsResponse if __name__ == '_

    1K10发布于 2020-11-24
  • 来自专栏杨丝儿的小站

    【机器人】ROS1工程案例:服务和动作

    -- uint32 num_out 取消package.xml中的注释 添加信息到CMakeLists.txt find_package(catkin REQUIRED COMPONENTS rospy (): def __init__(self): rospy.init_node('service_client_factorial') rospy.wait_for_service ('service/server/factorial/service') self.factorise = rospy.ServiceProxy('service/server/factorial class FactorialServiceServer(): def __init__(self): rospy.init_node('service_server_factorial # 新增 ) catkin_package( # INCLUDE_DIRS include # LIBRARIES factorial_calculator # CATKIN_DEPENDS rospy

    41620编辑于 2022-02-28
  • 来自专栏防止网络攻击

    ROS 编程入门的介绍

    在终端中运行以下命令: catkin_create_pkg de_ws my_robot rospy roscpp 此命令创建一个名为 my_robot 的功能包,并声明了对 std_msgs、rospy /usr/bin/env python import rospy from std_msgs.msg import String def talker(): pub = rospy.Publisher ('chatter', String, queue_size=10) rospy.init_node('talker', anonymous=True) rate = rospy.Rate (10) # 10hz while not rospy.is_shutdown(): hello_str = "hello world %s" % rospy.get_time =True) rospy.Subscriber('chatter', String, callback) rospy.spin() if __name__ == '__main__':

    74510编辑于 2024-09-18
  • 来自专栏机器人课程与技术

    蓝桥ROS之半自动贪吃龟turtlesim版

    courses/854 ---- 第二步:双击xfce终端,分别在不同窗口开启roscore和turtlesim ---- 第三步:贪吃龟(蓝桥ROS机器人之turtlesim贪吃蛇)  import rospy , self.tank_poseCallback) self.pub = rospy.Publisher(self.tank_name + '/cmd_vel', Twist, ("/" + tname + '/set_pen') try: client = rospy.ServiceProxy("/" + tname + '/set_pen', SetPen) client(0,0,0,0,1) except rospy.ServiceException as e ('snake_tank', anonymous=True) rospy.Subscriber('/tank1/pose', Pose, tank1_poseCallback) rospy.wait_for_service

    46220编辑于 2022-05-10
  • 来自专栏机器人课程与技术

    借助媛如意让ROS机器人turtlesim画出美丽的曲线-云课版本

    (): # 初始化ROS节点 rospy.init_node('draw_circle', anonymous=True) # 创建一个发布者,发布Twist消息到/cmd_vel 话题 pub = rospy.Publisher('/turtle1/cmd_vel', Twist, queue_size=10) # 设置循环频率 rate = rospy.Rate ().to_sec() while not rospy.is_shutdown(): # 发布Twist消息 pub.publish(vel) # (): # rospy.init_node('draw_circle', anonymous=True) # pub = rospy.Publisher('/turtle1 /cmd_vel', Twist, queue_size=10) # rate = rospy.Rate(10) # vel = Twist() #

    1.1K20编辑于 2023-03-08
  • 来自专栏机器人课程与技术

    ROS1云课→18一键配置

    creating: src/ros_tutorials/rospy_tutorials/test/ inflating: src/ros_tutorials/rospy_tutorials /rospy_tutorials/test/test_peer_subscribe_notify.py inflating: src/ros_tutorials/rospy_tutorials/ /rospy_tutorials/test/test-peer-subscribe-notify.launch inflating: src/ros_tutorials/rospy_tutorials src/ros_tutorials/rospy_tutorials/CHANGELOG.rst creating: src/ros_tutorials/rospy_tutorials/002 /rospy_tutorials/msg/HeaderString.msg extracting: src/ros_tutorials/rospy_tutorials/msg/Floats.msg

    1.1K10编辑于 2022-09-28
领券