自由度工业机械臂..."/>
如何用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七自由度工业机械臂...
发布评论