Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Teleop and fix velocity transformer #8

Merged
merged 2 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions controls/velocity_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

import sys
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist
from sub_interfaces.msg import SubThrusts
# from uuv_gazebo_ros_plugins_msgs.msg import FloatStamped


class VelocityTransformer(rclpy.node.Node):
class VelocityTransformer(Node):

def __init__(self):
self.sub = self.create_subscription('/sub/cmd_vel', Twist, self.vel_callback)
self.pub = self.create_publisher('/sub/thrusts', SubThrusts, 10)
super().__init__('velocity_transformer')
self.sub = self.create_subscription(Twist, '/sub/cmd_vel', self.vel_callback, 10)
self.pub = self.create_publisher(SubThrusts, '/sub/thrusts', 10)
# self.thrusters = [rospy.Publisher(f'/sub/thrusters/{i}/input', FloatStamped, queue_size=10) for i in ]

def vel_callback(self, twist):
Expand Down Expand Up @@ -51,8 +53,11 @@ def vel_callback(self, twist):

self.pub.publish(msg)

if __name__ == "__main__":
rclpy.init(sys.argv)
def main(args=None):
rclpy.init(args=args)
vel_transform = VelocityTransformer()
rclpy.spin(vel_transform)
rclpy.shutdown(vel_transform)

if __name__ == "__main__":
main()
20 changes: 20 additions & 0 deletions launch/robosub_controls.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
return LaunchDescription([
Node(
package='controls',
node_namespace='sb',
caelinsutch marked this conversation as resolved.
Show resolved Hide resolved
node_executable='velocity_transformer',
node_name='velocity_transformer'
),
Node(
package='teleop_twist_keyboard',
node_namespace='sb',
caelinsutch marked this conversation as resolved.
Show resolved Hide resolved
node_executable='teleop_twist_keyboard',
output='screen',
prefix='xterm -e',
node_name='teleop_twist_keyboard'
),
])
6 changes: 0 additions & 6 deletions launch/robosub_controls.launch.xml

This file was deleted.

4 changes: 3 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
<buildtool_depend>ament_python</buildtool_depend>

<build_depend>rclpy</build_depend>

<build_depend>teleop_twist_keyboard</build_depend>

<exec_depend>rclpy</exec_depend>
<exec_depend>geometry_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>razor_imu_9dof</exec_depend>
<exec_depend>sub_interfaces</exec_depend>
<exec_depend>teleop_twist_keyboard</exec_depend>

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from setuptools import setup
import glob
from glob import glob

package_name = 'controls'

Expand All @@ -11,7 +12,7 @@
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
('share/' + package_name, glob.glob('launch/*.launch*'))
(os.path.join('share', package_name), glob('launch/*.launch.py'))
],
install_requires=['setuptools'],
zip_safe=True,
Expand All @@ -22,7 +23,8 @@
tests_require=['pytest'],
entry_points={
'console_scripts': [
'init = controls.sub_init:processInput'
'init = controls.sub_init:processInput',
'velocity_transformer = controls.velocity_transformer:main',
],
},
)