Skip to content

Commit 0b851a1

Browse files
committed
restructured the repository
1 parent cfeb896 commit 0b851a1

File tree

103 files changed

+611
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+611
-11
lines changed

README.md

Lines changed: 11 additions & 5 deletions

controller_plugin/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

cpp/README.md

Lines changed: 1 addition & 0 deletions

cpp/controller_plugin/README.md

Lines changed: 9 additions & 0 deletions
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

cpp/tracker_plugin/README.md

Lines changed: 9 additions & 0 deletions
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

waypoint_flier/README.md renamed to cpp/waypoint_flier/README.md

Lines changed: 8 additions & 0 deletions
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

waypoint_flier_simple/README.md renamed to cpp/waypoint_flier_simple/README.md

Lines changed: 8 additions & 0 deletions

python/README.md

Lines changed: 1 addition & 0 deletions
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cmake_minimum_required(VERSION 3.15.0)
2+
project(example_sweeping_generator)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
7+
set(CATKIN_DEPENDENCIES
8+
rospy
9+
mrs_msgs
10+
)
11+
12+
find_package(catkin REQUIRED COMPONENTS
13+
${CATKIN_DEPENDENCIES}
14+
)
15+
16+
catkin_package(
17+
CATKIN_DEPENDS ${CATKIN_DEPENDENCIES}
18+
)
19+
20+
## --------------------------------------------------------------
21+
## | Install |
22+
## --------------------------------------------------------------
23+
24+
install(DIRECTORY launch config
25+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
26+
)
27+
28+
install(DIRECTORY scripts/
29+
USE_SOURCE_PERMISSIONS
30+
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
31+
)
32+
33+
install(DIRECTORY scripts
34+
USE_SOURCE_PERMISSIONS
35+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
36+
)

python/sweeping_generator/README.md

Lines changed: 12 additions & 0 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
frame_id: "world_origin"
2+
3+
timer_main:
4+
rate: 1.0 # [Hz]
5+
6+
center:
7+
x: 0.0 # [m]
8+
y: 0.0 # [m]
9+
z: 2.0 # [m]
10+
11+
dimensions:
12+
x: 20.0 # [m]
13+
y: 20.0 # [m]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<launch>
2+
3+
<!-- defines name of the namespace of the drone -->
4+
<arg name="UAV_NAME" default="$(optenv UAV_NAME uav1)" />
5+
6+
<!-- Namespace - all topics, services and parameters will be remapped using this namespace as a prefix (eg.: "/waypoint_flier_simple/odom_uav_in" to "/uav1/waypoint_flier_simple/odom_uav_in") -->
7+
<group ns="$(arg UAV_NAME)">
8+
9+
<node pkg="example_sweeping_generator" type="sweeping_generator.py" name="sweeping_generator" output="screen">
10+
11+
<!-- ROS parameters config file -->
12+
<rosparam file="$(find example_sweeping_generator)/config/sweeping_generator.yaml" />
13+
14+
<remap from="~control_manager_diag_in" to="control_manager/diagnostics" />
15+
16+
<remap from="~path_out" to="trajectory_generation/path" />
17+
18+
<remap from="~start_in" to="~start" />
19+
20+
</node>
21+
22+
</group>
23+
24+
</launch>

python/sweeping_generator/package.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<package format="2">
3+
4+
<name>example_sweeping_generator</name>
5+
<version>1.0.0</version>
6+
<description>The Python Example for Sweeping Generator</description>
7+
8+
<maintainer email="[email protected]">Tomas Baca</maintainer>
9+
<author email="[email protected]">Tomas Baca</author>
10+
11+
<license>MIT</license>
12+
13+
<buildtool_depend>catkin</buildtool_depend>
14+
15+
<depend>rospy</depend>
16+
<depend>mrs_msgs</depend>
17+
18+
<export>
19+
</export>
20+
21+
</package>
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#!/usr/bin/python3
2+
3+
import rospy
4+
import numpy
5+
6+
from mrs_msgs.msg import ControlManagerDiagnostics,Reference
7+
from mrs_msgs.srv import PathSrv,PathSrvRequest
8+
from mrs_msgs.srv import Vec1,Vec1Response
9+
10+
class Node:
11+
12+
# #{ __init__(self)
13+
14+
def __init__(self):
15+
16+
rospy.init_node("sweeping_generator", anonymous=True)
17+
18+
## | --------------------- load parameters -------------------- |
19+
20+
self.frame_id = rospy.get_param("~frame_id")
21+
22+
self.center_x = rospy.get_param("~center/x")
23+
self.center_y = rospy.get_param("~center/y")
24+
self.center_z = rospy.get_param("~center/z")
25+
26+
self.dimensions_x = rospy.get_param("~dimensions/x")
27+
self.dimensions_y = rospy.get_param("~dimensions/y")
28+
29+
self.timer_main_rate = rospy.get_param("~timer_main/rate")
30+
31+
rospy.loginfo('[SweepingGenerator]: initialized')
32+
33+
## | ----------------------- subscribers ---------------------- |
34+
35+
self.sub_control_manager_diag = rospy.Subscriber("~control_manager_diag_in", ControlManagerDiagnostics, self.callbackControlManagerDiagnostics)
36+
37+
## | --------------------- service servers -------------------- |
38+
39+
self.ss_start = rospy.Service('~start_in', Vec1, self.callbackStart)
40+
41+
## | --------------------- service clients -------------------- |
42+
43+
self.sc_path = rospy.ServiceProxy('~path_out', PathSrv)
44+
45+
## | ------------------------- timers ------------------------- |
46+
47+
self.timer_main = rospy.Timer(rospy.Duration(1.0/self.timer_main_rate), self.timerMain)
48+
49+
## | -------------------- spin till the end ------------------- |
50+
51+
self.is_initialized = True
52+
53+
rospy.spin()
54+
55+
# #} end of __init__()
56+
57+
## | ------------------------- methods ------------------------ |
58+
59+
# #{ planPath()
60+
61+
def planPath(self, step_size):
62+
63+
rospy.loginfo('[SweepingGenerator]: planning path')
64+
65+
# https://ctu-mrs.github.io/mrs_msgs/srv/PathSrv.html
66+
# -> https://ctu-mrs.github.io/mrs_msgs/msg/Path.html
67+
path_msg = PathSrvRequest()
68+
69+
path_msg.path.header.frame_id = self.frame_id
70+
path_msg.path.header.stamp = rospy.Time.now()
71+
72+
path_msg.path.fly_now = True
73+
74+
path_msg.path.use_heading = True
75+
76+
sign = 1.0
77+
78+
# fill in the path with a sweeping pattern
79+
for i in numpy.arange(-self.dimensions_x/2.0, self.dimensions_x/2.0, step_size):
80+
81+
for j in numpy.arange(-self.dimensions_y/2.0, self.dimensions_y/2.0, step_size):
82+
83+
# https://ctu-mrs.github.io/mrs_msgs/msg/Reference.html
84+
point = Reference()
85+
86+
point.position.x = self.center_x + i
87+
point.position.y = self.center_y + j*sign
88+
point.position.z = self.center_z
89+
point.heading = 0.0
90+
91+
path_msg.path.points.append(point)
92+
93+
if sign > 0.0:
94+
sign = -1.0
95+
else:
96+
sign = 1.0
97+
98+
return path_msg
99+
100+
# #} end of planPath()
101+
102+
## | ------------------------ callbacks ----------------------- |
103+
104+
# #{ callbackControlManagerDiagnostics():
105+
106+
def callbackControlManagerDiagnostics(self, msg):
107+
108+
if not self.is_initialized:
109+
return
110+
111+
rospy.loginfo_once('[SweepingGenerator]: getting ControlManager diagnostics')
112+
113+
self.sub_control_manager_diag = msg
114+
115+
# #} end of
116+
117+
# #{ callbackStart():
118+
119+
def callbackStart(self, req):
120+
121+
if not self.is_initialized:
122+
return Vec1Response(False, "not initialized")
123+
124+
# set the step size based on the service data
125+
step_size = req.goal
126+
127+
path_msg = self.planPath(step_size)
128+
129+
try:
130+
response = self.sc_path.call(path_msg)
131+
except:
132+
rospy.logerr('[SweepingGenerator]: path service not callable')
133+
pass
134+
135+
if response.success:
136+
rospy.loginfo('[SweepingGenerator]: path set')
137+
else:
138+
rospy.loginfo('[SweepingGenerator]: path setting failed, message: {}'.format(response.message))
139+
140+
return Vec1Response(True, "starting")
141+
142+
# #} end of
143+
144+
## | ------------------------- timers ------------------------- |
145+
146+
# #{ timerMain()
147+
148+
def timerMain(self, event=None):
149+
150+
if not self.is_initialized:
151+
return
152+
153+
rospy.loginfo_once('[SweepingGenerator]: main timer spinning')
154+
155+
if isinstance(self.sub_control_manager_diag, ControlManagerDiagnostics):
156+
if self.sub_control_manager_diag.tracker_status.have_goal:
157+
rospy.loginfo('[SweepingGenerator]: tracker has goal')
158+
else:
159+
rospy.loginfo('[SweepingGenerator]: waiting for command')
160+
161+
# #} end of timerMain()
162+
163+
if __name__ == '__main__':
164+
try:
165+
node = Node()
166+
except rospy.ROSInterruptException:
167+
pass
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# A timeout between the takeoff being triggered and the UAV actually taking off
2+
# while the timeout is counting down, the takeoff can be aborted by switching off
3+
# the offboard mode.
4+
# default = 5 sec
5+
safety_timeout: 1.0 # [s]

0 commit comments

Comments
 (0)