Project

General

Profile

Revision fa5ca6e3

IDfa5ca6e34e21f7bbdd4290fe1531fdc134901d14

Added by Priya about 11 years ago

Fixed pause not working with the GUI. Also removed super annoying printf from MotorControl. And also fixed some pause/resume GUI bugs and the fact that process.kill and process.terminate wouldnt do anything.

View differences:

scout/libscout/src/MotorControl.cpp
258 258
 **/
259 259
float MotorControl::rel_to_abs(float rel_speed, int units)
260 260
{
261
    ROS_INFO("Input: %f of units #%d.", rel_speed, units);
262 261
    switch(units)
263 262
    {
264 263
      case MOTOR_ABSOLUTE:/* Speed given as absolute */
scout/libscout/src/behaviors/pause_scout.cpp
27 27

  
28 28
void pause_scout::run()
29 29
{
30
  Duration delay(0.1);
31
  for(int i=0; i < 100; i++)
30
  Duration delay(0.2);
31
  for(int i=0; i < 500; i++)
32 32
  {
33 33
    motors->set_sides(0, 0, MOTOR_ABSOLUTE);
34 34
    delay.sleep();
scout/scoutsim/BehaviorGUI.py
21 21
# ROS functions
22 22
#
23 23
def AddToSimulator(name, x, y, theta):
24
    if name == "":
25
        return False
24 26
    if name in scouts:
25 27
        return False
26 28
    scouts[name] = ""
......
51 53
            return True
52 54
        else:
53 55
            if name in processes:
54
                processes[name].terminate()
56
                subprocess.Popen("rosnode kill /" + name + "_behavior", shell=True)
55 57
                del processes[name]
56
            subprocess.Popen("rosrun libscout libscout " + name + " 0", shell=True) 
58
            processes[name] = subprocess.Popen("rosrun libscout libscout " + name + " 0", shell=True) 
57 59
            print "Scout "+name+" was paused."
58 60
            behaviorButton.SetLabel("Resume")
59 61
            behaviorLabel.SetLabel("  |  Current Behavior: Paused")
60 62
            return True
61 63
    if name in processes:
62
        processes[name].terminate()
64
        subprocess.Popen("rosnode kill /" + name + "_behavior", shell=True)
63 65
        # TODO Running a new behavior while paused does not do anything and
64 66
        # Gives lots of errors.
65 67
    #
......
79 81
        rospy.wait_for_service('/kill')
80 82
        service = rospy.ServiceProxy('/kill', Kill)
81 83
        if name in processes:
82
            processes[name].kill()
84
            subprocess.Popen("rosnode kill /" + name + "_behavior", shell=True)
83 85
            del processes[name]
84 86
        resp = service(name)
85 87
        if name in scouts:
......
226 228
if __name__ == '__main__':
227 229
    ScoutSimGui = subprocess.Popen("rosrun scoutsim scoutsim_node race", shell=True)
228 230
    rospy.wait_for_service('/spawn')
229
    #subprocess.Popen("rosservice call /spawn 1.4 0.275 0 scout1", shell=True)  # why was this here?
230 231
    app = wx.App()
231 232
    GUI(None, title='Colony Scout Manager')
232 233
    app.MainLoop()
233
    # This doesn't run.  I'm sure there is a reason why.
234
    #Figure out how to terminate this for reals.
234 235
    for process in processes:
235
        process.kill()
236
    ScoutSimGui.kill()
236
        process.terminate()
237
    subprocess.Popen("rosnode kill /scoutsim", shell=True)

Also available in: Unified diff