Commit dc4b3bbe authored by Jakob Dommaschk's avatar Jakob Dommaschk
Browse files

Add launch system for landing_controller package

parent 9a79a43d
......@@ -6,14 +6,18 @@ import math
from geometry_msgs.msg import Twist, Vector3
from px4_msgs.msg import Timesync, OffboardControlMode, TrajectorySetpoint, VehicleCommand
class VelocityCommander(Node):
# parameters
TOPIC_CMD_VEL = 'cmd_vel'
TOPIC_PX4_TIME = 'Timesync_PubSubTopic'
TOPIC_TRAJ_WP = '/TrajectorySetpoint_PubSubTopic'
TOPIC_OFFB_CTRL_MODE = '/OffboardControlMode_PubSubTopic'
TOPIC_VEH_CMD = '/VehicleCommand_PubSubTopic'
TOPICS = {
"CMD_VEL": 'cmd_vel',
"PX4_TIME": 'Timesync_PubSubTopic',
"TRAJ_SP": '/TrajectorySetpoint_PubSubTopic',
"OFFB_CTRL_MODE": '/OffboardControlMode_PubSubTopic',
"VEH_CMD": '/VehicleCommand_PubSubTopic'
}
def __init__(self):
super().__init__('velocity_commander')
......@@ -28,20 +32,20 @@ class VelocityCommander(Node):
# subscription callbacks
self.sub_timesync = self.create_subscription(
Timesync,
self.TOPIC_PX4_TIME,
self.TOPICS["PX4_TIME"],
self.process_timesync_callback,
1)
self.sub_vel = self.create_subscription(
Twist,
self.TOPIC_CMD_VEL,
self.TOPICS["CMD_VEL"],
self.process_vel_callback,
1)
# init publications
self.offb_control_mode_publisher = self.create_publisher(OffboardControlMode, self.TOPIC_OFFB_CTRL_MODE, 10)
self.traj_sp_publisher = self.create_publisher(TrajectorySetpoint, self.TOPIC_TRAJ_WP, 10)
self.veh_cmd_publisher = self.create_publisher(VehicleCommand, self.TOPIC_VEH_CMD, 10)
self.offb_control_mode_publisher = self.create_publisher(OffboardControlMode, self.TOPICS["OFFB_CTRL_MODE"], 10)
self.traj_sp_publisher = self.create_publisher(TrajectorySetpoint, self.TOPICS["TRAJ_SP"], 10)
self.veh_cmd_publisher = self.create_publisher(VehicleCommand, self.TOPICS["VEH_CMD"], 10)
self.pub_vel_timer = self.create_timer(.1, self.timer_callback)
......
import launch
import launch.actions
import launch.substitutions
import launch_ros.actions
from landing_controller.velocity_commander import VelocityCommander
###
### This launch file is not supposed to be run manually. It is
### included by other launchfiles
###
def generate_launch_description():
# prepare launch command by inserting all necessary topics
launch_cmd = ['ros2', 'bag', 'record']
for topic in VelocityCommander.TOPICS:
launch_cmd.append(VelocityCommander.TOPICS[topic])
return launch.LaunchDescription([
launch_ros.actions.Node(
package='landing_controller',
namespace='',
executable='velocity_commander',
output='screen',
name=['velocity_commander']),
launch.actions.ExecuteProcess(
cmd=launch_cmd,
output='screen'
)
])
import launch
import launch.actions
import launch.substitutions
import launch_ros.actions
def generate_launch_description():
return launch.LaunchDescription([
# RTPS connection with gazebo
launch.actions.ExecuteProcess(
cmd=['micrortps_agent', 'start', '-t', 'UDP'],
output='screen'
),
# Gazebo and PX4 Firmware
# launch.actions.ExecuteProcess(
# cmd=['make', 'px4_sitl_rtps', 'gazebo',
# '-C', '~/PX4-Autopilot_1.12'],
# output='screen'
# ),
# Command to move drone
# launch_ros.actions.Node(
# package='teleop_twist_keyboard',
# namespace='',
# executable='teleop_twist_keyboard',
# output='screen',
# name=['teleop']),
# call general launch file (This could also be done nicer somehow)
launch.actions.ExecuteProcess(
cmd=['ros2', 'launch', 'landing_controller', 'general.launch.py'],
output='screen'
),
])
[develop]
script-dir=$base/lib/landing_controller
script_dir=$base/lib/landing_controller
[install]
install-scripts=$base/lib/landing_controller
install_scripts=$base/lib/landing_controller
import os
from glob import glob
from setuptools import setup
package_name = 'landing_controller'
......@@ -10,6 +12,8 @@ setup(
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
# Include all launch files
(os.path.join('share', package_name), glob('launch/*.launch.py')),
],
install_requires=['setuptools'],
zip_safe=True,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment