Commits

Trammell Hudson committed e9fdf18

robot_line() works

Comments (0)

Files changed (1)

 
 
 int verbose = 0;
+FILE * logfile;
 
 controller_t *
 controller_create(
 	return controller;
 }
 
+servo_t *
+robot_servo(
+	robot_t * const robot,
+	int i
+)
+{
+	controller_t * const controller = robot->servos[i].controller;
+	if (!controller)
+		return NULL;
+
+	return &controller->servo[robot->servos[i].channel-1];
+}
 
 int
 robot_poll(
 			return -1;
 	}
 
+	const servo_t * s1 = robot_servo(robot, 1);
+	const servo_t * s2 = robot_servo(robot, 2);
+	const servo_t * s3 = robot_servo(robot, 3);
+
+	if (!s1 || !s2 || !s3)
+		return 0;
+
+	fprintf(logfile, "%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
+		s1->position,
+		s1->amps,
+		s1->speed,
+		s2->position,
+		s2->amps,
+		s2->speed,
+		s3->position,
+		s3->amps,
+		s3->speed
+	);
+
 	return 1;
 }
 
 	const double x2 = 300;
 	const double y2 = 300;
 
-	robot_line(robot, x1, y1, x1, y2, 100, 50000);
-	robot_line(robot, x1, y2, x2, y2, 100, 50000);
-	robot_line(robot, x2, y2, x2, y1, 100, 50000);
-	robot_line(robot, x2, y1, x1, y1, 100, 50000);
+	robot_line(robot, x1, y1, x1, y2, 100, 20000);
+	robot_line(robot, x1, y2, x2, y2, 100, 20000);
+	robot_line(robot, x2, y2, x2, y1, 100, 20000);
+	robot_line(robot, x2, y1, x1, y1, 100, 20000);
 
 	return 0;
 }
 	robot->servos[3].scale = -(10500 - -11200) / M_PI;
 	robot->servos[3].length = 260;
 
+	logfile = fopen("/tmp/robot.log", "w");
+	fprintf(logfile, "p1,a1,s1,p2,a2,s2,p3,a3,s3\n");
+
 	for (int i = 1 ; i < argc ; i++)
 	{
 		const char * const device = argv[i];
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.