|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
Re: Wondering about GRIP
The GRIP Wiki is located here: https://github.com/WPIRoboticsProjects/GRIP/wiki
|
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
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. |
|
#5
|
||||
|
||||
|
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)
|
|
#6
|
|||
|
|||
|
Re: Wondering about GRIP
Still having these problems
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|