Mobile Robot Teleoperation in Rviz
Hello,
I am trying to teleoperate a mobile robot model with a PS3 joystick on Rviz. My system is Ubuntu 12.04 with Groovy. I've the ps3joy package installed. I want the linear values of two analog joysticks to be my velocity references of the wheels. I wrote a joint state publisher (which is subscribed to the joystick node) and an odometry transform braodcaster. In the launch file I also run the robot state publisher. When I try to move the model, I have to choose /odom frame and robot only turns around a circle with /odom frame in center, it can't move linearly.
Also, I'm not very sure about what should I send to odometry tf broadcaster. I took the joint_state.velocity[] as linear velocity of the wheel. I calculate the change in the robot's angle by substituting the previous angular velocity from the present angular velocity as;
jsVelL_ = jointState.velocity[1]; //left wheel velocity reference from left joystick
jsVelR_ = jointState.velocity[2]; // right wheel velocity reference from right joystick
angleDelta = ((jsVelR_-jsVelL_)/length)-angle; //angular velocity - prev. ang. velocity
angle = angleDelta;
So I'm passing this to odometry transform broadcaster as;
odom_trans.transform.translation.x = cos(angle);
odom_trans.transform.translation.y = sin(angle);
odom_trans.transform.translation.z = 0.0;
odom_trans.transform.rotation = tf::createQuaternionMsgFromYaw(angle);
broadcaster.sendTransform(odom_trans);
So my questions;
- Why can I only move around the /odom frame in circle?
- Shouldn't /odom frame drift with the robot and thus shouldn't I find and select a higher order world frame as fixed?
- I treated joint_state.velocity[] as linear velocities of my wheels. Is that true or are they angular velocities?
- Is my usage of odom tf broadcaster right as I've tried to use the change in the robot's angle? If not how should it be?
Thank you.
My launch file:
<launch>
<arg name="gui" default="False" />
<param name="robot_description" textfile="$(find agv)/urdf/agv3.urdf" />
<param name="use_gui" value="$(arg gui)"/>
<node respawn="true" pkg="joy"
type="joy_node" name="joy_node" >
<param name="dev" type="string" value="/dev/input/js0" />
<param name="deadzone" value="0.12" />
</node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find agv)/urdf.rviz" />
<!-- Axes -->
<param name="axis_linear_L" value="0" type="int"/>
<param name="axis_linear_R" value="2" type="int"/>
<param name="scale_linear_L" value="5" type="double"/>
<param name="scale_linear_R" value="5" type="double"/>
<node pkg="agv" type="jsPublisher" name="Joint_State_Publisher" ></node>
<node pkg="agv" type="odomTF" name="Odometry_Tf_Broadcaster" ></node>
</launch>
Urdf of the mobile robot:
<robot name="AGV">
<link name="base_link">
<visual>
<geometry>
<box size="0.49 .82 .2"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0.01"/>
<material name="gray">
<color rgba="0 0 0 0.6"/>
</material>
</visual>
</link>
<link name="wheel_left">
<visual>
<geometry>
<cylinder length="0.05" radius="0.1"/>
</geometry>
<origin rpy="0 1.57079633 0" xyz="0 0 0"/>
<material name="black">
<color rgba="1 0 0 1"/>
</material>
</visual>
</link ...