Go to Post I don't want a carbon copy of your wheels.. I want to improve upon your design. - Tom Bottiglieri [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-01-2011, 01:03
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,043
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Winpdb Remote Debugger ported to RobotPy

Hey, I've been playing with RobotPy quite a bit lately, and one thing you'll probably note is that debugging scripts is a bit annoying. Ok, more than just a bit annoying... haha. Anyways, here's a great solution to solve that problem! Winpdb is a GPL remote debugger that works pretty well from what I can see so far, and gives you full source debugging over the network. I've modified it a bit so that it works on RobotPy. Check it out:

http://www.virtualroadside.com/blog/...py-on-vxworks/

Note: Contrary to its name, Winpdb is cross platform, it just requires wxPython to run.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
Reply With Quote
  #2   Spotlight this post!  
Unread 12-01-2011, 02:04
Slix Slix is offline
Registered User
AKA: Peter Kowalczyk
FRC #2115 (NightMares)
Team Role: Programmer
 
Join Date: Mar 2010
Rookie Year: 2010
Location: Mundelein, IL
Posts: 31
Slix is an unknown quantity at this point
Re: Winpdb Remote Debugger ported to RobotPy

Sounds like this will really help! Unfortunately, I can't try it out on our robot until Monday. D:
Reply With Quote
  #3   Spotlight this post!  
Unread 13-01-2011, 21:11
blakeelias's Avatar
blakeelias blakeelias is offline
2011 CT chairman's award
FRC #0694 (Stuypulse)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: New York
Posts: 26
blakeelias is an unknown quantity at this point
Re: Winpdb Remote Debugger ported to RobotPy

Speaking of debugging, have you found a way to compile and check your scripts *before* running on the robot?

In Java NetBeans would compile our code locally and show where we had syntax errors or improper API calls, but with Python we don't find this out until runtime. This makes it hard to work on code when there is no robot access, since someone's usually working on it mechanically.

So far I can check syntax with:
python3.1 -c "import py_compile; py_compile.compile('robot.py')"

However that does not seem to catch many of the problems we'll run into, like misspelling function names and other common errors.

Any ideas?
Reply With Quote
  #4   Spotlight this post!  
Unread 13-01-2011, 23:52
Peter Johnson Peter Johnson is offline
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 247
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
Re: Winpdb Remote Debugger ported to RobotPy

Quote:
Originally Posted by blakeelias View Post
Speaking of debugging, have you found a way to compile and check your scripts *before* running on the robot?

In Java NetBeans would compile our code locally and show where we had syntax errors or improper API calls, but with Python we don't find this out until runtime. This makes it hard to work on code when there is no robot access, since someone's usually working on it mechanically.

So far I can check syntax with:
python3.1 -c "import py_compile; py_compile.compile('robot.py')"

However that does not seem to catch many of the problems we'll run into, like misspelling function names and other common errors.

Any ideas?
Indeed that's the downside of using a dynamic language.. static analysis is pretty much impossible (look up the halting problem). The long term solution will be a robot simulator (written in Python?) that provides an emulated Python wpilib so you can test your code offline. I've started looking at this but it's a pretty large project (the simulator is hard enough but there's also a LOT of wpilib classes to write emulated versions of).
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
Reply With Quote
  #5   Spotlight this post!  
Unread 14-01-2011, 23:38
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: Winpdb Remote Debugger ported to RobotPy

i have a virtual robot thing half put together

Code:
#This file should emulate enough of wpilib to make it usable for testing
#DONE: use pygame to get joystick inputs from actual joysticks

print("="*40)
print("TESTING.PY LOADED, IF THIS IS ON THE ROBOT CALL SAM *NOW*")
print("NNN NNN NNNN")
print("="*40)

try:
    import pygame
    import pygame.joystick
    pygame.init()
    print(str(pygame.joystick.get_count()) + " Joysticks attatched")
    new = True
except:
    new = False
    print ("NO PYGAME FOUND")
        
def limit(n):
    if n > 1.0:
        return 1.0
    elif n < -1.0:
        return -1.0
    else:
        return n

class Victor:
    def __init__(self, port):
        self.port = port
        print("Virtual Victor set up on port " + str(port))
        self.speed = float()
    
    def Set(self, speed):
        """***FOR TESTING PURPOSES ONLY***
       This "sets" the virtual Victor to any arbitrary speed"""
        speed = limit(speed)
        print("on port " + str(self.port) + " the speed is now " + str(speed))
        self.speed = speed
    
    def Get(self):
        """***FOR TESTING PURPOSES ONLY***
       This emulates the wpilib.Victor.Get function"""
        return self.speed
        
class Joystick_old:
    def __init__(self, port):
        self.port = port
        print("New FAKE joystick set up at port "+str(port))
    
    def GetRawAxis(self, n):
        return float()
    
    def GetRawButton(self, n):
        return False

class Joystick_pygame:
    def __init__(self, port):
        self.port = port -1
        self.joy = pygame.joystick.Joystick(port-1)
        self.joy.init()
        print("made new pygame joystick on port " + str(port))
        print(self.joy.get_name())
        
    def GetRawAxis(self, n):
        pygame.event.pump()
        return self.joy.get_axis(n-1)
    
    def GetRawButton(self, n):
        pygame.event.pump()
        r = self.joy.get_button(n-1)
        if r == 1:
            return True
        else:
            return False

def Joystick(port):
    if new:
        print("trying to use awesomesauce new features")
        try:
            print ("can use awesome features")
            return Joystick_pygame(port)
        except:
            print ("cannot use awesome new features")
            return Joystick_old(port)
    else:
        print ("cannot use awesome new features")
        return Joystick_old(port)

def speedReport(list_obj):
    """Use this for the driver object"""
    for n in list_obj:
        n.Get()
        
def IsDisabled():
    return False   

def IsAutonomous():
    return False

def IsOperatorControl():
    return True
    
def IsEnabled():
    return True

class dummyDog:
    def SetEnabled(self, var):
        pass
    
    def SetExpiration(self, var):
        pass
    
    def Feed(self):
        pass
    
    def Kill(self):
        pass

def GetWatchdog():
    return dummyDog()

def Wait(n):
    pass

class Solenoid:
    def __init__(self, slot, port):
        self.slot = slot
        self.port = port
        print("Solenoid set up on slot " + str(slot) + " port " + str(port))
    
    def Get(self):
        return self.state
    
    def Set(self, state):
        self.state = state
        
        if state:
            print("port " + str(self.port) + " active")
        else:
            print("port " + str(self.port) + " inactive")

class Relay:
    def __init__(self, port):
        self.port = port
        print("Relay set up on port " + str(port))
        self.kForward = 1
        self.kOff     = 2
        self.kReverse = 3
    
    def Get(self):
        pass
    
    def Set(self, value):
        if value == self.kForward:
            print("relay forward")
        elif value == self.kOff:
            print ("relay off")
        elif value == self.kReverse:
            print ("relay backwards")

class Compressor:
    def __init__(self, port1, port2):
        pass
    def Start(self):
        print ("compressor on")
    def Stop(self):
        print ("compressor off")

class SimpleRobot():
    def StartCompetition():
        run_old()
edit:
Wow, i was high when i wrote this, pasted wrong file

Last edited by Robototes2412 : 14-01-2011 at 23:40.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 06:26.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi