Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

DRC Vehicle commands via rospy

Hi, I am trying to control the DRC Vehicle using a python code to substitute the rostopic pub commands given through the terminal, however, I'm not making much headway. On running the code, rostopic echo returns the default values for all parameters. This is the code I have tried: (I'm very new to ROS and Gazebo, recently started learning)

import roslib; roslib.load_manifest('vehicle_control') import rospy from std_msgs.msg import Float64 from std_msgs.msg import Int8

def mover(): rospy.init_node('vehicle_control')

rospy.loginfo("Release brake.")
pub1=rospy.Publisher('/drc_vehicle_xp900/hand_brake/cmd', Float64)
pub1.publish(data=0.0)
rospy.sleep(3);

rospy.loginfo("Moving forward.")
pub2=rospy.Publisher('/drc_vehicle_xp900/gas_pedal/cmd', Float64)
pub2.publish(data=1.0)
rospy.sleep(3);

rospy.loginfo("Turning right.")
pub3=rospy.Publisher('/drc_vehicle_xp900/hand_wheel/cmd', Float64)
pub3.publish(data=3.14)
rospy.sleep(3);

rospy.loginfo("Killing engine.")
pub5=rospy.Publisher('/drc_vehicle_xp900/key/cmd', Int8)
pub5.publish(data=0)
rospy.sleep(3);

if __name__ == '__main__': try: mover() except rospy.ROSInterruptException: pass

Any help would be great, thanks in advance!