Problem with JointTrajectory message
I'm trying to publish a JoinTrajectory message to move a robot arm in Gazebo. When i type roslaunch mypackage myfile.launch i don't have error but the robot doesn't move (it appears in Gazebo but it is stuck). What I forgot? These are my file (script,launch and yaml), the urdf is provided by Denso:
#! /usr/bin/env python
import rospy
from trajectory_msgs.msg import JointTrajectory
from trajectory_msgs.msg import JointTrajectoryPoint
rospy.init_node('trajectory')
pub = rospy.Publisher('/vs060/arm_controller/command',JointTrajectory,queue_size=1)
trajectory=JointTrajectory()
point=JointTrajectoryPoint()
trajectory.header.stamp=rospy.Time.now()
trajectory.header.frame_id = "/base_link";
trajectory.joint_names.append("joint_1");
trajectory.joint_names.append("joint_2");
trajectory.joint_names.append("joint_3");
trajectory.joint_names.append("joint_4");
trajectory.joint_names.append("joint_5");
trajectory.joint_names.append("joint_6");
point.positions.append(0.0)
point.positions.append(0.0)
point.positions.append(0.3)
point.positions.append(0.6)
point.positions.append(0.5)
point.positions.append(10.0)
trajectory.points.append(point)
pub.publish(trajectory)
I created also this launch file to load robot model, to launch the nodes, the controllers:
<launch>
<!-- This launch file will start gazebo with a robot model (by default the vs060) -->
<!-- Override robot_name argument to load a different robot -->
<arg name="robot_name" default="vs060" />
<!-- Robot description argument -->
<arg name="robot_description" value="$(arg robot_name)_description" />
<!-- include the empty world to launch gazebo -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find denso_robot_gazebo)/worlds/denso_robot.world"/>
</include>
<!-- Load the URDF, SRDF and other .yaml configuration files on the param server -->
<param name="robot_description" type="str" textfile="$(find denso_robot_descriptions)/$(arg robot_description)/$(arg robot_name).urdf"/>
<!-- $(arg gui) evaluates to the value specified by an <arg> tag. There must be a corresponding <arg> tag in the same launch file that declares the arg. -->
<arg name="gui" default="true"/>
<param name="use_gui" value="$(arg gui)"/>
<!-- launch the spawn_urdf node using spawn_model from the gazebo_ros package with some arguments -->
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -model $(arg robot_name)" />
<!-- To load the controller -->
<rosparam file="$(find denso_robot_descriptions)/$(arg robot_description)/denso_robot_control.yaml" command="load" />
<!-- Launch the controller_spawner node from controller_manager using spawner executable, if it dies it doesn't respawn, the node starts in the namespace provided by the robot_name argument-->
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen"
ns="/$(arg robot_name)" args="joint_state_controller arm_controller" />
<node name="robot_state_publisher" pkg="robot_state_publisher"
type="robot_state_publisher" respawn="false" output="screen">
<!-- Remap let you launch the same node under multiple configurations from the command-line. -->
<remap from="/joint_states" to="/$(arg robot_name)/joint_states" />
</node>
<node name="trajectory" pkg="vs060robot" type="trajectory.py" output="screen">
</node>
</launch>
And this is the .yaml file:
vs060:
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 125
arm_controller:
type: "position_controllers/JointTrajectoryController"
joints:
- joint_1
- joint_2
- joint_3
- joint_4
- joint_5
- joint_6
Asked by milini on 2018-09-18 12:08:11 UTC
Comments
did you find a solution? i have the same problem
Asked by joeced on 2019-05-09 11:12:28 UTC