blob: ad1d6b60a5ca0c05408f5d7adf808daa8b9409fe [file] [log] [blame]
Philipp Schrader790cb542023-07-05 21:06:52 -07001#include <math.h>
Jim Ostrowskiba2edd12022-12-03 15:44:37 -08002
3#include "Eigen/Dense"
Philipp Schrader790cb542023-07-05 21:06:52 -07004#include "glog/logging.h"
Jim Ostrowskiba2edd12022-12-03 15:44:37 -08005#include <opencv2/aruco.hpp>
6#include <opencv2/aruco/charuco.hpp>
7#include <opencv2/calib3d.hpp>
8#include <opencv2/core/eigen.hpp>
9#include <opencv2/highgui/highgui.hpp>
10#include <opencv2/imgproc.hpp>
Philipp Schrader790cb542023-07-05 21:06:52 -070011
12#include "aos/init.h"
13#include "aos/logging/logging.h"
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080014#include "aos/time/time.h"
Philipp Schrader790cb542023-07-05 21:06:52 -070015#include "frc971/vision/visualize_robot.h"
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080016
Stephan Pleinesf63bde82024-01-13 15:59:33 -080017namespace frc971::vision {
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080018
19// Show / test the basics of visualizing the robot frames
20void Main(int /*argc*/, char ** /* argv */) {
21 VisualizeRobot vis_robot;
22
23 int image_width = 500;
24 cv::Mat image_mat =
25 cv::Mat::zeros(cv::Size(image_width, image_width), CV_8UC3);
26 vis_robot.SetImage(image_mat);
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080027 double focal_length = 1000.0;
Jim Ostrowski49be8232023-03-23 01:00:14 -070028 vis_robot.SetDefaultViewpoint(image_width, focal_length);
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080029
30 // Go around the clock and plot the coordinate frame at different rotations
31 for (int i = 0; i < 12; i++) {
32 double angle = M_PI * double(i) / 6.0;
33 Eigen::Vector3d trans;
34 trans << 1.0 * cos(angle), 1.0 * sin(angle), 0.0;
35
Jim Ostrowski49be8232023-03-23 01:00:14 -070036 Eigen::Affine3d offset_rotate_origin =
37 Eigen::Translation3d(trans) *
38 Eigen::AngleAxisd(angle, Eigen::Vector3d::UnitX());
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080039
40 vis_robot.DrawFrameAxes(offset_rotate_origin, std::to_string(i));
41 }
42
43 // Display the result
44 cv::imshow("Display", image_mat);
45 cv::waitKey();
46}
Stephan Pleinesf63bde82024-01-13 15:59:33 -080047} // namespace frc971::vision
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080048
49int main(int argc, char **argv) {
50 aos::InitGoogle(&argc, &argv);
51
52 frc971::vision::Main(argc, argv);
53}