ROS笔记七(基于Python、Kinetic):通信机制——动作(action)

新手避坑指南:在Ubuntu 16.04和树莓派上搭建ROS Kinetic通信环境(含ROS安装与网络配置) 本文详细介绍了在Ubuntu 16.04和树莓派上搭建ROS Kinetic通信环境的完整流程,包括系统镜像选择、rosdep初始化失败解决方案、网络配置与防火墙优化等关键步骤。特别针对多机通信中的常见问题提供了实战验证的解决方法,帮助开发者快速构建稳定的机器人通信环境,并包含语音控制机器人的实战案例。 阅读详情

前言: 

动作使用话题实现,其本质上相当于一个规定了一系列话题(目标、结果、反馈等)的组合使用方法的高层协议。相较于服务的同步通信机制,动作机制则是异步的。动作适用于大部分请求/响应式交互场景,尤其是执行过程不能立即完成。

catkin_ws工作空间下my_code程序包里的文件目录结构:

1.定义一个动作服务器:

#! /usr/bin/env python
import rospy
import time
import actionlib
from my_code.msg import TimerAction, TimerGoal, TimerResult, TimerFeedback

def do_timer(goal):
    start_time = time.time()
    #统计反馈信息的次数
    update_count = 0
    #请求时长大于60s,终止当前目标
    if goal.time_to_wait.to_sec() > 60.0:
        result = TimerResult() #TimerResult变量声明
        result.time_elapsed = rospy.Duration.from_sec(time.time() - start_time) #time_elapsed属性赋值
        result.updates_sent = update_count #updates_sent属性赋值
        server.set_aborted(result, "Timer aborted due to too-long wait") #向客户端发送终止结果
        return

    while (time.time() - start_time) < goal.time_to_wait.to_sec():
        #判断是否发生终端
        if server.is_preempt_requested():
            result = TimerResult()
            #time_elapsed需从秒转换为ROS的Duration类型
            result.time_elapsed = rospy.Duration.from_sec(time.time() - start_time)
            result.updates_sent = update_count
            server.set_preempted(result, "Timer preempted")
            return
        #反馈信息给客户端
        feedback = TimerFeedback() #TimerFeedback变量声明
        feedback.time_elapsed = rospy.Duration.from_sec(time.time() - start_time) 
        feedback.time_remaining = goal.time_to_wait - feedback.time_elapsed #time_remaining属性赋值
        server.publish_feedback(feedback) #向客户端发送反馈信息
        update_count += 1

        time.sleep(1.0)
 
    result = TimerResult()
    result.time_elapsed = rospy.Duration.from_sec(time.time() - start_time)
    result.updates_sent = update_count
    server.set_succeeded(result, "Timer completed successfully")

rospy.init_node('timer_action_server') #节点初始化
#创建动作服务器(名称、动作类型、回调函数、False:关闭动作服务器的自动启动)
server = actionlib.SimpleActionServer('timer', TimerAction, do_timer, False) 
server.start()
rospy.spin()

这里使用自定义服务类型Timer.action

2.定义一个动作客户端:

#! /usr/bin/env python
import rospy
import time
import actionlib
from my_code.msg import TimerAction, TimerGoal, TimerResult, TimerFeedback

#定义一个回调函数,收到反馈时执行
def feedback_cb(feedback):
    print('[Feedback] Time elapsed: %f'%(feedback.time_elapsed.to_sec()))
    print('[Feedback] Time remaining: %f'%(feedback.time_remaining.to_sec()))

rospy.init_node('timer_action_client') #节点初始化
client = actionlib.SimpleActionClient('timer', TimerAction) #创建一个动作客户端(名称、动作类型)
client.wait_for_server() #等待服务器启动

goal = TimerGoal() #TimeGoal变量声明
goal.time_to_wait = rospy.Duration.from_sec(5.0) #time_to_wait属性赋值

#用于测试服务端的等待时常大于60s的终止请求
#goal.time_to_wait = rospy.Duration.from_sec(500.0)

#将回调函数作为feedback_cb关键词的参数,传入send_goal
client.send_goal(goal, feedback_cb=feedback_cb)

#用于测试服务端中断
#time.sleep(3.0)
#client.cancel_goal()


client.wait_for_result() 
print('[Result] State: %d'%(client.get_state()))
print('[Result] Status: %s'%(client.get_goal_status_text()))
print('[Result] Time elapsed: %f'%(client.get_result().time_elapsed.to_sec()))
print('[Result] Updates sent: %d'%(client.get_result().updates_sent))

3.运行服务端节点:

增加fancy_action_server.py可执行权限:

chmod +x fancy_action_server.py

 运行ros:

roscore

新开一个终端,启动服务器节点:(my_code为ROS程序包名)

rosrun my_code fancy_action_server.py

4.运行客户端节点:

再打开另一个终端,增加service_client.py可执行权限:

chmod +x fancy_action_client.py

启动客户端节点:

rosrun my_code fancy_action_client.py

5.运行效果:

取消终止注释:

goal.time_to_wait = rospy.Duration.from_sec(500.0)

取消中断注释:

time.sleep(3.0)
client.cancel_goal()

ROS Kinetic + Ubuntu 16.04 入门配置全指南:稳定基座构建与catkin工作流 ROS(Robot Operating System)是一套面向机器人系统的元操作系统,其核心在于节点通信、消息传递与分布式软件架构。理解ROS环境配置的本质,就是掌握catkin构建系统、ROS_PACKAGE_PATH路径机制与roscore运行时基座的协同原理。该配置过程直接决定后续传感器驱动集成、SLAM建图、导航控制等高阶功能的稳定性与可调试性。Ubuntu 16.04与ROS Kinetic的组合,因ABI兼容性完备、文档覆盖全面、社区案例丰富,成为软硬协同开发中最可靠的学习基线。本文聚焦从系统 阅读详情

相关推荐

ROS Kinetic入门教程:Ubuntu 16.04下安装配置与工程实践

ROS(Robot Operating System)是机器人系统开发的核心中间件框架,其核心原理基于分布式节点通信、话题/服务/动作机制及TF坐标变换体系。技术价值在于屏蔽硬件异构性、提供标准化工具链(如rviz、rosbag、roslaunch)并支撑实时控制与多传感器融合。典型应用场景涵盖高校机器人课程实验、工业AGV底盘调试、教学机械臂开发及国产激光雷达(如思岚A1)驱动集成。由于大量教材、实验平台与国产硬件SDK仍深度绑定ROS Kinetic版本,且其运行依赖Ubuntu 16.04 LTS的稳

liudaoru - 悟 796

ROS python教程-actionlib-编写简单的action客户端及服务器

适用环境 ROS中的服务service是一问一答的形式,你来查询了,我就返给你要的信息。 action也有服务的概念,但是它不一样的地方是:不是一问一答,而多了一个反馈,它会不断反馈项目进度。如navigation下的move_base package,你设定了目标点,反馈信息可能是机器人在规划路径上的即时位姿,直到机器人到达目标点,返回SUCCEEDED消息。 所以action lib适用于...

David's Tweet 4527

适合初学者的ROS机器人教程(3): ROS下使用Python对UR5机器人建模与控制

安装UR机器人ROS包 $ sudo apt-get install ros-kinetic-universal-robot 查询下看看有哪些包是和UR机器相关 $ sudo rospack list | grep urur5_moveit_config /opt/ros/kinetic/share/ur5_moveit_config moveit!配置功能包 ur_description /o...

@司南牧|知乎|博客|易懂教程|李韬 5743

C++ SimpleActionClient::waitForResult方法代码示例

C++ SimpleActionClient::waitForResult方法代码示例

AI_future的博客 573

ROS Kinetic小乌龟仿真器入门:从键盘控制到话题发布的完整实战指南

本文提供ROS Kinetic小乌龟仿真器的完整实战指南,从基础环境搭建、核心概念讲解开始,详细演示了通过键盘控制小乌龟移动的经典方法,并深入剖析了节点、话题与消息的通信原理。进一步,教程指导读者使用命令行直接发布话题来控制小乌龟,并结合系统观测工具和脚本编写,帮助读者从实践层面深入理解ROS的分布式通信架构。

weixin_29176179的博客 225

kinetic_sample_packages:适用于C ++和Python的示例ROS Kinetic节点的集合

etic_sample_packages 适用于C ++和Python的示例ROS Kinetic节点的集合 先决条件 在能够编译此软件包之前,您需要确保已安装所有软件依赖项。 建议您提取要使用的特定示例,而不要尝试一次编译所有内容。 假定您至少已安装ros-kinetic-desktop软件包。 spinner_py / spinner_cpp / atime_sync / custom_msg_srv 无需额外的依赖! image_sub_py / image_processing / resolve_pnp_py sudo apt install ros-kinetic-vision-opencv ros-kinetic-cv-bridge ros-kinetic-image-transport ros-kinetic-cv-camera mavros_guider sudo

vscode开发ROS(16)-python实现自定义动作action

python实现自定义动作action写在最前自定义动作新建Server节点新建Client节点运行Server和Client后记 写在最前 此篇博客为vscode开发系列ros第9篇vscode开发ROS(9)-ROS服务通信机制(srv)的python实现版本, 请对照进行查看. 自定义动作 此处是直接采用第11篇中的, 自定义heatWater.action服务, 具体过程, 请查看该篇,...

MSNH2012的博客 817

【CADARXC++】ObjectArx2023 C++ CAD二次开发环境配置笔记

从官网或第三方平台下载以下AUtoCAD2023、VisualStudio2019和ObjectArx2023安装时请注意安装顺序。

BIMCATIA的博客 1789

python机器人开发教程_ROS与Python入门教程-actionlib-开发简单的action服务端

ROS与Python入门教程-actionlib-开发简单的action服务端说明使用simple_action_server库创建Python的Fibonacci(斐波那契数列)action服务端计算Fibonacci数列的顺序,得到计算后的数列介绍actionlib_tutorials/simple_action_servers/fibonacci_server.py代码#! /usr/bin...

weixin_39873741的博客 509

SAP OBYC自动过账全解析:从BSX到WRX的会计科目配置指南

本文深入解析SAP OBYC自动过账功能,从BSX到WRX的会计科目配置全流程,涵盖评估分组代码、事务码和评估类等核心概念。通过实战案例展示如何实现库存变动到财务过账的自动化流转,提升企业财务数据的准确性和效率。

weixin_29239279的博客 420

基于python获取网易云热门歌单及封面

先看一下图片背后的代码 非常好,里面歌单名字,id,以及封面图片都有了.在复制url的时候注意把/#删掉,要不然爬不了. import requests from lxml import etree url='https://music.163.com/discover/playlist' head={ 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Ch

ziyuan12345678的博客 538

ROS_Python编程 之 案例代码核心解析(第三版)

ROS_Python编程 之 案例代码核心解析(第三版) 时隔有一段时间咯,忙着学习课内知识还有ros重要框架、接口,代码方面稍有懈怠,请大家见谅哈。通过Handsfree mini机器人平台配套的中级教程,我对ros_python 自主巡逻案例 的知识做以下归纳: 文章目录ROS_Python编程 之 案例代码核心解析(第三版)4. 自主巡逻案例 4. 自主巡逻案例 handsfree mini 机器人工控机自带的ros系统有一份代码,是 multi_point_patrol.py,代码如下: #!/us

MuscleMonk的博客 901

BEVFusion实战:从零搭建LiDAR-Camera融合的3D目标检测环境(附避坑指南)

本文提供了BEVFusion实战指南,详细讲解如何从零搭建LiDAR-Camera融合的3D目标检测环境。内容涵盖环境配置、数据预处理、模型训练与性能优化等关键步骤,并附有实用的避坑技巧,帮助开发者高效部署这一先进的BEV感知算法。

p4q5r6s7t的博客 515

ROS笔记二(基于Python、Kinetic):通信机制——话题(topic)

前言: 话题实现了一种发布/订阅的通信机制,这是一种在分布式系统中常见的数据交换方式。节点在发送数据到话题上之前,必须先声明话题名和发送到该话题的消息所具有的类型。 1.声明一个话题 ...

java0fu的博客 714

【强化学习】11 —— Double DQN算法与Dueling DQN算法

可以看到由于数据点的分布,使得拟合出的价值函数无法与真实的价值函数吻合,甚至在部分区域产生了明显的偏差。Dueling DQN 是 DQN 另一种的改进算法,它在传统 DQN 的基础上只进行了微小的改动,但却能大幅提升 DQN 的表现。这样,即使其中一套神经网络的某个动作存在比较严重的过高估计问题,由于另一套神经网络的存在,这个动作最终使用的值不会存在很大的过高估计问题。.在同一个状态下,所有动作的优势值之和为 0,因为所有动作的动作价值的期望就是这个状态的状态价值。环境的状态包括倒立摆角度的正弦值。

sinat_52032317的博客 1万+

ZYNQ AXI DMA零拷贝实战:用mmap在用户空间玩转高速数据流(基于Petalinux 2020.2)

本文详细介绍了在ZYNQ平台上使用AXI DMA和mmap技术实现零拷贝数据传输的实战方法。基于Petalinux 2020.2环境,通过内核配置、设备树修改和用户空间库设计,大幅提升PS与PL之间的数据传输效率,特别适用于高清视频流、高速AD采样等高性能场景。

weixin_27956639的博客 365

ROS笔记五(基于Python、Kinetic):通信机制——服务(server)

前言: 服务是另一种在节点之间传递数据的方式。服务其实就是同步的跨进程函数调用,让一个节点调用运行在另一个节点中的函数。服务适用于偶尔并且在有限时间里完成的通信情况。 1.定义一个服务端: q ...

java0fu的博客 802

MIT 18.03 微分方程 ODE 学习笔记分享——目录

从B站上看到了MIT 微分方程的课程,觉得老爷子讲的真好! 其实微分方程对于工科来说相当重要,但是很多学习也仅把他放在高数里作为单独的一个章节来讲,这是远远不够的。所以对于同学们来说 ,一定要认真听讲,做好笔记! 以下是我的个人学习比较分享。有需要的同学可以做一个参考。 注:个人认为笔记的作用是用来回想起课堂所讲的内容(细节),所以我的笔记风格为以老师讲课思路为准,板书为辅。建议刚开始听这门课的同...

weixin_40664094的博客 2630

TurtleBot2+ROS Kinetic硬件驱动配置实战指南

ROS(Robot Operating System)作为机器人开发的事实标准,其核心价值在于统一硬件抽象与中间件通信。理解ROS驱动原理,关键在于掌握设备节点映射、内核模块兼容性及实时性调度机制。在真实嵌入式机器人平台如TurtleBot2上,ROS Kinetic并非单纯软件版本选择,而是与Kobuki底盘固件、CP2102串口芯片、Ubuntu 16.04内核深度耦合的技术栈。该组合保障了USB通信时序稳定性、`/dev/kobuki`设备持久化及`/odom`里程计时间戳精度,是实车SLAM、导航与

weixin_33672400的博客 389

【漏洞复现】WordPress Plugin NotificationX 存在sql注入CVE-2024-1698

技术文章仅供参考,任何个人和组织使用网络应当遵守宪法法律,遵守公共秩序,尊重社会公德,不得利用网络从事危害国家安全、荣誉和利益,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。WordPress和WordPress plugin都是WordPress基金会的产品。WordPress Plugin NotificationX 存在安全漏洞,该漏洞源于对用户提供的参数转义不充分以及对现有 SQL 查询缺乏充分的准备,很容易通过“type”参数受到 SQL 注入攻击。

失心少年 1384

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

安装并启动ROS-kinetic

本博文ROS镜像源的地址设置以及密钥均引用自胡春旭老师的《ROS机器人开发与实践》一书 1.更换软件源 首先要更换软件源,因为原来默认的中国服务器的在学校里的下载速度实在太感人(当时还真傻乎乎地等了半天TAT)。但是家里连中国服务器下载又很快,总之那个快选哪个。 点击左侧倒数第二个图标进入系统设置,然后点击软件与更新,设置如图所示。 跳出更新可用软件列表信息过时的窗口直接关掉就好了(因为后续操作也会更新这些软件列表)。 2. 设置软件源并添加密钥 在终端中输入 sudo sh -c '. /etc/lsb-

qq_42256241的博客 776

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

vibe-vibe 实战:AI 辅助编码的 70/30 分工——把人类判断力用在真正重要的 30%

> 本篇技术指南源自 vibe-vibe 仓库收录的工程实践文章《Beyond the 70%: Maximizing the Human 30% of AI-Assisted Coding》,并结合仓库内的 PRD 模板、源码 Demo、测试与安全清单等真实素材展开。它回答一个核心问题:当 AI 能稳定完成约 70% 的常规编码任务时,人类剩余的 30% 精力应该投在哪里?读完本文,你将能分清"

gitblog_00751的博客 484

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Roboware Studio从零到一:ROS Kinetic环境下的安装与基础开发指南

本文提供了一份详细的Roboware Studio安装教程,指导读者在ROS Kinetic环境下从零开始配置这一ROS专用IDE。内容涵盖环境准备、依赖安装、工作区创建、功能包开发及消息通信实战,旨在帮助ROS新手快速搭建开发环境并掌握基础开发流程。

lemon的博客 619

避坑指南:在Ubuntu 16.04上搞定CoppeliaSim V4.1.0与ROS Kinetic的通信(附Python版本冲突解决方案)

本文详细介绍了在Ubuntu 16.04系统下实现CoppeliaSim V4.1.0与ROS Kinetic通信的避坑指南,重点解决Python版本冲突等常见问题。通过环境配置、接口编译、功能验证等步骤,提供实战验证的解决方案,帮助开发者高效完成机器人仿真与ROS的深度集成。

weixin_30333885的博客 631

vscode开发ROS(20)-ros与arduino串口通信(python)

ros与arduino串口通信python写在最前安装pyserial 写在最前 这篇文章是上一篇中, arduino与ros进行串口通信的python实现版本. 可以对照查看, vscode开发ROS(19)-ros与arduino串口通信(c++). 安装pyserial python中比较常用的串口通信的工具就是pyserial. 安装方法也比较简单: sudo pip install p...

MSNH2012的博客 1458

【ROS话题通信笔记】

记录一下ROS学习中的话题通信,我用的Ubuntu是16.04对应的ROS版本是kinetic

qq_1840998080的博客 544
上一篇: ROS笔记六(基于Python、Kinetic):自定义动作类型
下一篇: ROS笔记八(基于Python、Kinetic):gazebo初探——实现turtlebot移动并避开障碍
进击的香皂
博客等级 码龄8年 34粉丝 20原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值