File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed
ros2/TurtlebotController/turtlebot_vel_ctrl/turtlebot_vel_ctrl Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,30 @@ def __init__(self):
26
26
def camData_callback (self ,msg_in ):
27
27
msg_out = Twist ()
28
28
29
- k = 1.0
30
- err_z = msg_in .data
29
+ # no camera data is found. set velocity to zero
30
+ if msg_in .data < - 999.0 :
31
+ msg_out .linear .x = 0.0
32
+ msg_out .linear .y = 0.0
33
+ msg_out .linear .z = 0.0
31
34
32
- ang_input = err_z * k
35
+ msg_out .angular .x = 0.0
36
+ msg_out .angular .y = 0.0
37
+ msg_out .angular .z = 0.0
33
38
34
- msg_out .linear .x = 0.1 #define constant speed
35
- msg_out .linear .y = 0.0
36
- msg_out .linear .z = 0.0
39
+ #1 or both lanes are detected and error is send as usual
40
+ else :
41
+ k = 1.0
42
+ err_z = msg_in .data
37
43
38
- msg_out .angular .x = 0.0
39
- msg_out .angular .y = 0.0
40
- msg_out .angular .z = ang_input
44
+ ang_input = err_z * k
45
+
46
+ msg_out .linear .x = 0.1 #define constant speed
47
+ msg_out .linear .y = 0.0
48
+ msg_out .linear .z = 0.0
49
+
50
+ msg_out .angular .x = 0.0
51
+ msg_out .angular .y = 0.0
52
+ msg_out .angular .z = ang_input
41
53
42
54
self .vel_publisher .publish (msg_out )
43
55
You can’t perform that action at this time.
0 commit comments