File tree Expand file tree Collapse file tree 5 files changed +96
-5
lines changed Expand file tree Collapse file tree 5 files changed +96
-5
lines changed Original file line number Diff line number Diff line change 3
3
# typegeneration.jl must be run first
4
4
5
5
using geometry_msgs. msg
6
- init_node (" jltest" , anonymous= true )
7
- const t0 = to_nsec (get_rostime ())
8
6
9
7
const Nmsgs = 10
10
8
const rate = 20. # Hz
11
9
const msgs = PoseStamped[]
12
10
const refs = Array (Vector3, Nmsgs)
11
+ const t0 = to_nsec (get_rostime ())
13
12
14
13
for i= 1 : Nmsgs
15
14
refs[i] = Vector3 (rand (3 )... )
Original file line number Diff line number Diff line change
1
+ # Test basic rospy interactions
2
+ init_node (" jltest" , anonymous= true )
3
+
4
+ # Parameters
5
+ @test length (RobotOS. get_param_names ()) > 0
6
+ @test has_param (" rosdistro" )
7
+ @test chomp (get_param (" rosdistro" )) in [" hydro" , " indigo" , " jade" ]
8
+ @test ! has_param (" some_param" )
9
+ @test_throws KeyError get_param (" some_param" )
10
+ @test_throws KeyError delete_param (" some_param" )
11
+ @test get_param (" some_param" , 1.1 ) == 1.1
12
+ @test get_param (" some_param" , " some_val" ) == " some_val"
13
+ set_param (" some_param" , " val" )
14
+ @test get_param (" some_param" , 1.1 ) == " val"
15
+ delete_param (" some_param" )
16
+ @test ! has_param (" some_param" )
17
+
18
+ # Really just running this stuff for coverage
19
+
20
+ # Logging
21
+ logdebug (" %s" , " debug" )
22
+ loginfo (" %s" , " info" )
23
+ logwarn (" %s" , " warn" )
24
+ logerr (" %s" , " err" )
25
+ logfatal (" %s" , " fatal" )
26
+ @test ! is_shutdown ()
27
+
28
+ # Generic stuff
29
+ @test startswith (RobotOS. get_name ()[2 : end ], " jltest" )
30
+ @test RobotOS. get_namespace () == " /"
31
+ RobotOS. get_node_uri ()
32
+ RobotOS. get_caller_id ()
33
+ RobotOS. get_published_topics ()
34
+ RobotOS. get_ros_root ()
Original file line number Diff line number Diff line change 1
1
using Base. Test
2
2
using RobotOS
3
+ using Compat
3
4
RobotOS. debug (true )
4
5
6
+ # Generally, later tests rely on things defined in previous tests, so the order
7
+ # is important
8
+ include (" rospy.jl" )
5
9
include (" time.jl" )
6
10
include (" typegeneration.jl" )
7
11
include (" pubsub.jl" )
Original file line number Diff line number Diff line change 1
- # typegeneration.jl and pubsub.jl must be run first
1
+ # pubsub.jl must be run first
2
2
3
3
using std_srvs. srv
4
4
using nav_msgs. srv
@@ -24,8 +24,8 @@ function srv_cb(req::GetPlanRequest)
24
24
return resp
25
25
end
26
26
27
- const srvcall = ServiceProxy {Empty} (" callme" )
28
- const srvlisten = Service {GetPlan} (" getplan" , srv_cb)
27
+ const srvcall = ServiceProxy (" callme" , Empty )
28
+ const srvlisten = Service (" getplan" , GetPlan , srv_cb)
29
29
30
30
# Call echo's Empty service
31
31
println (" Waiting for 'callme' service..." )
@@ -49,3 +49,7 @@ if flag[1]
49
49
@test_approx_eq (msgs[i]. pose. position. z, i)
50
50
end
51
51
end
52
+
53
+ # Test error handling
54
+ @test_throws ErrorException wait_for_service (" fake_srv" , timeout= 1.0 )
55
+ @test_throws ArgumentError call (srvcall, EmptyResponse ())
Original file line number Diff line number Diff line change @@ -8,14 +8,64 @@ d3 = Duration(0, 1)
8
8
@test t1 == Time (1 ,0 )
9
9
@test t1 != t2
10
10
@test t1 > t2
11
+ @test t1 >= t2
12
+ @test t2 < t1
13
+ @test t2 <= t1
11
14
12
15
@test d1 == Duration (0 , 999_999_999 )
13
16
@test d1 != d2
14
17
@test d1 < d2
18
+ @test d1 <= d2
19
+ @test d2 > d1
20
+ @test d2 >= d1
15
21
16
22
@test t1 + d2 == t3
17
23
@test t2 + d3 == t1
18
24
@test t1 - t2 == d3
19
25
@test t1 - d3 == t2
20
26
@test d1 + d2 + d3 == Duration (t3. secs, t3. nsecs)
21
27
@test d2 - d1 - d3 == Duration (0 , 500_000_000 )
28
+
29
+ tt = Time ()
30
+ tt. secs = 2
31
+ @test tt == Time (2.0 )
32
+ @test convert (Float64,tt) == 2.0
33
+ @test to_sec (tt) == 2.0
34
+ @test to_nsec (tt) == 2_000_000_000
35
+
36
+ dt = Duration ()
37
+ dt. secs = 3
38
+ @test dt == Duration (3.0 )
39
+ @test convert (Float64,dt) == 3.0
40
+ @test to_sec (dt) == 3.0
41
+ @test to_nsec (dt) == 3_000_000_000
42
+
43
+ @test tt + dt == Time (5.0 )
44
+ @test dt + dt == Duration (6.0 )
45
+
46
+ t1 = get_rostime ()
47
+ rossleep (0.5 )
48
+ t2 = get_rostime ()
49
+ @test t2 - t1 >= Duration (0.4 )
50
+
51
+ rte = Rate (Duration (0.5 ))
52
+ rossleep (rte)
53
+ t1 = RobotOS. now ()
54
+ rossleep (rte)
55
+ t2 = RobotOS. now ()
56
+ rossleep (rte)
57
+ t3 = RobotOS. now ()
58
+ @test t2 - t1 >= Duration (0.4 )
59
+ @test t3 - t2 >= Duration (0.4 )
60
+ @test t3 - t1 >= Duration (0.8 )
61
+
62
+ t1 = get_rostime ()
63
+ RobotOS. sleep (0.5 )
64
+ t2 = get_rostime ()
65
+ @test t2 - t1 >= Duration (0.4 )
66
+
67
+ RobotOS. sleep (rte)
68
+ t1 = get_rostime ()
69
+ RobotOS. sleep (rte)
70
+ t2 = get_rostime ()
71
+ @test t2 - t1 >= Duration (0.4 )
You can’t perform that action at this time.
0 commit comments