ios pusher使用

by Rahat Khanna

通过拉哈特·汉娜

如何使用JavaScript和Pusher实时更新用户状态 (How to update a User’s Status in realtime using JavaScript and Pusher)

“Hey, what’s up?” is not a phrase we need to ask someone these days. These days knowing what someone is up to has become so easy, because we keep seeing updated statuses for all our friends on WhatsApp, Snapchat, Facebook and so on.

“嘿,怎么了?” 这几天我们不是要问别人这个词。 如今,知道某人的举动变得如此容易,因为我们不断在WhatsApp,Snapchat,Facebook等上看到所有朋友的最新状态。

In this article, we will learn how we can update a user’s status in a realtime component along with a list of all members who are online.

在本文中,我们将学习如何在实时组件中更新用户状态以及所有在线成员的列表。

We will be using Node.js as the application server, Vanilla JavaScript in the front-end, and Pusher for realtime communication between our server and front-end.

我们将使用Node.js作为应用程序服务器,前端使用Vanilla JavaScript,并使用Pusher进行服务器与前端之间的实时通信。

We will build an app, which will be like your friends list or a common chat room, where you can see who’s online and what’s their latest status update in realtime. We will learn about Pusher’s presence channel and how to know about the online members on this channel.

我们将构建一个应用程序,就像您的朋友列表或公共聊天室一样,您可以在其中实时查看谁在线以及他们的最新状态。 我们将了解Pusher的状态频道以及如何了解该频道的在线成员。

We will be building the following components during this blog post:

在此博客文章中,我们将构建以下组件:

Node.js Server using Express.js Framework:

使用Express.js框架的Node.js服务器:

  • /register API — In order to register/login a new user to our channel and server by creating their session and saving their info

    / register API-为了通过创建他们的会话并保存他们的信息来将新用户注册/登录到我们的频道和服务器

  • /isLoggedIn API — To check if a user is already logged in or not in case of refreshing the browser

    / isLoggedIn API-在刷新浏览器的情况下检查用户是否已经登录

  • /usersystem/auth API — Auth validation done by Pusher after registering it with our app and on subscribing to a presence or private channel

    / usersystem / auth API-由Pusher在我们的应用程序中注册并订阅状态或私人频道后完成的身份验证

  • /logout API — To logout the user and remove the session

    / logout API-注销用户并删除会话

Front-End App using JavaScript:

使用JavaScript的前端应用程序:

  • Register/Login Form — To register/login a new user by filling in their username and initial status

    注册/登录表单—通过填写用户名和初始状态来注册/登录新用户
  • Members List — To see everyone who is online and their updated statuses

    成员列表—查看所有在线用户及其最新状态
  • Update Status — To click on the existing status and update it on blur of the status text edit control

    更新状态-单击现有状态并在状态文本编辑控件模糊时对其进行更新

Find here the link to the Github Repository for reference.

在此处找到指向 Github存储库的链接以供参考。

推杆简介 (Introduction to Pusher)

Pusher is a platform which abstracts the complexities of implementing a realtime system on our own using WebSockets or Long Polling. We can instantly add realtime features to our existing web applications using Pusher, as it supports a wide variety of software development kits (SDKs).

Pusher是一个平台,该平台抽象了使用WebSockets或Long Polling自己实现实时系统的复杂性。 我们可以使用Pusher立即将实时功能添加到我们现有的Web应用程序中,因为它支持各种软件开发工具包(SDK)。

Integration kits are available for a variety of front-end libraries like Backbone, React, Angular, and jQuery — and also back-end platforms/languages like .NET, Java, Python, Ruby, PHP, and GO.

集成工具包可用于各种前端库(例如Backbone,React,Angular和jQuery)以及后端平台/语言(如.NET,Java,Python,Ruby,PHP和GO)。

使用Pusher注册 (Signing up with Pusher)

You can create a free account in Pusher here. After you signup and login for the first time, you will be asked to create a new app as seen in the image below. You will have to fill in some information about your project, and also provide the front-end library or back-end language you will be building your app with.

您可以在推创建一个免费帐户这里 。 首次注册并登录后,将要求您创建一个新应用,如下图所示。 您将必须填写有关项目的一些信息,并提供用于构建应用程序的前端库或后端语言。

For this particular article, we will be selecting JavaScript for the front-end and Node.js for the back-end as seen in the image above.

对于这篇特定的文章,我们将为前端选择JavaScript,为后端选择Node.js,如上图所示。

This will just show you a set of starter sample codes for these selections, but you can use any integration kit later on with this app.

这只会为您显示这些选择的一组入门示例代码,但是您以后可以在此应用程序中使用任何集成套件。

Node.js服务器 (Node.js Server)

Node.js should be installed in the system as a prerequisite to this project. Now let’s begin building the Node.js server and all the required APIs using Express. Initialize a new node project by the following command:

应将Node.js作为此项目的前提条件安装在系统中。 现在,让我们开始使用Express构建Node.js服务器和所有必需的API。 通过以下命令初始化新的节点项目:

npm init

安装依赖项 (Installing Dependencies)

We will be installing the required dependencies like Express, express-session, Pusher, body-parser, cookie-parser by the following command:

我们将通过以下命令安装所需的依赖项,例如Express,express-session,Pusher,body-parser,cookie-parser:

基础服务器 (Foundation Server)

We will now create the basic foundation for the Node.js Server and also enable sessions in it using express-session module.

现在,我们将为Node.js服务器创建基础,并使用express-session模块在其中启用会话。

In the above code, we have created a basic Express server, and using the method .use we have enabled cookie-parser, body-parser, and a static file serving from public folder. We have also enabled sessions using express-session module. This will enable us to save user information in the appropriate request session for the user.

在上面的代码中,我们已经创建了一个基本的Express服务器,以及使用该方法.use我们支持cookie的解析器,身体分析器,并从服务于静态文件public文件夹。 我们还使用express-session模块启用了会话。 这将使我们能够在适当的用户请求会话中保存用户信息。

添加推送器 (Adding Pusher)

Pusher has an open source npm module for Node.js integrations, which we will be using. It provides a set of utility methods to integrate with Pusher APIs using a unique appId, key and a secret. We will first install the Pusher npm module using the following command:

Pusher有一个用于Node.js集成的开源npm模块,我们将使用它。 它提供了一套实用的方法采用了独特的带有推进器的API集成appIdkey和一个secret 。 我们将首先使用以下命令安装Pusher npm模块:

npm install pusher --save

Now, we can use require to get the Pusher module and to create a new instance passing an options object with important keys to initialize our integration. For this article, I have chosen random keys — you will have to obtain them for your app from the Pusher dashboard.

现在,我们可以使用require获取Pusher模块并创建一个新的实例,该实例通过带有重要键的options对象来初始化我们的集成。 在本文中,我选择了随机密钥-您必须从Pusher仪表板为您的应用程序获取它们。

You will have to replace the appId, key and a secret with values specific to your own app. After this, we will write code for a new API which will be used to create a new comment.

您将必须替换appIdkey key 以及包含特定于您自己的应用程序的值的secret 。 之后,我们将为新的API编写代码,这些代码将用于创建新的注释。

注册/登录API (Register/Login API)

Now, we will develop the first API route of our application through which a new user can register/login and make themselves available on our app.

现在,我们将开发应用程序的第一个API路线,新用户可以通过该路线注册/登录并使自己在我们的应用程序中可用。

In the above code, we have exposed a POST API call on the route /register which would expect username and status parameters to be passed in the request body. We will be saving this user info in the request session.

在上面的代码中,我们公开了路由/register上的POST API调用,该调用期望usernamestatus参数在请求正文中传递。 我们将在request session保存此用户信息。

用户系统身份验证API (User System Auth API)

In order to enable any client subscribing to Pusher Private and Presence channels, we need to implement an auth API which would authenticate the user request by calling Pusher.authenticate method at the server side. Add the following code in the server in order to fulfill this condition:

为了启用任何订阅Pusher PrivatePresence通道的客户端,我们需要实现一个auth API,该API将通过在服务器端调用Pusher.authenticate方法来认证用户请求。 为了满足此条件,请在服务器中添加以下代码:

We need to provide the specific route in the initialization of the Pusher client side library, which we will see later. The Pusher client library will automatically call this route and pass in the channel_name and socket_id properties. We will simultaneously get the user information from the user session object and pass it as presenceData to the Pusher.authenticate method call.

我们需要在Pusher客户端库的初始化中提供特定的路由,稍后我们将进行介绍。 Pusher客户端库将自动调用此路由,并传入channel_namesocket_id属性。 我们将同时从用户会话对象获取用户信息,并将其作为presenceData传递给Pusher.authenticate方法调用。

IsLoggedIn和注销API (IsLoggedIn and Logout API)

If the user refreshes the browser, the client side app should detect if the user is already registered or not. We will implement an isLoggedIn API route for this. Also, we need a logout route to enable any user to logout from the app.

如果用户刷新浏览器,则客户端应用程序应检测用户是否已注册。 我们将为此实现一个isLoggedIn API路由。 另外,我们需要logout路径,以使任何用户都可以从应用程序注销。

使用Vanilla JavaScript的前端应用 (Front-End App using Vanilla JavaScript)

We will now be developing the front-end app to register a new user with an initial status and see the members who are online and their statuses. We will also build the feature for the logged-in user to update their users and all other users will see the updated status in realtime.

现在,我们将开发前端应用程序,以注册具有初始状态的新用户,并查看在线成员及其状态。 我们还将为登录用户构建功能,以更新其用户,所有其他用户将实时看到更新状态。

步骤1:创建一个名为public的文件夹并创建一个index.html文件 (Step 1: Create a folder named public and create an index.html file)

We have already written code in our server.js to serve static content from public folder, so we will write all our front-end code in this folder.

我们已经在server.js编写了用于从public文件夹提供静态内容的代码,因此我们将在此文件夹中编写所有前端代码。

Please create a new folder public and also create an empty index.html file for now.

请创建新文件夹public ,也可以创建一个空index.html现在文件。

第2步:将样板代码添加到我们的index.html (Step 2: Add Boilerplate Code to our index.html)

We will be adding some basic boilerplate code to set up the base structure for our web app like Header, and Sections where the registration form and the members list can be placed.

我们将添加一些基本的样板代码,以设置Web应用程序的基本结构,例如Header和可放置注册表单和成员列表的Sections

In the above boilerplate code, we have referenced our main JavaScript file app.js and the Pusher client side JavaScript library. We also have a script tag where we will place the template for a member row in the member list. Also, we have two empty div tags with ids me and membersList to contain the logged in member name and info, as well as the list of all other members with their status.

在上面的样板代码中,我们引用了我们的主要JavaScript文件app.js和Pusher客户端JavaScript库。 我们还有一个script标记,用于将成员行的模板放置在成员列表中。 另外,我们有两个空的div标签,其ID为memembersList用于包含已登录的成员名称和信息以及所有其他成员及其状态的列表。

步骤3:Style.css (Step 3: Style.css)

Important to note that we will be showing the signup form for the first time and the MembersList and Logout button will be hidden by default initially. Please create a new file called style.css and add the following CSS to it:

需要注意的重要一点是,我们将首次显示注册表单,默认情况下, MembersListLogout按钮将默认为隐藏。 请创建一个名为style.css的新文件,并向其中添加以下CSS:

Please try to open the URL http://localhost:9000 in your browser and the application will load with the basic register or login form with username and status. The output will look like the screenshot below:

请尝试在浏览器中打开URL http:// localhost:9000 ,该应用程序将加载基本注册名或具有用户名和状态的登录表单。 输出将类似于以下屏幕截图:

步骤4:添加app.js基本代码 (Step 4: Add app.js basic code)

Now we will add our JavaScript code to have basic utility elements inside a self-invoking function to create a private scope for our app variables. We do not want to pollute JavaScript’s global scope.

现在,我们将添加JavaScript代码,以在自调用函数中包含基本实用程序元素,从而为我们的应用程序变量创建私有范围。 我们不想污染JavaScript的全局范围。

In the above code, we have referenced all the important variables we will be requiring. We will also initialize the Pusher library using new Pusher and passing the API key as the first argument. The second argument contains an optional config object in which we will add the key authEndpoint with the custom node API route /usersystem/auth and also add the key encrypted setting it to value true.

在上面的代码中,我们已经引用了所有需要的重要变量。 我们还将使用new Pusher初始化Pusher库,并将API密钥作为第一个参数传递。 第二个参数包含一个可选的config对象,我们将在其中添加具有自定义节点API路由/usersystem/auth的密钥authEndpoint ,还添加将其设置为true encrypted密钥。

We will create a couple of generic functions to show or hide an element passing its unique id. We have also added a common method named ajax to make AJAX requests using XMLHttp object in Vanilla JavaScript.

我们将创建几个通用函数来显示或隐藏通过其唯一ID的元素。 我们还添加了一个名为ajax的通用方法,以使用Vanilla JavaScript中的XMLHttp对象发出AJAX请求。

At the load of the page we make an AJAX request to check if the user is logged in or not. If the user is logged in, we will directly use the Pusher instance to subscribe the user to a presence channel named presence-whatsup-members . You can have this as the unique chat room or app location where you want to report/track the online members.

在页面加载时,我们发出AJAX请求以检查用户是否已登录。 如果用户已登录,我们将直接使用Pusher实例将用户订阅到一个名为presence-whatsup-members的状态通道。 您可以将其作为要报告/跟踪在线成员的唯一聊天室或应用程序位置。

We have also written a method above to addNewMember using an AJAX request to the register API route we have built in Node.js. We will be passing the name and initial status entered into the form.

上面我们还编写了一种方法,该方法使用AJAX请求将addNewMember到我们在Node.js中构建的register API路由。 我们将在表单中输入名称和初始状态。

We also have a method to update the user view state based on the logged-in status. This method does nothing but update the visibility of the members list, logout button, and signup form. We have used a bindChannelEvents method when the user is logged in, which we will be implementing later in the blog post.

我们还提供了一种基于登录状态更新用户视图状态的方法。 此方法除了更新成员列表,注销按钮和注册表单的可见性外,什么也不做。 用户登录时,我们已使用bindChannelEvents方法,稍后将在博客文章中实现该方法。

Please add the following CSS in style.css file to display the me element appropriately with the username and the status of the logged-in user.

请在style.css文件中添加以下CSS,以正确显示me元素以及用户名和登录用户的状态。

步骤5:添加代码以呈现成员列表和bindChannelEvents (Step 5: Add code to render the members list and bindChannelEvents)

Now, after subscribing to the channel, we need to bind certain events so that we can know whenever a new member is added to the channel or removed from it. We will also bind to a custom event to know whenever someone updates their status.

现在,在订阅频道之后,我们需要绑定某些事件,以便我们可以知道何时有新成员添加到频道或从频道中删除。 我们还将绑定到自定义事件,以在有人更新状态时知道。

Add the following code to the app.js file:

将以下代码添加到app.js文件:

In the above bindChannelEvents method, we use the channel.bind method to bind event handlers for 3 internal events —usher:subscription_succeeded, pusher:member_added, pusher:member_removed and 1 custom event —client-status-update.

在上面的bindChannelEvents方法中,我们使用channel.bind方法绑定3个内部事件的事件处理程序— pusher:member_added usher:subscription_succeededpusher:member_addedpusher:member_removed和1个自定义事件client-status-update

Now we will add the JavaScript code to render the list of members. It is important to know that the object which I returned from the .subscribe method has a property called members , which can be used to know the information about the logged-in user referred by the key me and other members by key members. Add the following code to app.js file:

现在,我们将添加JavaScript代码以呈现成员列表。 要知道,这是我从返回的对象是很重要的.subscribe方法有一个名为属性members ,可以用来了解的信息登录的用户提到的关键me和其他成员的关键members 。 将以下代码添加到app.js文件:

We have added the event handler for new member add/remove event to re-render the members list so that it remains updated with the online members only. In order to show the members list, we need to add the following style into our file style.css:

我们为新成员添加/删除事件添加了事件处理程序,以重新呈现成员列表,以便仅使用在线成员对其进行更新。 为了显示成员列表,我们需要在文件style.css添加以下样式:

Now we will write the code to trigger a client event on our channel to notify all users about the status change of the logged in user. Add the following code to your app.js file:

现在,我们将编写代码以触发我们的频道上的客户端事件,以通知所有用户有关已登录用户的状态更改。 将以下代码添加到您的app.js文件中:

IMPORTANT: When we run this code in our browsers, update the status, and blur out of the status control, we will get an error in the JavaScript console for the Pusher library. To fix this, go to the console at Pusher.com website, go to settings, and enable sending events from clients directly.

重要说明 :当我们在浏览器中运行此代码,更新状态并模糊掉状态控件时,我们会在Pusher库JavaScript控制台中收到错误消息。 要解决此问题,请转到Pusher.com网站上的控制台,转到设置,然后启用直接从客户端发送事件的功能。

We can only send events from clients directly for Presence or Private channels. Link to the official documentation — https://Pusher.com/docs/client_api_guide/client_events#trigger-events

我们只能直接从客户发送PresencePrivate频道的事件。 链接到官方文档-https://Pusher.com/docs/client_api_guide/client_events#trigger-events

结论 (Conclusion)

We have built an application which will display all the online members for a particular presence channel and their status. If any of the online user updates their status, every user will be notified about the updated status.

我们已经构建了一个应用程序,该应用程序将显示特定presence渠道及其状态的所有在线成员。 如果有任何在线用户更新其状态,则将通知每个用户有关更新状态。

This component or code can be used for developing a social networking section in most of the web apps these days. It is an important use case where the user needs to know about other available participants. For example: an online classroom app can see the other participants and the status can correspond to any question any participant wants to ask the presenter.

如今,此组件或代码可用于在大多数Web应用程序中开发社交网络部分。 这是一个重要的用例,其中用户需要了解其他可用的参与者。 例如:一个在线教室应用程序可以看到其他参与者,并且状态可以对应于任何参与者想要向演示者提问的任何问题。

We have just used Node.js and Vanilla JavaScript to implement the above functionality. You can use the JavaScript for front-end code with any popular framework like React or Angular. The back-end can also be Java or Ruby. Please refer to the Pusher docs for more information on this.

我们刚刚使用Node.js和Vanilla JavaScript来实现上述功能。 您可以将JavaScript用于前端代码以及任何流行的框架,例如React或Angular 。 后端也可以是Java或Ruby 。 请参考Pusher文档以获取更多信息。

This blog post was originally published on Pusher’s blog.

该博客文章最初发布在Pusher的博客上 。

翻译自: https://www.freecodecamp.org/news/how-to-update-a-users-status-in-realtime-using-javascript-and-pusher-2cae8f4aaafa/

ios pusher使用

查看全文
如若内容造成侵权/违法违规/事实不符,请联系编程学习网邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

相关文章

  1. node.js新手入门初学

    新公司后端需要用到node.js做开发,由于本人在此之前实习亦或是在学校做的项目仅仅使用java所谓后端语言进行项目的开发,所以在入职之前先是自己学习node.js基础的知识,方便进公司后能快速上手工作内容。以下是本人在学习时候做的笔记内容&…...

    2024/4/20 13:10:02
  2. 100行Javascript代码实现视频通话

    视频聊天室 上一篇文章通过JavaScript调用AnyChat实现视频聊天室简单地讲述了如何通过AnyChat做视频聊天室。通过学习,我自己也做了个简单的小例子,几十行JavaScript脚本就能轻松实现视频通话;也不用去下载指定的什么浏览器,因为I…...

    2024/4/20 15:27:19
  3. 爱美尔眼睑下垂可以做双眼皮吗

    ...

    2024/4/21 12:19:43
  4. ASP.NET SingalR + MongoDB 实现简单聊天室(二):实现用户信息、聊天室初始化,聊天信息展示完善...

    第一篇已经介绍了一大半了&#xff0c;下面就是详细业务了&#xff0c;其实业务部分要注意的地方有几个&#xff0c;剩下的就是js跟html互动处理。 首先在强调一下&#xff0c;页面上不可缺少的js&#xff1a;jquery&#xff0c;singalR.js,hubs . <script src"Scripts…...

    2024/4/20 17:44:00
  5. angular+ui-router+layui的使用心得

    近来&#xff0c;完成公司的一个项目&#xff0c;项目使用angularui-routerlayui框架开发&#xff0c;由于刚刚接触angularjs,因此遇到各种各样的坑。在这里记下印象最深的几个坑&#xff1b; 一、ng-repeat 当数组元素有至少两个相同时&#xff0c;报Error: [ngRepeat:dupes]…...

    2024/4/21 12:19:43
  6. 广州公立埋线双眼皮好

    ...

    2024/4/21 12:19:40
  7. ROS入门_1.9 理解ROS话题

    目录 开始 roscoreturtlesim通过键盘远程控制turtle ROS Topics 使用 rqt_graphrostopic介绍使用 rostopic echo使用 rostopic list ROS Messages 使用 rostopic type 继续学习 rostopic 使用 rostopic pub使用 rostopic hz 使用 rqt_plot 1. 开始 roscore 首先确保roscore已经…...

    2024/4/21 12:19:39
  8. ROS官网新手级教程总结

    第 1 关卡&#xff1a;安装和配置 ROS 环境 目标&#xff1a;在计算机上安装和配置 ROS 环境。 安装 ROS 按照 ROS 安装说明进行安装。 管理环境 确定环境变量 ROS_ROOT 和 ROS_PACKAGE_PATH 已经设置好了。以我的为例&#xff1a; printenv | grep ROS 输出为&#xff1a; ROS…...

    2024/4/21 12:19:38
  9. 在ROS中发布IMU数据

    本文主要是来发布sensor_msgs/Imu类型的消息&#xff0c;其中&#xff29;&#xff2d;&#xff55;的数据为虚拟的。 &#xff11;&#xff0e;在自己的工作空间中创建ros程序包 (这个包依靠std_msgs、roscpp、rospy) catkin_create_pkg imu_publish std_msgs rospy roscpp进…...

    2024/4/24 0:44:55
  10. ROS学习笔记五:理解ROS topics

    版权声明&#xff1a;本文为博主原创文章&#xff0c;遵循 CC 4.0 BY-SA 版权协议&#xff0c;转载请附上原文出处链接和本声明。 本文链接&#xff1a;https://blog.csdn.net/mountzf/article/details/52314364 ROS学习笔记五&#xff1a;理解ROS topics 本节主要介绍ROS top…...

    2024/4/20 15:35:23
  11. ros接入IMU数据,打包发布topic

    1 串口读入IMU数据 1.1 serial工具 IMU接入ros系统可以使用I2C&#xff0c;串口或者其他方式实现&#xff0c;这里考虑使用usb转TTL解决。 参考博客ROS使用官方包进行串口通信几点说明&#xff1a; 在catkin_workspace/src 在创建package $ cd ~/catkin_ws/src $ catkin_crea…...

    2024/4/21 12:19:35
  12. 用自己的机器人和ubuntu PC实现通信和控制--26

    原创博客:转载请表明出处:http://www.cnblogs.com/zxouxuewei/ 前提&#xff1a; 1.拥有一台能够采用手动或者自动移动的机器人移动平台。 2.在电机端需要安装高分辨率的霍尔编码器。 3.在终端控制板上有基本的电机PWM控制&#xff0c;PID电机补偿调速。编码器输入捕获&#xf…...

    2024/4/21 12:19:34
  13. Gazebo使用笔记(10) —— gazebo插件与传感器的添加

    文章目录0. 插件类型添加ModelPlugin添加SensorPlugin1. 相机普通相机多机位相机深度相机2. 激光GPU LaserLaserBlock Laser3. IMUIMU (GazeboRosImu)IMU sensor (GazeboRosImuSensor)4. 其他F3D (Force Feedback Ground Truth)ForceJoint Pose TrajectoryP3D (3D Position Int…...

    2024/4/21 12:19:33
  14. ROS2官网学习笔记 理解ROS2话题篇

    ROS2官网学习笔记 理解ROS2话题篇背景要准备的条件学习内容1. 启动节点2. rqt_graph3. ros2 topic list4. ros2 topic echo5. ros2 topic info6. ros2 interface show7. ros2 topic pub8. ros2 topic hz9. 关闭节点总结学习目标&#xff1a;使用rqt_graph和命令行工具查看ROS2的…...

    2024/4/21 12:19:33
  15. ROS学习笔记 使用imu_tools对imu_raw数据进行滤波和可视化

    目录 1 前言 2. 安装 From source files 3. IMU原始数据测试 3.1 文件系统 注&#xff1a;遇到串口权限问题&#xff0c;请安装此步骤解决 3.2 运行imu_read_node 运行节点launch文件 查看节点和话题信息 查看原始数据&#xff1a; 3.3 打开rviz查看原始的imu数据 …...

    2024/4/21 12:19:31
  16. ROS学习笔记(二)-----发布者publisher的编程实现、订阅者Subscriber的编程实现、话题消息的定义和使用

    本系列文章是与大家分享一下&#xff0c;我在学习ROS过程中所做的笔记&#xff0c;目前主要的学习资料是古月老师&#xff08;胡春旭老师&#xff09;的 ROS入门21讲&#xff0c;以及其编著的《ROS机器人开发实践》&#xff0c;当然其中也加入了我自己的理解和其他的相关资料&a…...

    2024/4/21 12:19:31
  17. 发布导航需要的传感器信息和里程计消息---21

    摘要: 原创博客:转载请表明出处:http://www.cnblogs.com/zxouxuewei/ 一。ROS使用tf来决定机器人的位置和静态地图中的传感器数据&#xff0c;但是tf中没有机器人的速度信息&#xff0c;所以导航功能包要求机器人 能够通过里程计信息源发布包含速度信息的里程计nav_msgs/Odomet…...

    2024/4/21 12:19:30
  18. ROS与GAZEBO实时硬件仿真(3)——将gazebo和ros连接起来

    版权声明&#xff1a; https://blog.csdn.net/wubaobao1993/article/details/81054570 写在前面 通过上两节的博客&#xff0c;相信朋友们已经对gazebo的一些标签有了较为深入的认识&#xff0c;但是特别是上一节&#xff0c;程序写完了之后发现并没有什么特别的变化。着实&a…...

    2024/4/21 12:19:29
  19. ROS 订阅雷达/scan信息和定位信息的数据融合进行目标跟随

    雷达信息scan的数据类型如下&#xff08;通过rosmsg show 查看&#xff09;&#xff1a; 代码中用到的min(range)代表离障碍物的最小距离&#xff0c;而且代码含有简单的过滤功能&#xff0c;请仔细研读&#xff01;&#xff01;&#xff01; Header header # Head…...

    2024/4/20 16:30:41
  20. 机器人系统仿真(十六)——摄像头和kinect信息仿真以及显示

    参考视频&#xff1a;【奥特学园】ROS机器人入门课程《ROS理论与实践》零基础教程_哔哩哔哩_bilibili 参考文档&#xff1a;http://www.autolabor.com.cn/book/ROSTutorials/ 一、摄像头信息仿真以及显示 通过 Gazebo 模拟摄像头传感器&#xff0c;并在 Rviz 中显示摄像头数据。…...

    2024/5/3 15:04:21

最新文章

  1. vue3 双向绑定:如何在自定义组件中修改props定义的属性值,并更新父组件绑定的响应式变量值

    1、自定义支持双向绑定的prop 在子组件中声明一个 count prop&#xff0c;通过触发 update:count 事件更新父组件值 子组件示例代码&#xff1a; <template><div><div>[子组件] count: {{ count }}</div><button click"onClick">1&…...

    2024/5/6 5:30:27
  2. 梯度消失和梯度爆炸的一些处理方法

    在这里是记录一下梯度消失或梯度爆炸的一些处理技巧。全当学习总结了如有错误还请留言&#xff0c;在此感激不尽。 权重和梯度的更新公式如下&#xff1a; w w − η ⋅ ∇ w w w - \eta \cdot \nabla w ww−η⋅∇w 个人通俗的理解梯度消失就是网络模型在反向求导的时候出…...

    2024/3/20 10:50:27
  3. LeetCode 80—— 删除有序数组中的重复项 II

    阅读目录 1. 题目2. 解题思路3. 代码实现 1. 题目 2. 解题思路 让 index指向删除重复元素后数组的新长度&#xff1b;让 st_idx 指向重复元素的起始位置&#xff0c;而 i 指向重复元素的结束位置&#xff0c;duplicate_num代表重复元素的个数&#xff1b;一段重复元素结束后&am…...

    2024/5/2 21:20:34
  4. ASP.NET Core 标识(Identity)框架系列(一):如何使用 ASP.NET Core 标识(Identity)框架创建用户和角色?

    前言 ASP.NET Core 内置的标识&#xff08;identity&#xff09;框架&#xff0c;采用的是 RBAC&#xff08;role-based access control&#xff0c;基于角色的访问控制&#xff09;策略&#xff0c;是一个用于管理用户身份验证、授权和安全性的框架。 它提供了一套工具和库&…...

    2024/5/5 15:45:29
  5. AI小程序的创业方向:深度思考与逻辑引领

    随着人工智能技术的快速发展&#xff0c;AI小程序逐渐成为创业的新热点。在这个充满机遇与挑战的时代&#xff0c;我们有必要深入探讨AI小程序的创业方向&#xff0c;以把握未来的发展趋势。 一、目标市场定位 首先&#xff0c;我们要明确目标市场。针对不同的用户需求&#x…...

    2024/5/5 8:51:37
  6. 【外汇早评】美通胀数据走低,美元调整

    原标题:【外汇早评】美通胀数据走低,美元调整昨日美国方面公布了新一期的核心PCE物价指数数据,同比增长1.6%,低于前值和预期值的1.7%,距离美联储的通胀目标2%继续走低,通胀压力较低,且此前美国一季度GDP初值中的消费部分下滑明显,因此市场对美联储后续更可能降息的政策…...

    2024/5/4 23:54:56
  7. 【原油贵金属周评】原油多头拥挤,价格调整

    原标题:【原油贵金属周评】原油多头拥挤,价格调整本周国际劳动节,我们喜迎四天假期,但是整个金融市场确实流动性充沛,大事频发,各个商品波动剧烈。美国方面,在本周四凌晨公布5月份的利率决议和新闻发布会,维持联邦基金利率在2.25%-2.50%不变,符合市场预期。同时美联储…...

    2024/5/4 23:54:56
  8. 【外汇周评】靓丽非农不及疲软通胀影响

    原标题:【外汇周评】靓丽非农不及疲软通胀影响在刚结束的周五,美国方面公布了新一期的非农就业数据,大幅好于前值和预期,新增就业重新回到20万以上。具体数据: 美国4月非农就业人口变动 26.3万人,预期 19万人,前值 19.6万人。 美国4月失业率 3.6%,预期 3.8%,前值 3…...

    2024/5/4 23:54:56
  9. 【原油贵金属早评】库存继续增加,油价收跌

    原标题:【原油贵金属早评】库存继续增加,油价收跌周三清晨公布美国当周API原油库存数据,上周原油库存增加281万桶至4.692亿桶,增幅超过预期的74.4万桶。且有消息人士称,沙特阿美据悉将于6月向亚洲炼油厂额外出售更多原油,印度炼油商预计将每日获得至多20万桶的额外原油供…...

    2024/5/4 23:55:17
  10. 【外汇早评】日本央行会议纪要不改日元强势

    原标题:【外汇早评】日本央行会议纪要不改日元强势近两日日元大幅走强与近期市场风险情绪上升,避险资金回流日元有关,也与前一段时间的美日贸易谈判给日本缓冲期,日本方面对汇率问题也避免继续贬值有关。虽然今日早间日本央行公布的利率会议纪要仍然是支持宽松政策,但这符…...

    2024/5/4 23:54:56
  11. 【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响

    原标题:【原油贵金属早评】欧佩克稳定市场,填补伊朗问题的影响近日伊朗局势升温,导致市场担忧影响原油供给,油价试图反弹。此时OPEC表态稳定市场。据消息人士透露,沙特6月石油出口料将低于700万桶/日,沙特已经收到石油消费国提出的6月份扩大出口的“适度要求”,沙特将满…...

    2024/5/4 23:55:05
  12. 【外汇早评】美欲与伊朗重谈协议

    原标题:【外汇早评】美欲与伊朗重谈协议美国对伊朗的制裁遭到伊朗的抗议,昨日伊朗方面提出将部分退出伊核协议。而此行为又遭到欧洲方面对伊朗的谴责和警告,伊朗外长昨日回应称,欧洲国家履行它们的义务,伊核协议就能保证存续。据传闻伊朗的导弹已经对准了以色列和美国的航…...

    2024/5/4 23:54:56
  13. 【原油贵金属早评】波动率飙升,市场情绪动荡

    原标题:【原油贵金属早评】波动率飙升,市场情绪动荡因中美贸易谈判不安情绪影响,金融市场各资产品种出现明显的波动。随着美国与中方开启第十一轮谈判之际,美国按照既定计划向中国2000亿商品征收25%的关税,市场情绪有所平复,已经开始接受这一事实。虽然波动率-恐慌指数VI…...

    2024/5/4 23:55:16
  14. 【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试

    原标题:【原油贵金属周评】伊朗局势升温,黄金多头跃跃欲试美国和伊朗的局势继续升温,市场风险情绪上升,避险黄金有向上突破阻力的迹象。原油方面稍显平稳,近期美国和OPEC加大供给及市场需求回落的影响,伊朗局势并未推升油价走强。近期中美贸易谈判摩擦再度升级,美国对中…...

    2024/5/4 23:54:56
  15. 【原油贵金属早评】市场情绪继续恶化,黄金上破

    原标题:【原油贵金属早评】市场情绪继续恶化,黄金上破周初中国针对于美国加征关税的进行的反制措施引发市场情绪的大幅波动,人民币汇率出现大幅的贬值动能,金融市场受到非常明显的冲击。尤其是波动率起来之后,对于股市的表现尤其不安。隔夜美国股市出现明显的下行走势,这…...

    2024/5/6 1:40:42
  16. 【外汇早评】美伊僵持,风险情绪继续升温

    原标题:【外汇早评】美伊僵持,风险情绪继续升温昨日沙特两艘油轮再次发生爆炸事件,导致波斯湾局势进一步恶化,市场担忧美伊可能会出现摩擦生火,避险品种获得支撑,黄金和日元大幅走强。美指受中美贸易问题影响而在低位震荡。继5月12日,四艘商船在阿联酋领海附近的阿曼湾、…...

    2024/5/4 23:54:56
  17. 【原油贵金属早评】贸易冲突导致需求低迷,油价弱势

    原标题:【原油贵金属早评】贸易冲突导致需求低迷,油价弱势近日虽然伊朗局势升温,中东地区几起油船被袭击事件影响,但油价并未走高,而是出于调整结构中。由于市场预期局势失控的可能性较低,而中美贸易问题导致的全球经济衰退风险更大,需求会持续低迷,因此油价调整压力较…...

    2024/5/4 23:55:17
  18. 氧生福地 玩美北湖(上)——为时光守候两千年

    原标题:氧生福地 玩美北湖(上)——为时光守候两千年一次说走就走的旅行,只有一张高铁票的距离~ 所以,湖南郴州,我来了~ 从广州南站出发,一个半小时就到达郴州西站了。在动车上,同时改票的南风兄和我居然被分到了一个车厢,所以一路非常愉快地聊了过来。 挺好,最起…...

    2024/5/4 23:55:06
  19. 氧生福地 玩美北湖(中)——永春梯田里的美与鲜

    原标题:氧生福地 玩美北湖(中)——永春梯田里的美与鲜一觉醒来,因为大家太爱“美”照,在柳毅山庄去寻找龙女而错过了早餐时间。近十点,向导坏坏还是带着饥肠辘辘的我们去吃郴州最富有盛名的“鱼头粉”。说这是“十二分推荐”,到郴州必吃的美食之一。 哇塞!那个味美香甜…...

    2024/5/4 23:54:56
  20. 氧生福地 玩美北湖(下)——奔跑吧骚年!

    原标题:氧生福地 玩美北湖(下)——奔跑吧骚年!让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 让我们红尘做伴 活得潇潇洒洒 策马奔腾共享人世繁华 对酒当歌唱出心中喜悦 轰轰烈烈把握青春年华 啊……啊……啊 两…...

    2024/5/4 23:55:06
  21. 扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!

    原标题:扒开伪装医用面膜,翻六倍价格宰客,小姐姐注意了!扒开伪装医用面膜,翻六倍价格宰客!当行业里的某一品项火爆了,就会有很多商家蹭热度,装逼忽悠,最近火爆朋友圈的医用面膜,被沾上了污点,到底怎么回事呢? “比普通面膜安全、效果好!痘痘、痘印、敏感肌都能用…...

    2024/5/5 8:13:33
  22. 「发现」铁皮石斛仙草之神奇功效用于医用面膜

    原标题:「发现」铁皮石斛仙草之神奇功效用于医用面膜丽彦妆铁皮石斛医用面膜|石斛多糖无菌修护补水贴19大优势: 1、铁皮石斛:自唐宋以来,一直被列为皇室贡品,铁皮石斛生于海拔1600米的悬崖峭壁之上,繁殖力差,产量极低,所以古代仅供皇室、贵族享用 2、铁皮石斛自古民间…...

    2024/5/4 23:55:16
  23. 丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者

    原标题:丽彦妆\医用面膜\冷敷贴轻奢医学护肤引导者【公司简介】 广州华彬企业隶属香港华彬集团有限公司,专注美业21年,其旗下品牌: 「圣茵美」私密荷尔蒙抗衰,产后修复 「圣仪轩」私密荷尔蒙抗衰,产后修复 「花茵莳」私密荷尔蒙抗衰,产后修复 「丽彦妆」专注医学护…...

    2024/5/4 23:54:58
  24. 广州械字号面膜生产厂家OEM/ODM4项须知!

    原标题:广州械字号面膜生产厂家OEM/ODM4项须知!广州械字号面膜生产厂家OEM/ODM流程及注意事项解读: 械字号医用面膜,其实在我国并没有严格的定义,通常我们说的医美面膜指的应该是一种「医用敷料」,也就是说,医用面膜其实算作「医疗器械」的一种,又称「医用冷敷贴」。 …...

    2024/5/4 23:55:01
  25. 械字号医用眼膜缓解用眼过度到底有无作用?

    原标题:械字号医用眼膜缓解用眼过度到底有无作用?医用眼膜/械字号眼膜/医用冷敷眼贴 凝胶层为亲水高分子材料,含70%以上的水分。体表皮肤温度传导到本产品的凝胶层,热量被凝胶内水分子吸收,通过水分的蒸发带走大量的热量,可迅速地降低体表皮肤局部温度,减轻局部皮肤的灼…...

    2024/5/4 23:54:56
  26. 配置失败还原请勿关闭计算机,电脑开机屏幕上面显示,配置失败还原更改 请勿关闭计算机 开不了机 这个问题怎么办...

    解析如下&#xff1a;1、长按电脑电源键直至关机&#xff0c;然后再按一次电源健重启电脑&#xff0c;按F8健进入安全模式2、安全模式下进入Windows系统桌面后&#xff0c;按住“winR”打开运行窗口&#xff0c;输入“services.msc”打开服务设置3、在服务界面&#xff0c;选中…...

    2022/11/19 21:17:18
  27. 错误使用 reshape要执行 RESHAPE,请勿更改元素数目。

    %读入6幅图像&#xff08;每一幅图像的大小是564*564&#xff09; f1 imread(WashingtonDC_Band1_564.tif); subplot(3,2,1),imshow(f1); f2 imread(WashingtonDC_Band2_564.tif); subplot(3,2,2),imshow(f2); f3 imread(WashingtonDC_Band3_564.tif); subplot(3,2,3),imsho…...

    2022/11/19 21:17:16
  28. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机...

    win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”问题的解决方法在win7系统关机时如果有升级系统的或者其他需要会直接进入一个 等待界面&#xff0c;在等待界面中我们需要等待操作结束才能关机&#xff0c;虽然这比较麻烦&#xff0c;但是对系统进行配置和升级…...

    2022/11/19 21:17:15
  29. 台式电脑显示配置100%请勿关闭计算机,“准备配置windows 请勿关闭计算机”的解决方法...

    有不少用户在重装Win7系统或更新系统后会遇到“准备配置windows&#xff0c;请勿关闭计算机”的提示&#xff0c;要过很久才能进入系统&#xff0c;有的用户甚至几个小时也无法进入&#xff0c;下面就教大家这个问题的解决方法。第一种方法&#xff1a;我们首先在左下角的“开始…...

    2022/11/19 21:17:14
  30. win7 正在配置 请勿关闭计算机,怎么办Win7开机显示正在配置Windows Update请勿关机...

    置信有很多用户都跟小编一样遇到过这样的问题&#xff0c;电脑时发现开机屏幕显现“正在配置Windows Update&#xff0c;请勿关机”(如下图所示)&#xff0c;而且还需求等大约5分钟才干进入系统。这是怎样回事呢&#xff1f;一切都是正常操作的&#xff0c;为什么开时机呈现“正…...

    2022/11/19 21:17:13
  31. 准备配置windows 请勿关闭计算机 蓝屏,Win7开机总是出现提示“配置Windows请勿关机”...

    Win7系统开机启动时总是出现“配置Windows请勿关机”的提示&#xff0c;没过几秒后电脑自动重启&#xff0c;每次开机都这样无法进入系统&#xff0c;此时碰到这种现象的用户就可以使用以下5种方法解决问题。方法一&#xff1a;开机按下F8&#xff0c;在出现的Windows高级启动选…...

    2022/11/19 21:17:12
  32. 准备windows请勿关闭计算机要多久,windows10系统提示正在准备windows请勿关闭计算机怎么办...

    有不少windows10系统用户反映说碰到这样一个情况&#xff0c;就是电脑提示正在准备windows请勿关闭计算机&#xff0c;碰到这样的问题该怎么解决呢&#xff0c;现在小编就给大家分享一下windows10系统提示正在准备windows请勿关闭计算机的具体第一种方法&#xff1a;1、2、依次…...

    2022/11/19 21:17:11
  33. 配置 已完成 请勿关闭计算机,win7系统关机提示“配置Windows Update已完成30%请勿关闭计算机”的解决方法...

    今天和大家分享一下win7系统重装了Win7旗舰版系统后&#xff0c;每次关机的时候桌面上都会显示一个“配置Windows Update的界面&#xff0c;提示请勿关闭计算机”&#xff0c;每次停留好几分钟才能正常关机&#xff0c;导致什么情况引起的呢&#xff1f;出现配置Windows Update…...

    2022/11/19 21:17:10
  34. 电脑桌面一直是清理请关闭计算机,windows7一直卡在清理 请勿关闭计算机-win7清理请勿关机,win7配置更新35%不动...

    只能是等着&#xff0c;别无他法。说是卡着如果你看硬盘灯应该在读写。如果从 Win 10 无法正常回滚&#xff0c;只能是考虑备份数据后重装系统了。解决来方案一&#xff1a;管理员运行cmd&#xff1a;net stop WuAuServcd %windir%ren SoftwareDistribution SDoldnet start WuA…...

    2022/11/19 21:17:09
  35. 计算机配置更新不起,电脑提示“配置Windows Update请勿关闭计算机”怎么办?

    原标题&#xff1a;电脑提示“配置Windows Update请勿关闭计算机”怎么办&#xff1f;win7系统中在开机与关闭的时候总是显示“配置windows update请勿关闭计算机”相信有不少朋友都曾遇到过一次两次还能忍但经常遇到就叫人感到心烦了遇到这种问题怎么办呢&#xff1f;一般的方…...

    2022/11/19 21:17:08
  36. 计算机正在配置无法关机,关机提示 windows7 正在配置windows 请勿关闭计算机 ,然后等了一晚上也没有关掉。现在电脑无法正常关机...

    关机提示 windows7 正在配置windows 请勿关闭计算机 &#xff0c;然后等了一晚上也没有关掉。现在电脑无法正常关机以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;关机提示 windows7 正在配…...

    2022/11/19 21:17:05
  37. 钉钉提示请勿通过开发者调试模式_钉钉请勿通过开发者调试模式是真的吗好不好用...

    钉钉请勿通过开发者调试模式是真的吗好不好用 更新时间:2020-04-20 22:24:19 浏览次数:729次 区域: 南阳 > 卧龙 列举网提醒您:为保障您的权益,请不要提前支付任何费用! 虚拟位置外设器!!轨迹模拟&虚拟位置外设神器 专业用于:钉钉,外勤365,红圈通,企业微信和…...

    2022/11/19 21:17:05
  38. 配置失败还原请勿关闭计算机怎么办,win7系统出现“配置windows update失败 还原更改 请勿关闭计算机”,长时间没反应,无法进入系统的解决方案...

    前几天班里有位学生电脑(windows 7系统)出问题了&#xff0c;具体表现是开机时一直停留在“配置windows update失败 还原更改 请勿关闭计算机”这个界面&#xff0c;长时间没反应&#xff0c;无法进入系统。这个问题原来帮其他同学也解决过&#xff0c;网上搜了不少资料&#x…...

    2022/11/19 21:17:04
  39. 一个电脑无法关闭计算机你应该怎么办,电脑显示“清理请勿关闭计算机”怎么办?...

    本文为你提供了3个有效解决电脑显示“清理请勿关闭计算机”问题的方法&#xff0c;并在最后教给你1种保护系统安全的好方法&#xff0c;一起来看看&#xff01;电脑出现“清理请勿关闭计算机”在Windows 7(SP1)和Windows Server 2008 R2 SP1中&#xff0c;添加了1个新功能在“磁…...

    2022/11/19 21:17:03
  40. 请勿关闭计算机还原更改要多久,电脑显示:配置windows更新失败,正在还原更改,请勿关闭计算机怎么办...

    许多用户在长期不使用电脑的时候&#xff0c;开启电脑发现电脑显示&#xff1a;配置windows更新失败&#xff0c;正在还原更改&#xff0c;请勿关闭计算机。。.这要怎么办呢&#xff1f;下面小编就带着大家一起看看吧&#xff01;如果能够正常进入系统&#xff0c;建议您暂时移…...

    2022/11/19 21:17:02
  41. 还原更改请勿关闭计算机 要多久,配置windows update失败 还原更改 请勿关闭计算机,电脑开机后一直显示以...

    配置windows update失败 还原更改 请勿关闭计算机&#xff0c;电脑开机后一直显示以以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容&#xff0c;让我们赶快一起来看一下吧&#xff01;配置windows update失败 还原更改 请勿关闭计算机&#x…...

    2022/11/19 21:17:01
  42. 电脑配置中请勿关闭计算机怎么办,准备配置windows请勿关闭计算机一直显示怎么办【图解】...

    不知道大家有没有遇到过这样的一个问题&#xff0c;就是我们的win7系统在关机的时候&#xff0c;总是喜欢显示“准备配置windows&#xff0c;请勿关机”这样的一个页面&#xff0c;没有什么大碍&#xff0c;但是如果一直等着的话就要两个小时甚至更久都关不了机&#xff0c;非常…...

    2022/11/19 21:17:00
  43. 正在准备配置请勿关闭计算机,正在准备配置windows请勿关闭计算机时间长了解决教程...

    当电脑出现正在准备配置windows请勿关闭计算机时&#xff0c;一般是您正对windows进行升级&#xff0c;但是这个要是长时间没有反应&#xff0c;我们不能再傻等下去了。可能是电脑出了别的问题了&#xff0c;来看看教程的说法。正在准备配置windows请勿关闭计算机时间长了方法一…...

    2022/11/19 21:16:59
  44. 配置失败还原请勿关闭计算机,配置Windows Update失败,还原更改请勿关闭计算机...

    我们使用电脑的过程中有时会遇到这种情况&#xff0c;当我们打开电脑之后&#xff0c;发现一直停留在一个界面&#xff1a;“配置Windows Update失败&#xff0c;还原更改请勿关闭计算机”&#xff0c;等了许久还是无法进入系统。如果我们遇到此类问题应该如何解决呢&#xff0…...

    2022/11/19 21:16:58
  45. 如何在iPhone上关闭“请勿打扰”

    Apple’s “Do Not Disturb While Driving” is a potentially lifesaving iPhone feature, but it doesn’t always turn on automatically at the appropriate time. For example, you might be a passenger in a moving car, but your iPhone may think you’re the one dri…...

    2022/11/19 21:16:57