如何用MATLAB做边际效用,1、在仿真机中运行Gazebo LBR Simulator七自由度工业机械臂...

编程入门 行业动态 更新时间:2024-10-27 08:31:26

如何用MATLAB做边际效用,1、在仿真机中运行Gazebo LBR Simulator七<a href=https://www.elefans.com/category/jswz/34/1765797.html style=自由度工业机械臂..."/>

如何用MATLAB做边际效用,1、在仿真机中运行Gazebo LBR Simulator七自由度工业机械臂...

1、在仿真机中运行Gazebo LBR Simulator七自由度工业机械臂

2、在Matlab中连接ROS网络

rosinit('192.168.127.128')

3、查看ROS网络中的节点和主题并记录结果

rosnode list

rostopic list

4、查询主题/iiwa/PositionJointInterface_trajectory_controller/command的消息类型,以及发布者和订阅者。

rostopic info

rostopic type

5、订阅/iiwa/joint_states主题,并接收一个消息,可以获得机械臂七个关节Joint的名称和当前位置,并记录

jointStateSub = rossubscriber('/iiwa/joint_states')

jsMsg=receive(jointStateSub)

6、注册为主题/iiwa/PositionJointInterface_trajectory_controller/command的消息发布者,然后再查询主题的发布者和订阅者,跟4比较。

[jointTauPub, jtMsg] = rospublisher('/iiwa/PositionJointInterface_trajectory_controller/command')

rostopic info

7、构造trajectory_msgs/JointTrajectory消息,并发布,控制机械臂运动

jtMsg = rosmessage('trajectory_msgs/JointTrajectory')

jtMsg.JointNames = 第5步查询到的七个关节名称

jtMsg.Points 是trajectory_msgs/JointTrajectoryPioint消息的集合,所以需要构造若干个trajectory_msgs/JointTrajectoryPioint消息,并赋给jtMsg.Points

tjPoint1 = rosmessage('trajectory_msgs/JointTrajectoryPoint')

tjPoint2 = rosmessage('trajectory_msgs/JointTrajectoryPoint')

tjPoint1.Positions = 七个关节的位置

tjPoint1.Velocities = 七个关节的运动速度,可设为0

tjPoint1.TimeFromStart.Sec = 1

tjPoint1.TimeFromStart.Nsec = 0

tjPoint2.Positions = 七个关节的另一个位置

tjPoint2.Velocities = 七个关节的运动速度,可设为0

tjPoint2.TimeFromStart.Sec = 4

tjPoint2.TimeFromStart.Nsec = 0;

把这两个点或者更多的点赋给jtMsg.Points

jtMsg.Points = [tjPoint1,tjPoint2]

发送消息

send(jointTauPub,jtMsg)

观察机械臂的动作

8、尝试改变不同关节的角度,观察机械臂的动作。动作完成后,参照5接收一个/iiwa/joint_states主题的消息,查看机械臂的位置是否跟你设置的位置一样。

9、退出ROS网络

rosshutdown

更多推荐

如何用MATLAB做边际效用,1、在仿真机中运行Gazebo LBR Simulator七自由度工业机械臂...

本文发布于:2024-02-12 12:23:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1687785.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自由度   效用   边际   如何用   机中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!