Not able to control motor wheels in RVIZ through Python Publisher
Hi, I'm running Ubuntu 18.04, melodic.
I'm very new to ROS in general (1 week new), so hopefully you guys can be a bit more patient. So anyway, I wrote a Python publisher for my (differential drive) car. It supposed to send the joint state of my two wheels to RVIZ, and in RVIZ, I supposed to see my car moving with the set speed coming from python side.
It didn't happen. I think maybe I'm missing something, or misunderstood something? If you guys can point that out, it would be great!
Here's my Python side:
Hi, I'm very new to ROS in general (1 week new), so hopefully you guys can be a bit more patient. So anyway, I wrote a Python publisher for my (differential drive) car. It supposed to send the joint state of my two wheels to RVIZ, and in RVIZ, I supposed to see my car moving with the set speed coming from python side.
It didn't happen. I think maybe I'm missing something, or misunderstood something? If you guys can point that out, it would be great!
Here's my Python side:
#!/usr/bin/env python
import rospy
from std_msgs.msg import Header
from sensor_msgs.msg import JointState
def talker():
pub = rospy.Publisher('joint_states', JointState, queue_size=10)
rospy.init_node('joint_state_publisher', anonymous = True)
rate = rospy.Rate(10) # 10hz
while not rospy.is_shutdown():
jointState_msg = JointState()
jointState_msg.header = Header()
jointState_msg.header.stamp = rospy.Time.now()
jointState_msg.name = ['left_wheel_holder_to_left_wheel', 'right_wheel_holder_to_right_wheel']
jointState_msg.position = []
jointState_msg.velocity = [1, 1]
jointState_msg.effort = []
pub.publish(jointState_msg)
rate.sleep()
if __name__ == '__main__':
try:
talker()
except rospy.ROSInterruptException:
pass
Here's my launch file:
<launch>
<param name="robot_description" textfile="$(find rover_project)/rover_description/urdf/rover.urdf"/>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find rover_project)/rover_description/launch/rviz_config.rviz" />
<node pkg="robot_state_publisher" type="robot_state_publisher" name="rob_st_pub">
<param name="use_gui" value="True"/>
</node>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<param name="use_gui" value="True"/>
</node>
</launch>
And most importantly, and this is where I think went wrong, my urdf file:
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="Rover Platform">
<material name="blue">
<color rgba="0 0 0.8 1"/>
</material>
<material name="grey">
<color rgba="0.2 0.2 0 1"/>
</material>
<xacro:macro name="default_origin">
<origin rpy="0 0 0" xyz="0 0 0"/>
</xacro:macro>
<link name="base_link">
<visual>
<geometry>
<box size="1.0 1.0 0.2"/>
</geometry>
<xacro:default_origin />
<material name="blue"/>
</visual>
<collision>
<geometry>
<box size="1.0 1.0 0.2"/>
</geometry>
</collision>
<inertial>
<mass value="5"/>
<inertia ixx="0.83333" ixy="0.0" ixz="0.0" iyy="0.433333" iyz="0.0" izz="0.433333"/>
</inertial>
</link>
<link name ...