working on it ...

Filters

Explore Public Snippets

Sort by

Found 1,646 snippets matching: robot

    public by emsity modified Jul 1, 2014  262604  2  6  0

    PHP script to call Python robot arm command

    HTML call PHP to execute python command
    <?php
    exec( " sudo python /home/pi/arm/baseanti.py &"  );
    
    /* Redirect browser */
    $gohere = "http://192.168.169.15/index3G.html";
    header("Location: $gohere");
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    ?>
    

    public by emsity modified Jul 5, 2014  2924  3  6  0

    Python script to drive robot arm using MySql Database

    Reads MySql database (db=action, table=arm) to drive arm using pre-determined codes.
    # import the USB and Time libraries into Python 
    import usb.core, usb.util, time, MySQLdb
    
    #Obtain sys from PHP 
    #import sys
    
    #Open connection to the action database (action/ arm table)
    db = MySQLdb.connect("localhost", "your_name", "your_password", "action")
    db.autocommit(True)
    cursor = db.cursor()
    
    
    #Allocate the name 'RoboArm' to the USB device
    RoboArm=usb.core.find(idVendor=0x1267,idProduct=0x0000)
    
    #Check if the arm is detected and warn if not found
    if RoboArm is None:
    	raise ValueError("Arm not found")
    
    
    #Define a procedure to execute each movement
    def MoveArm(Duration,ArmCmd):
    	#Start the movement
    	RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    	#Stop the movement after waiting specified duration
    	time.sleep(Duration)
    	ArmCmd=[0,0,0]
    	RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    
    #get the data from arm table 
    cursor.execute ("SELECT * FROM arm where Status='0' ")
    print cursor.rowcount
    
    data = cursor.fetchall()
    for row in data:
         ID = row[0]
         Duration = row[1]
         Direction = row[2]
         Status = row[3]
         print ID, Duration, Direction, Status
         Code = Direction
         
    #Code is obtained from the 'Direction' field in the MySql arm table
    #Duration is obtained from the 'Duration' field in the arm table
    
         if Code==1:
    	ArmCmd=[2,0,0] 
    	print "grip open"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    
    		
         elif Code==2:
    	ArmCmd=[1,0,0]
    	print "grip close"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    
    
         elif Code==3:
    	ArmCmd=[0,0,1]
    	print "light on"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
     
    
         elif Code==4:
    	ArmCmd=[0,0,0]
    	print "light off"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    
    
         elif Code==5:
    	ArmCmd=[0,1,0]
    	print "clockwise"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    
         elif Code==6:
    	ArmCmd=[0,2,0]
    	print "anti clockwise"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    
         elif Code==7:
    	ArmCmd=[128,0,0]
    	print "shoulder up"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    
         elif Code==8:
    	ArmCmd=[64,0,0]
    	print "shoulder down"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    
         elif Code==9:
    	ArmCmd=[16,0,0]
    	print "elbow up"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET Status='1' ")
            print ID, Duration, Direction, Status
    
    
         elif Code==10:
    	ArmCmd=[32,0,0]
    	print "elbow down"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET Status='1' ")
            print ID, Duration, Direction, Status
    
    
         elif Code==11:
    	ArmCmd=[4,0,0]
    	print "wrist up"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    
         elif Code==12:
    	ArmCmd=[8,0,0]
    	print "wrist down"
            MoveArm(Duration,ArmCmd)
            cursor.execute ("UPDATE arm SET status='1' ")
            print ID, Duration, Direction, Status
    	
    else:
     Duration=1	
     ArmCmd=[0,0,0]
     print "exit" # Exit   
     MoveArm(Duration,ArmCmd)
    
    exit
    
    
    

    public by emsity modified Jun 27, 2014  2793  2  6  1

    Code to drive robot arm - demo number 3

    This code sends multiple simultaneous commands.
    #!/usr/bin/python2 -u   
    
    print("Content-type: text/html\n")
    print("Arm script running");
    
    # import the USB and Time libraries into Python 
    import usb.core, usb.util, time
    
    #Allocate the name 'RoboArm' to the USB device
    RoboArm=usb.core.find(idVendor=0x1267,idProduct=0x0000)
    
    #Check if the arm is detected and warn if not found
    if RoboArm is None:
    	print("Arm Not Found")
    	raise ValueError("Arm not found")
    
    #Create a variable for duration
    	
    #Define a procedure to execute each movement
    def MoveArm(Duration, ArmCmd):
    	#Start the movement
    	RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    	
    	#Stop the movement after waiting specified duration
    	time.sleep(Duration)
    	ArmCmd=[0,0,0]
    	RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    
    #Give the arm some commands
    
    
    MoveArm(4, [32,1,0])
    MoveArm(4, [80,2,0]) 
    MoveArm(2, [32,2,0])
    MoveArm(2, [18,2,0])
    MoveArm(2, [17,2,0])
    MoveArm(2, [18,1,1])
    MoveArm(2, [128,1,1])
    MoveArm(2, [161,2,0])
    
    
    #MoveArm(1,[0,1,0]) # Rotate Base Anti-clockwise
    #MoveArm(1,[0,2,0]) # Rotate Base Clockwise
    #MoveArm(1,[64,0,0]) # Shoulder Down
    #MoveArm(1,[128,0,0]) # Shoulder Up
    #MoveArm(1,[16,0,0]) # Elbow Up
    #MoveArm(1,[32,0,0]) # Elbow Down
    #MoveArm(1,[4,0,0]) #  Wrist Up
    #MoveArm(1,[8,0,0]) # Wrist Down
    #MoveArm(1,[2,0,0]) # Grip Open
    #MoveArm(1,[1,0,0]) # Grip Close
    #MoveArm(1,[0,0,1]) # Light On
    #MoveArm(1,[0,0,0]) # Light Off
    
    
    print("Script complete!")
    

    public by emsity modified Jul 5, 2014  2024  2  6  2

    PHP to read the robot arm MySql and to run the arm Python Script

    Reads arm table and can pass the data to Python
    
    <?php
    // Create Connection
    $con=mysqli_connect("localhost","my_name","my_password","action");
    
    //Check connection
    if (mysqli_connect_errno()) {
      echo "failed to connect to mysql: " . mysqli_connect_error();
    }
    
    // escape variables for security
    $id = mysqli_real_escape_string($con, $_POST['id']);
    $duration = mysqli_real_escape_string($con, $_POST['duration']);
    $direction = mysqli_real_escape_string($con, $_POST['direction']);
    $status = mysqli_real_escape_string($con, $_POST['status']);
    
    $result = mysqli_query($con,"SELECT * FROM arm where status='0'");
    
    echo "<table border='1'>
    <tr>
    <th>_Id_</th>
    <th>Duration</th>
    <th>Direction</th>
    <th>Status</th>
    </tr>";
    
    while($row = mysqli_fetch_array($result))
    {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['duration'] . "</td>";
    echo "<td>" . $row['direction'] . "</td>";
    echo "<td>" . $row['status'] . "</td>";
    echo "</tr>";
    }
    echo "</table>";
    
    mysqli_close($con);
    
    ?>
    
    <htlm>
    <form action="/cgi-bin/run_mymove.php" method="get">
    Run:<input type="hidden" name="run">
    <input type="submit">
    </form>
    </html>

    public by emsity modified Jun 29, 2014  1351  11  6  0

    Simple Robot Arm code in Python

    The basic arm commands for Raspberry Pi and Maplins arm (www.emsity.com)
    # import the USB and Time libraries into Python 
    import usb.core, usb.util, time
    
    #Allocate the name 'RoboArm' to the USB device
    RoboArm=usb.core.find(idVendor=0x1267,idProduct=0x0000)
    
    #Check if the arm is detected and warn if not found
    if RoboArm is None:
    	raise ValueError("Arm not found")
    
    #Define a procedure to execute each movement
    def MoveArm(Duration, ArmCmd):
    	#Start the movement
    	RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    	#Stop the movement after waiting specified duration
    	time.sleep(Duration)
    	ArmCmd=[0,0,0]
    	RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    
    #Give the arm some commands
    
    MoveArm(1,[0,2,0]) # Rotate Base Anti-Clockwise
    
    #MoveArm(1,[0,1,0]) # Rotate Base Clockwise
    #MoveArm(1,[0,2,0]) # Rotate Base Anti-Clockwise
    #MoveArm(1,[64,0,0]) # Shoulder Up
    #MoveArm(1,[128,0,0]) # Shoulder Down
    #MoveArm(1,[16,0,0]) # Elbow Up
    #MoveArm(1,[32,0,0]) # Elbow Down
    #MoveArm(1,[4,0,0]) #  Wrist Up
    #MoveArm(1,[8,0,0]) # Wrist Down
    #MoveArm(1,[2,0,0]) # Grip Open
    #MoveArm(1,[1,0,0]) # Grip Close
    #MoveArm(1,[0,0,1]) # Light On
    #MoveArm(1,[0,0,0]) # Light Off

    public by emsity modified Jul 5, 2014  1798  1  6  1

    PHP script to insert data into robot arm MySql

    Passes Direction and Duration to a MySql table (arm) for Python to read
    <?php
    // Create Connection
    $con=mysqli_connect("localhost","my_name","my_password","action");
    
    //Check connection
    if (mysqli_connect_errno()) {
      echo "failed to connect to mysql: " . mysqli_connect_error();
    }
    
    // escape variables for security
    $id = mysqli_real_escape_string($con, $_POST['id']);
    $duration = mysqli_real_escape_string($con, $_POST['duration']);
    $direction = mysqli_real_escape_string($con, $_POST['direction']);
    $status = mysqli_real_escape_string($con, $_POST['status']);
    
    $sql="INSERT INTO arm (id, duration, direction, status)
    VALUES ('$id', '$duration', '$direction', '$status')";
    
    if (!mysqli_query($con,$sql)) {
      die('Error: ' . mysqli_error($con));
    }
    
    mysqli_close($con);	
    
    /* Redirect browser */
    $gohere = "http://192.168.169.15/myarm.html";
    header("Location: $gohere");
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    
    ?>

    public by emsity modified Jun 29, 2014  1764  1  5  0

    Python script takes data from the PHP script to drive the robot arm

    Uses 'import sys' to receive the arguments from the PHP of action code (what to do) and duration (how long for). www.emsity.com
    # import the USB and Time libraries into Python 
    import usb.core, usb.util, time
    
    #Obtain sys from PHP 
    import sys
    
    #Allocate the name 'RoboArm' to the USB device
    RoboArm=usb.core.find(idVendor=0x1267,idProduct=0x0000)
    
    #Check if the arm is detected and warn if not found
    if RoboArm is None:
    	raise ValueError("Arm not found")
    
    
    #Define a procedure to execute each movement
    def MoveArm(Duration,ArmCmd):
    	#Start the movement
    	RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    	#Stop the movement after waiting specified duration
    	time.sleep(Duration)
    	ArmCmd=[0,0,0]
    	RoboArm.ctrl_transfer(0x40,6,0x100,0,ArmCmd,1000)
    
    
    Code = 0
    
    #Create a variable for duration from PHP
    
    while Code < 9:
    
    #Create a variable for duration
    	xString = sys.argv[1]
    	Duration = int(xString)
    
    #Create a variable for command code
    	yString = sys.argv[2]
    	Code = int(yString)
    
    #Move arm anti if code is 1 
    
    	if Code==1:
    		ArmCmd=[2,0,0] 
    		print "grip open"
    		
    	elif Code==2:
    		ArmCmd=[1,0,0]
    		print "grip close"
    
    	elif Code==3:
    		ArmCmd=[0,0,1]
    		print "light on"
    
    	elif Code==4:
    		ArmCmd=[0,0,0]
    		print "light off"
    
    	elif Code==5:
    		ArmCmd=[0,1,0]
    		print "clockwise"
    
    	elif Code==6:
    		ArmCmd=[0,2,0]
    		print "anti clockwise"
    
    	elif Code==7:
    		ArmCmd=[128,0,0]
    		print "shoulder up"
    
    	elif Code==8:
    		ArmCmd=[64,0,0]
    		print "shoulder down"
    
    	elif Code==9:
    		ArmCmd=[16,0,0]
    		print "elbow up"
    
    	elif Code==10:
    		ArmCmd=[32,0,0]
    		print "elbow down"
    
    	elif Code==11:
    		ArmCmd=[4,0,0]
    		print "wrist up"
    
    	elif Code==12:
    		ArmCmd=[8,0,0]
    		print "wrist down"
    	else:
    		ArmCmd=[0,0,0]
    		print "exit" # Exit
    	
    
    	MoveArm(Duration,ArmCmd)
    	exit(3)
    
    #MoveArm(1,[0,1,0]) # Rotate Base Anti-clockwise
    #MoveArm(1,[0,2,0]) # Rotate Base Clockwise
    #MoveArm(1,[64,0,0]) # Shoulder Up
    #MoveArm(1,[128,0,0]) # Shoulder Down
    #MoveArm(1,[16,0,0]) # Elbow Up
    #MoveArm(1,[32,0,0]) # Elbow Down
    #MoveArm(1,[4,0,0]) #  Wrist Up
    #MoveArm(1,[8,0,0]) # Wrist Down
    #MoveArm(1,[2,0,0]) # Grip Open
    #MoveArm(1,[1,0,0]) # Grip Close
    #MoveArm(1,[0,0,1]) # Light On
    #MoveArm(1,[0,0,0]) # Light Off
    
    

    public by rlafranchi modified Jul 29, 2016  101  0  2  0

    Mr. Robot Season 2 easter egg website email alert cronjob

    Mr. Robot Season 2 easter egg website email alert cronjob: watchRobot.cron.php
    <?php
    ini_set('max_execution_time', 300);
    /**
     * Mr. Robot Season 2 easter egg website email alert cronjob
     * (Note: requires your PHP to be able to send emails (of course)!)
     *
     * 1. Download this script. Browser download: https://gist.github.com/eyecatchup/f5f5929f57b22fc1b37ef516d675ac92/download/
     *    Or, for the console users:
     * # wget --no-check-certificate https://gist.github.com/eyecatchup/f5f5929f57b22fc1b37ef516d675ac92/raw/watchRobot.cron.php
     *
     * 2. Set the value for the variable $notifyEmailAddress to your email address.
     *
     * 3. Create a new cronjob (for a Windows Xampp stack alternative see: http://stackoverflow.com/a/4231634/624466).
     *    On your console, type:
     * # crontab -e
     *
     * 4. Paste the following (adjust script/logfile path):
     * 0 * * * * php /absolute/path/to/script.php >> /absolute/path/to/cronjob.log
     *
     * Exit crontab and you're all set. You'll get an email as soon as there's a new Mr. Robot EE site to checkout.
     */
    
    /**
     * CHANGE THIS TO YOUR EMAIL ADDRESS !!!
     */
    $notifyEmailAddress = 'eyecatchup@gmail.com';
    
    /**
     * NO NEED FOR CHANGES BELOW
     */
    $base = '192.251.68.';
    $bits = range(241, 248);
    array_push($bits, 252);
    
    function getHttpResponse($url) {
        $ch = curl_init($url);
        curl_setopt_array($ch, array(
            CURLOPT_RETURNTRANSFER  => 1,
            CURLOPT_CONNECTTIMEOUT  => 30,
            CURLOPT_FOLLOWLOCATION  => 1,
            CURLOPT_MAXREDIRS       => 3,
            CURLOPT_SSL_VERIFYPEER  => 0,
        ));
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        return 200 == (int)$httpCode ? $response : false;
    }
    
    foreach ($bits as $bit) {
        $addr = $base . $bit;
        $resp = getHttpResponse($addr);
    
        if ($resp && trim($resp) !== sprintf('i%d.bxjyb2jvda.net', $bit)) {
            $msg = 'Strike! A new Mr. Robot easter egg site is online: ' . $addr;
            mail($notifyEmailAddress, 'Mr. Robot Easter Egg Website Alert', $msg);
            echo $msg . PHP_EOL;
        }
    }
    
    
    

    public by eyecatchup modified Jul 12, 2016  196  1  2  0

    A collection of "Mr. Robot" Season 2 Easter Egg Sites. #mrrobot #hackingrobot #robotegg

    A collection of "Mr. Robot" Season 2 Easter Egg Sites. #mrrobot #hackingrobot #robotegg: mr.robot_season-2_easter-egg-sites.md
    # Mr. Robot Season 2 Easter Egg Sites
    
    ### 1. Ransomware webpage
    
    - Page Name: `AdobeTracking.pageName = 'Mr. Robot : S2 Easter Egg Sites : Ransomware : Home';`
    - URL: http://i239.bxjyb2jvda.net/  
    - JS: http://i239.bxjyb2jvda.net/web_analytics.js
    - Credit: https://0x41.no/mr-robot-s02e01-easter-egg/  
    
    On load, this page displays a countdown timer starting at 24:00:00. When time is over, the following "hidden" message is revealed:
    
    > I sincerely believe that banking establishments are more dangerous than standing armies, and that the principle of spending money to be paid by posterity, under the name of funding, is but swindling futurity on a large scale.  
    > – Thomas Jefferson
    
    ### 2. _E Corp_ maintenance page
    
    - Page Name: `AdobeTracking.pageName = 'Mr. Robot : S2 Easter Egg Sites : E Corp : Maintenance';`
    - URL: http://www.e-corp-usa.com/
    
    Maintenance page for the fictive E Corp webpage. Opposite of the Evil Corp version.
    
    ### 3. _Evil Corp_ maintenance page
    
    - Page Name: `AdobeTracking.pageName = 'Mr. Robot : S2 Easter Egg Sites : Evil Corp : Maintenance';`
    - URL: http://www.evil-corp-usa.com/ 
    
    Maintenance page for the fictive Evil Corp webpage. Opposite of the E Corp version.
    
    A subdomain of the evil corp site is shown in a S2 trailer on Facebook, when Elliot connects as follows:  
    ```sh 
    ssh -l root bkuw300ps345672-cs30.serverfarm.evil-corp-usa.com
    ```
    
    ### 4. _Confictura Industries_ webpage
    
    - Page Name: `AdobeTracking.pageName = 'Mr. Robot : S2 Easter Egg Sites : Confictura Industries : Home';`
    - URL: http://www.conficturaindustries.com/
    - JS: http://www.conficturaindustries.com/js/webmaster_analytics.js
    - Email: webmaster@conficturaindustries.com  
    
    GIF-bloated 90's "Under construction" webpage. Nothing special here (afaik).  
    
    ### 5. Others
    
    - [Who is Mr. Robot : 420 Hidden Image](http://www.whoismrrobot.com/images/420/420.jpg)
    - [Who is Mr. Robot : July 4th Hidden Image](http://www.whoismrrobot.com/images/independence/independence.gif)  
     
    
    

    public by AysadKozanoglu modified Apr 29, 2016  940  7  3  0

    nginx configuration file, (do not log robots.txt and favicon.ico requests)

    nginx configuration file, (do not log robots.txt and favicon.ico requests): do_not_log.conf
    # Designed to be included in any server {} block.
    location = /favicon.ico {
    	log_not_found off;
    	access_log off;
    }
    
    location = /robots.txt {
    	allow all;
    	log_not_found off;
    	access_log off;
    }
    
    
    
    • Public Snippets
    • Channels Snippets