Publishing joint_state with python and displaying in rviz
Hey Guys,
I'm have a robot arm I'm trying to put into ros. I went through the urdf_tutorial and got a urdf that works with the tutorial launch file. Now, I want to write a node that publishes to /joint_states and uses robot_state_publisher to update the robot. I'd like to display the robot in rviz, and also write a subscriber to /joint_states that moves the actual arm.
The problem I'm having is, when I write my own simple node to publish to /joint_states, rviz gives me errors for all of my joint transforms. (ie "no transform from [first_segment] to [base_link]" and "no transform from [second_segment] to [base_link]", also there's "Fixed Frame: No tf data. Actual error: Fixed Frame [base_link] does not exist"
I've looked at the documentation for robot_state_publisher, read the code for joint_state_publisher and tried manually sending tf's through my node.
I use this command to put in my urdf and launch the code:
roslaunch launch/display.launch model:=urdf/josh-arm.urdf
Here's my urdf, launch file, and python code (sorry I couldn't attach it.. don't have enough karma):
Thanks!
<launch>
<arg name="model" />
<arg name="gui" default="true" />
<arg name="rvizconfig" default="$(find urdf_tutorial)/rviz/urdf.rviz" />
<param name="robot_description" command="$(find xacro)/xacro.py $(arg model)" />
<param name="use_gui" value="$(arg gui)"/>
<node name="updateArm" pkg="me439arm" type="updateArm.py"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
</launch>
The urdf file:
<?xml version="1.0"?>
<robot name="visual">
<material name="blue">
<color rgba="0 0 0.8 1"/>
</material>
<material name="black">
<color rgba="0 0 0 1"/>
</material>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
<link name="base_link">
<visual>
<geometry>
<cylinder length="0.1026" radius="0.025"/>
</geometry>
</visual>
</link>
<link name="base_rotate">
<visual>
<geometry>
<sphere radius="0.025"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 .1026"/>
<material name="white"/>
</visual>
</link>
<joint name="base_joint" type="revolute">
<axis xyz=" 0 0 1"/>
<parent link="base_link"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
<limit effort="1000.0" lower="-3.14159" upper="3.14159" velocity=".5"/>
<child link="base_rotate"/>
</joint>
<link name="first_segment">
<visual>
<geometry>
<cylinder length="0.1180" radius="0.025"/>
</geometry>
<origin rpy="0 0 0" xyz="-.0310 0 .059"/>
<material name="white"/>
</visual>
</link>
<joint name="first_segment_joint" type="revolute">
<axis rpy="0 1 0" xyz="0 1 0"/>
<origin rpy="0 0 0" xyz="0 0 .1"/>
<limit effort="1000.0" lower="-3.14159" upper="3.14159" velocity=".5"/>
<parent link="base_rotate"/>
<child link="first_segment"/>
</joint>
<link name="second_segment">
<visual>
<geometry>
<cylinder length="0.02" radius="0.025"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 .01"/>
<material name="white"/>
</visual>
</link>
<joint name="second_segment_joint" type="revolute">
<axis rpy="0 1 0" xyz="0 1 0"/>
<origin rpy="0 0 0" xyz="-.0310 0 .1180"/>
<limit effort="1000.0" lower="-3.14159" upper="3 ...
Don't worry about not being able to your code as a file. It's actually better to include the code in the question as you have done here.