blob: 6e15f2fbda7261cb6763bfe49e05c58cc84b93fa [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"
Austin Schuh99f7c6a2024-06-25 22:07:44 -07004#include "absl/log/check.h"
5#include "absl/log/log.h"
Jim Ostrowskiba2edd12022-12-03 15:44:37 -08006#include <opencv2/aruco.hpp>
7#include <opencv2/aruco/charuco.hpp>
8#include <opencv2/calib3d.hpp>
9#include <opencv2/core/eigen.hpp>
10#include <opencv2/highgui/highgui.hpp>
11#include <opencv2/imgproc.hpp>
Philipp Schrader790cb542023-07-05 21:06:52 -070012
13#include "aos/init.h"
14#include "aos/logging/logging.h"
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080015#include "aos/time/time.h"
Philipp Schrader790cb542023-07-05 21:06:52 -070016#include "frc971/vision/visualize_robot.h"
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080017
Stephan Pleinesf63bde82024-01-13 15:59:33 -080018namespace frc971::vision {
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080019
20// Show / test the basics of visualizing the robot frames
21void Main(int /*argc*/, char ** /* argv */) {
22 VisualizeRobot vis_robot;
23
24 int image_width = 500;
25 cv::Mat image_mat =
26 cv::Mat::zeros(cv::Size(image_width, image_width), CV_8UC3);
27 vis_robot.SetImage(image_mat);
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080028 double focal_length = 1000.0;
Jim Ostrowski49be8232023-03-23 01:00:14 -070029 vis_robot.SetDefaultViewpoint(image_width, focal_length);
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080030
31 // Go around the clock and plot the coordinate frame at different rotations
32 for (int i = 0; i < 12; i++) {
33 double angle = M_PI * double(i) / 6.0;
34 Eigen::Vector3d trans;
35 trans << 1.0 * cos(angle), 1.0 * sin(angle), 0.0;
36
Jim Ostrowski49be8232023-03-23 01:00:14 -070037 Eigen::Affine3d offset_rotate_origin =
38 Eigen::Translation3d(trans) *
39 Eigen::AngleAxisd(angle, Eigen::Vector3d::UnitX());
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080040
41 vis_robot.DrawFrameAxes(offset_rotate_origin, std::to_string(i));
42 }
43
44 // Display the result
45 cv::imshow("Display", image_mat);
46 cv::waitKey();
47}
Stephan Pleinesf63bde82024-01-13 15:59:33 -080048} // namespace frc971::vision
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080049
50int main(int argc, char **argv) {
51 aos::InitGoogle(&argc, &argv);
52
53 frc971::vision::Main(argc, argv);
54}