Home | Tutorials | Wiki | Issues
Ask Your Question

Using DRC vehicle commands in version 2.5

asked 2013-05-15 23:20:48 -0600

David Jeang gravatar image

I built a self driving vehicle using version 2.2 by following the tutorial here:


But after upgrading to 2.5, my code won't run anymore. I don't want to downgrade again since some of my other programs run on 2.5, so I'd rather just modify my existing vehicle driver to work for 2.5. What can I use to manipulate the drc vehicle in version 2.5?

edit retag flag offensive close merge delete


Can you elaborate on what's not working? Are you trying to use ros topics? Are you able to echo the state topics like rostopic echo /drc_vehicle/brake_pedal/state? Are there any console error messages?

scpeters gravatar imagescpeters ( 2013-06-14 13:34:53 -0600 )edit

According to my code, the driver should do this once the loop begins, get in the car, undo the handbrake, drive in figure 8, then four corner turns in a square, brake,reverse direction, brake, and repeat until forced termination. All it seems to do is enter the car, I get the printed messages on the console, so I know it's executing the functions with no error. I think according to the code I am using rostopics. I'm not sure about the echoing, I haven't tried that. What's the result wanted?

David Jeang gravatar imageDavid Jeang ( 2013-06-14 21:56:11 -0600 )edit

Just to reiterate, I have posted a copy of my code on pastebin for others to analyze, are there any more suggestions?

David Jeang gravatar imageDavid Jeang ( 2013-06-19 22:34:26 -0600 )edit

Ok, I've examined your code. It looks like you are using ros topics for control. I'm trying to remember if there were bugs with vehicle control in drcsim_2.5. The latest version is 2.6, but there's a few things to try aside from upgrading.

scpeters gravatar imagescpeters ( 2013-06-24 00:59:27 -0600 )edit

Can you try running the command from the command line while the simulation is running: "rostopic echo /drc_vehicle/brake_pedal/state" It should print out several numbers near zero if the brake pedal is not pressed. If there's no messages, then there's a problem with the vehicle plugin.

scpeters gravatar imagescpeters ( 2013-06-24 01:09:30 -0600 )edit

I've actually upgraded as I've made some progress on a different machine with 2.6, I have a new problem now that is right here:http://answers.gazebosim.org/question/3395/sdf-version-problems-cause-drcsim26-and-gazebo18/.this topic is still open though.

David Jeang gravatar imageDavid Jeang ( 2013-06-28 13:44:48 -0600 )edit

Updated issue has been resolved, and the VRC cheats seem to work, as the wheels can now turn, however the vehicle still will not move, so either the issue is with the brake, handbrake, or accelerator. I adjusted values for all three, but no response.

David Jeang gravatar imageDavid Jeang ( 2013-07-09 15:03:23 -0600 )edit

When you say the wheels can turn, I assume you mean that the steering works? The following commands can help with debugging the brake, handbrake, and gas pedal: rostopic echo /drc_vehicle/gas_pedal/state, rostopic echo /drc_vehicle/brake_pedal/state, rostopic echo /drc_vehicle/hand_brake/state

scpeters gravatar imagescpeters ( 2013-07-09 16:23:07 -0600 )edit

I've never used echo before, do I use that command before, during, or after running the executable? And do I do it in a new terminal next the one running the program or in the same one? Also, on a side note, does anyone know how to install rospy? Issue right here:https://bitbucket.org/osrf/drcsim/issue/334/unable-to-use-rospy

David Jeang gravatar imageDavid Jeang ( 2013-07-13 23:14:22 -0600 )edit

Just so you know, I think it's the hand brake, when I echoed it before and after the program, it remains the same value of 1.0, but the gas pedal and brake changed to their respective assigned values(i.e. gas pedal 0.0->1.0). The code is still the same on pastebin, so what should I try to get the handbrake working?

David Jeang gravatar imageDavid Jeang ( 2013-07-13 23:52:39 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2013-05-17 00:04:20 -0600

scpeters gravatar image

updated 2013-05-27 13:01:35 -0600

gerkey gravatar image

Do you have the environment variable VRC_CHEATS_ENABLED set to 1? The ros topics for controlling the vehicle are provided as a development aid, but will not be available during the Virtual Robotics Challenge. As such, they are disabled by default, but are available by setting the VRC_CHEATS_ENABLED variable.

For example, to launch VRC task 1 with cheats enabled:

VRC_CHEATS_ENABLED=1 roslaunch atlas_utils vrc_task_1.launch

You could also make that setting persistent in your shell:


Then subsequent launches will include cheats.

edit flag offensive delete link more


So export VRC_CHEATS_ENABLED=1 in the shell, that's the ./bashrc right? Does it matter where I put that?

David Jeang gravatar imageDavid Jeang ( 2013-05-28 14:28:33 -0600 )edit

Sure, putting the export line in your `~/.bashrc` would do the trick.

gerkey gravatar imagegerkey ( 2013-05-28 17:24:26 -0600 )edit

No good. I set it both the shell and on command line. export VRCCHEATSENABLED=1 roslaunch atlasutils atlasdrcvehiclefire_hose.launch. When I ran my code, it still wouldn't respond. Should I show a copy of my code so it can be tested?

David Jeang gravatar imageDavid Jeang ( 2013-06-14 10:39:41 -0600 )edit

Sure, if you can show the code, then we can help diagnose the problem.

scpeters gravatar imagescpeters ( 2013-06-14 15:28:34 -0600 )edit

Thanks, there's a character limit, so I'll have ot break it down in parts, luckily it's not too long. #include <math.h> #include <ros ros.h=""> #include <ros subscribe_options.h=""> #include <boost thread.hpp=""> #include <boost algorithm="" string.hpp=""> #include <gazebo common="" time.hh=""> #include <sensor_msgs jointstate.h=""> #include <geometry_msgs pose.h=""> #include <osrf_msgs jointcommands.h=""> #include <std_msgs float64.h=""> #include <std_msgs int8.h="">

David Jeang gravatar imageDavid Jeang ( 2013-06-14 21:34:55 -0600 )edit

ros::Publisher pubdrivecommands1; ros::Publisher pubdrivecommands2; ros::Publisher pubdrivecommands3; ros::Publisher pubdrivecommands4; ros::Publisher pubdrivecommands5; ros::Publisher pubdrivecommands6;

geometrymsgs::Pose posemsgs;void toggleHandBrake(ros::Publisher pubdrivecommands, stdmsgs::Float64 handbrake){ printf("robot toggle hand brake\n"); pubdrivecommands.publish(handbrake); printf("ros spinOnce\n"); ros::spinOnce(); }

David Jeang gravatar imageDavid Jeang ( 2013-06-14 21:39:18 -0600 )edit

void toggleGasPedal(ros::Publisher pubdrivecommands, stdmsgs::Float64 gaspedal){ printf("robot press/unpress gas pedal\n"); pubdrivecommands.publish(gaspedal); printf("ros spinOnce\n"); ros::spinOnce(); }void toggleBrakePedal(ros::Publisher pubdrivecommands, stdmsgs::Float64 brakepedal){ printf("robot press/unpress brake pedal\n"); pubdrivecommands.publish(brakepedal); printf("ros spinOnce\n"); ros::spinOnce(); }

David Jeang gravatar imageDavid Jeang ( 2013-06-14 21:39:56 -0600 )edit

void turnWheel(ros::Publisher pub_drive_commands, std_msgs::Float64 turn_wheel_magnitude, bool leftorright){ printf("robot turn wheel\n"); if(leftorright == false) turn_wheel_magnitude.data = (((double)turn_wheel_magnitude.data) * -1.0); pub_drive_commands.publish(turn_wheel_magnitude); printf("ros spinOnce\n"); ros::spinOnce(); }

David Jeang gravatar imageDavid Jeang ( 2013-06-14 21:40:48 -0600 )edit

void changeGear(ros::Publisher pub_drive_commands, std_msgs::Int8 direction){ printf("robot change direction of vehicle\n"); pub_drive_commands.publish(direction); printf("ros spinOnce\n"); ros::spinOnce(); }void figure8(ros::Publisher turn_command, std_msgs::Float64 degree){ turnWheel(turn_command,degree,true); ros::Duration(5).sleep(); turnWheel(turn_command,degree,false); ros::Duration(5).sleep(); }

David Jeang gravatar imageDavid Jeang ( 2013-06-14 21:41:21 -0600 )edit

void circle(ros::Publisher turncommand, stdmsgs::Float64 degree, bool lr){ turnWheel(turncommand,degree,lr); ros::Duration(10).sleep(); }void square(ros::Publisher turncommand, stdmsgs::Float64 degree, bool lr, int length){ stdmsgs::Float64 handwheel3; handwheel3.data = 00.00f; turnWheel(turncommand,degree,lr); ros::Duration(1.5).sleep(); turnWheel(turncommand,handwheel3,lr); ros::Duration(length).sleep();turnWheel(turncommand,degree,lr); ros::Duration(1.5).sleep();

David Jeang gravatar imageDavid Jeang ( 2013-06-14 21:42:26 -0600 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-05-15 23:20:48 -0600

Seen: 575 times

Last updated: May 27 '13