Go to Post "C'mon Amanda, this is eating doughnuts, not rocket science." "[Dave Lavery's] better than me at both!" - Amanda Morrison [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 04-02-2016, 20:30
1337WaffleBendr 1337WaffleBendr is offline
Registered User
FRC #5489
 
Join Date: Jan 2016
Location: Twin Falls ID
Posts: 6
1337WaffleBendr is an unknown quantity at this point
Wondering about GRIP

Hi we are new to vision this year, and have gotten GRIP to work for us.
We have gotten GRIP to get, process images, and give us info on network tables. We are at the point that we are ready to integrate GRIP into our code. We are just unsure of a couple of things.

1) How to start GRIP from C++ code.
2) How to get NetworkTables numbers into our code for processing.


Thanks in advance
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2016, 09:14
nollchr nollchr is offline
Registered User
FRC #2170 (Titanium Tomahawks)
Team Role: Mentor
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Glastonbury, CT
Posts: 28
nollchr is an unknown quantity at this point
Re: Wondering about GRIP

The GRIP Wiki is located here: https://github.com/WPIRoboticsProjects/GRIP/wiki
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2016, 20:40
1337WaffleBendr 1337WaffleBendr is offline
Registered User
FRC #5489
 
Join Date: Jan 2016
Location: Twin Falls ID
Posts: 6
1337WaffleBendr is an unknown quantity at this point
Re: Wondering about GRIP

thanks but i have been to the wiki and it is not much help. there is some code but no explanation and i don't know enough to decipher it. if someone will please explain how to do these things too me like i'm five that would be great

Last edited by 1337WaffleBendr : 05-02-2016 at 20:44.
Reply With Quote
  #4   Spotlight this post!  
Unread 05-02-2016, 20:53
nollchr nollchr is offline
Registered User
FRC #2170 (Titanium Tomahawks)
Team Role: Mentor
 
Join Date: Feb 2014
Rookie Year: 2014
Location: Glastonbury, CT
Posts: 28
nollchr is an unknown quantity at this point
Re: Wondering about GRIP

The sample code is spawning a separate process via the fork() function and then executing a command line that is running a separate java grip program in that process.

The other part of the code is getting a subset of the network table containing the contour report and parsing it out.
Reply With Quote
  #5   Spotlight this post!  
Unread 08-02-2016, 20:34
MaikeruKonare's Avatar
MaikeruKonare MaikeruKonare is offline
Programming Division Captain
AKA: Michael Conard
FRC #4237 (Team Lance-a-Bot)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2012
Location: Michigan
Posts: 15
MaikeruKonare is an unknown quantity at this point
Re: Wondering about GRIP

This is the sample code.

Code:
#include <unistd.h>
#include <stdio.h>
#include "WPILib.h"

class MyRobot: public IterativeRobot
{
	std::shared_ptr<NetworkTable> grip;

    const char *JAVA = "/usr/local/frc/JRE/bin/java";

    char *GRIP_ARGS[5] = { "java", "-jar", "/home/lvuser/grip.jar", "/home/lvuser/project.grip", NULL };

public:

	MyRobot():grip(NetworkTable::GetTable("GRIP")){std::cout << "GRIP Test in Constructor" << std::endl;}

    void RobotInit() override {
    	std::cout << "GRIP Test in RobotInit" << std::endl;
        /* Run GRIP in a new process */
        int retval=fork();
        if ( retval == 0) {
        	// in the child process so start Java with the GRIP program
            if (execv(JAVA, GRIP_ARGS) == -1) {
                perror("Error running GRIP in new process");
            }
        }
        // in the parent process
        else if (retval == -1) printf("fork error returned to parent error %d\n", retval);
        else printf("fork okay continuing with parent robot code\n");
    }

    void AutonomousPeriodic() override {
    	std::cout << "GRIP Test in AutonomousPeriodoc" << std::endl;

    	double init[3];init[0]=2.3; init[1]=3.4;init[2]=4.5;

    	while(true){
    		/* Get published values from GRIP using NetworkTables */

    		auto areas = grip->GetNumberArray("MyTargetTable/area", llvm::ArrayRef<double>());
    		for (auto area : areas) {
    			std::cout << "Got contour with area=" << area << std::endl;
    		}

    		auto blobsx = grip->GetNumberArray("myBlobsReport/x", init /*llvm::ArrayRef<double>()*/);
    		for (auto blob : blobsx) {
    			std::cout << "Got blob with x=" << blob << std::endl;
    		}

    		auto blobsy = grip->GetNumberArray("myBlobsReport/y", init /*llvm::ArrayRef<double>()*/);
    		for (auto blob : blobsy) {
    			std::cout << "Got blob with y=" << blob << std::endl;
    		}

    		auto blobssize = grip->GetNumberArray("myBlobsReport/size", init /*llvm::ArrayRef<double>()*/);
    		for (auto blob : blobssize) {
    			std::cout << "Got blob with size=" << blob << std::endl;
    		}
    	}
   }
};

START_ROBOT_CLASS(MyRobot)
If you're still having issues, the author of Grip has an account on ChiefDelphi. He will find you eventually and give you his pro advice.
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2016, 20:41
1337WaffleBendr 1337WaffleBendr is offline
Registered User
FRC #5489
 
Join Date: Jan 2016
Location: Twin Falls ID
Posts: 6
1337WaffleBendr is an unknown quantity at this point
Re: Wondering about GRIP

Still having these problems
Reply With Quote
  #7   Spotlight this post!  
Unread 13-02-2016, 02:58
ThomasClark's Avatar
ThomasClark ThomasClark is offline
Registered User
FRC #0237
 
Join Date: Dec 2012
Location: Watertown, CT
Posts: 146
ThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud ofThomasClark has much to be proud of
Re: Wondering about GRIP

Quote:
Originally Posted by 1337WaffleBendr View Post
Still having these problems
Could you explain what these problems are? There's sample code for both of your questions here, but if there are any questions you have about it, I can answer them.
__________________
GRIP (Graphically Represented Image Processing) - rapidly develop computer vision algorithms for FRC
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 12:15.

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