Piling on, here is a file that I think is correct (I am not sure I have the rotations correct, really appreciate gentle correction if in order).
West wall is the blue alliance station, origin is SW corner.
- target 1 is on the west wall, 1 meter north of origin, 1 meter up from floor, facing center of field (facing east)
- target 2 is on the west wall, 2 meters north of origin, 2 meters up from floor, facing center of field (facing east)
- target 11 is on the south wall, 1 meter east of origin, 1 meter up from floor, facing center of field (facing north)
- target 12 is on the south wall, 2 meters north of origin, 2 meters up from floor, facing center of field (facing north)
This is magic incantation:
import java.io.*;
import java.util.*;
import org.junit.Test;
import edu.wpi.first.math.geometry.*;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.apriltag.*;
public class TestGenerateJsonForTagtrackerDevelopers {
@Test
public void t00() throws IOException {
AprilTagFieldLayout a = getAprilTagFieldLayout();
a.serialize ("test_apriltags.json");
}
static Rotation3d r3d_westwall = new Rotation3d(0, Units.degreesToRadians(-90), 0);
static Rotation3d r3d_southwall = new Rotation3d(0, Units.degreesToRadians(-90), Units.degreesToRadians(-90));
static AprilTagFieldLayout getAprilTagFieldLayout() {
List<AprilTag> rv = new ArrayList<>();
rv.add (new AprilTag(1, new Pose3d (0, 1.0, 1.0, r3d_westwall)));
rv.add (new AprilTag(2, new Pose3d (0, 2.0, 2.0, r3d_westwall)));
rv.add (new AprilTag(11, new Pose3d (1.0, 0.0, 1.0, r3d_southwall)));
rv.add (new AprilTag(12, new Pose3d (2.0, 0.0, 2.0, r3d_southwall)));
return new AprilTagFieldLayout(rv, 20.0, 10.0);
}
}
…and this is the (formatted) result…
{
"tags": [
{
"ID": 1,
"pose": {
"translation": {
"x": 0.0,
"y": 1.0,
"z": 1.0
},
"rotation": {
"quaternion": {
"W": 0.7071067811865476,
"X": 0.0,
"Y": -0.7071067811865475,
"Z": 0.0
}
}
}
},
{
"ID": 2,
"pose": {
"translation": {
"x": 0.0,
"y": 2.0,
"z": 2.0
},
"rotation": {
"quaternion": {
"W": 0.7071067811865476,
"X": 0.0,
"Y": -0.7071067811865475,
"Z": 0.0
}
}
}
},
{
"ID": 11,
"pose": {
"translation": {
"x": 1.0,
"y": 0.0,
"z": 1.0
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": -0.4999999999999999,
"Y": -0.5,
"Z": -0.5
}
}
}
},
{
"ID": 12,
"pose": {
"translation": {
"x": 2.0,
"y": 0.0,
"z": 2.0
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": -0.4999999999999999,
"Y": -0.5,
"Z": -0.5
}
}
}
}
],
"field": {
"width": 20.0,
"height": 10.0
}
}