Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
test_specific_cases.py
35
36from pytest import approx
37from visp.core import Math, ImagePoint, ColVector, ThetaUVector, Point
39 '''
40 Test that a function that was with signature
41 double lineFitting(const std::vector<...>& imPts, double& a, double& b, double& c)
42 is now (with custom configuration) with a signature lineFitting(imPts) -> tuple[double * 4]
43
44 all the reference parameters are used as outputs but not as inputs
45
46 '''
47 a = 45.0
48 b = 52.0
49 points = [
50 ImagePoint(a*i+b, i) for i in range(3)
51 ]
52 res = Math.lineFitting(points)
53 print(res)
54 values = (res[0], -res[1] / res[2], res[3] / res[2])
55 expected = (0, a, b)
56 for i, (val, exp) in enumerate(zip(values, expected)):
57 print(i)
58 assert val == approx(exp, 0.0001)
59
61 theta = 3.14
62 vec = [0.0, 0.0, 1.0]
63 thetau = ThetaUVector(*[v * theta for v in vec])
64 theta_out, vec_out = thetau.extract()
65 assert theta_out == theta
66 assert vec_out == ColVector(vec)
67
69 values = [0, 1, 2]
70 p = Point(values)
71 vec_ref = ColVector()
72 p.getWorldCoordinates(vec_ref)
73 assert vec_ref == p.getWorldCoordinates()
74