def main(args):
    rospy.init('image_converter', anonymous - True)
    image_sub = rospy.Subscriber('usb_cam/image_raw', Image, image_callback)
    try:
        rospy.spin()
    except KeyboardInterrupt:
        print("Shutting Down")
def run_application():
    rospy.init('app_obstacle_avoidance');
    setup_wheels(wheels)
    rospy.Subscriber("distance_val", Float32, distance_callback)
    rospy.Subscriber("QRCode_available", qrcode, qr_callback)
    move_forward(wheels)
    rospy.spin()
Exemplo n.º 3
0
def start():
	rospy.init("car_controller")
	print("Beginning...")
	plan=planner()
	scansensor=Scansensor()
	motion=Twist()
	r=rospy.Rate(initialdata.freq)
Exemplo n.º 4
0
def main():
    print("Usage: demo.py [model path] [image topic] [output topic]")
    model_path = sys.argv[1]
    image_topic_name = sys.argv[2]
    output_topic_name = sys.argv[3]
    if (len(sys.argv) < 4):
        print("arg error.")
        return
    pModel = load_model(model_path)
    rospy.init("GAAS_ImageDetection_TEGU_demo" +
               model_path)  # which supports multi process.
    pPublisher = rospy.Publisher(output_topic_name)
    rospy.Subscribe(image_topic_name, 10, callback)
    rospy.spin()
Exemplo n.º 5
0
def loadnode():
	rospy.init("wheel_encoder_node")
	read_encoder()
	print_data()
Exemplo n.º 6
0
    def callback_main(self, msg):
        pass
        """
            This will handle all "static" operations that happen at the beginning and end
            of digging automation - prepping digging arm, pulling out of the ground, etc.
        """

    def callback_sensor(self, msg):
        pass
        """
            This will handle the "main digging loop" where we are constantly checking the sensor data
            and deciding which opcode to run on the subassembly
        """

    def stop(self):
        pass


if __name__ == "__main__":
    # standard ROS node setup
    rospy.init("autonomy_dumping_node")

    auto_dump_wrapper = autoDumpingWrapperROS()

    rospy.on_shutdown(auto_dump_wrapper.stop)

    rospy.loginfo("***Autonomy Digging Node initializaed successfully***")

    rospy.spin()
Exemplo n.º 7
0
#/usr/bin/env pytnon

import rospy
import diagnostics_msgs
import diagnostics_updater

if __name__ == "__main__":
    rospy.init("diagnostics_sample")
    
Exemplo n.º 8
0
        self.reference_alpha = np.pi / 2.0
        self.reference_alpha_rate = 0.0
        self.motor_id = dynamixel_id

    def traj_callback(self, msg):
        self.reference_alpha = msg.traj[0].alpha * 180 / np.pi + 60.0
        self.reference_alpha_rate = msg.traj[0].alpha_rate

    def progress(self, ):
        self.serial_connection.movePosition(self.motor_id,
                                            self.reference_alpha)
        self.current_angle_degree = self.serial_connection.readPosition(
            self.motor_id)
        itm_manipulator_state_obj = manipulator_state()
        itm_manipulator_state_obj.angle = (self.current_angle_degree -
                                           60.0) / 180.0 * np.pi
        self.motor_angle_pub.publish(itm_manipulator_state_obj)


if __name__ == '__main__':
    rospy.init('ax12_control')
    ax12_obj = AX12Controller(serial_port=None)

    rate = rospy.Rate(10)

    while not rospy.is_shutdown():
        ax12_obj.progress()
        rate.sleep()

    rospy.loginfo('AX12 controller is closed')
Exemplo n.º 9
0
import pypcd
import rospy
from sensor_msgs.msg import PointCloud2


def cb(msg):
    pc = PointCloud2.from_msg(msg)
    pc.save('foo.pcd', compression='binary_compressed')
    # maybe manipulate your pointcloud
    pc.pc_data['x'] *= -1
    outmsg = pc.to_msg()
    # you'll probably need to set the header
    outmsg.header = msg.header
    pub.publish(outmsg)


# ...
sub = rospy.Subscriber('incloud', PointCloud2)
pub = rospy.Publisher('outcloud', PointCloud2, cb)
rospy.init('pypcd_node')
rospy.spin()


def listener():
    rospy.init_node('listener', anonymous=True)
    rospy.Subscriber('/camera/depth/points', PointCloud2, cb)
    rospy.spin()
Exemplo n.º 10
0
    def callback_main(self, msg):
        pass
        """
            This will handle all "static: operations that happen at the beginning and end
            of digging automation - prepping digging arm, pulling out of the ground, etc.
        """

    def callback_sensor(self, msg):
        pass
        """
            This will handle the "main digging loop" where we are constantly checking the sensor data
            and deciding which opcode to run on the subassembly
        """

    def stop(self):
        pass


if __name__ == "__main__":
    # standard ROS node setup
    rospy.init("autonomy_digging_node")

    auto_dig_wrapper = autoDiggingWrapperROS()

    rospy.on_shutdown(auto_dig_wrapper.stop)

    rospy.loginfo("***Autonomy Digging Node initializaed successfully***")

    rospy.spin()
Exemplo n.º 11
0
#!/usr/bin/env python
from __future__ import print_function
import time
import RPi.GPIO as GPIO

import sys
import rospy
import roslib
from std_msgs.msg import Float64


def callback(data):
    rospy.loginfo(rospy.get_caller_id() + 'I heard %s', data.data)
    file = open("test3.txt", "a")
    elapsed = data.data
    file.write('%r\n' % (elapsed))
    file.close()


#------------Main Program-------------
rospy.init('ultranode_list', anonymous=True)
rospy.Subscriber("distance", Float64, callback)
rospy.spin()
Exemplo n.º 12
0
def main():
    rospy.init("robotic_arm_ros")
    rospy.Subscriber("robotic_arm_target", String, target_callback)

    while not rospy.is_shutdown():
        rospy.spin()
Exemplo n.º 13
0
DYNAMIC_FILENAME = 'tf_file_dynamic.json'


class Transformer:
    def __init__(self, topic, frame_id, child_id):
        self.frame_id = frame_id
        self.child_id = child_id
        self.pose_sub = rospy.Subscriber(topic, Pose, self.get_tf)
        self.broadcaster = tf2_ros.TransformBroadcaster()

    def get_tf(self, pose_msg):
        tf_msg = tf2_ros.TransformStamped()
        tf_msg.header.stamp = rospy.Time.now()
        tf_msg.header.frame_id = self.frame_id
        tf_msg.child_frame_id = self.child_id
        tf_msg.transform.translation = pose_msg.position
        tf_msg.transform.rotation = pose_msg.orientation
        self.broadcaster.sendTransform(tf_msg)


if __name__ == '__main__':
    rospy.init('tf_dynamic_broadcaster')
    with open(DYNAMIC_FILENAME) as f:
        transforms = json.load(f)['transforms']

    for transform in transforms:
        Transformer(transforms['topic'], transforms['frame_id'],
                    transforms['child_frame_id'])

    rospy.spin()
# /usr/bin/env pytnon

import rospy
import diagnostics_msgs
import diagnostics_updater

if __name__ == "__main__":
    rospy.init("diagnostics_sample")
Exemplo n.º 15
0
class ImuResetMonitor(object):
    '''Monitors an IMU topic and resets orientation when stationary
    '''
    def __init__(self):
        self.imu_sub = rospy.Subscriber('imu', Imu, self.imu_callback)
        reset_topic = rospy.get_param('~reset_service')
        self.reset_srv = rospy.ServiceProxy(reset_topic, Reset)

        self.stationary_time = rospy.get_param('~stationary_time', 1.0)
        self.reset_period = rospy.get_param('~time_between_resets', 1.0)
        self.last_reset_time = rospy.Time.now()

    def reset(self):
        req = ResetRequest()
        req.zero_gyros = True
        req.reset_ekf = True
        try:
            self.reset_srv(req)
        except rospy.ServiceException:
            rospy.logerr('Could not reset IMU')

    def imu_callback(self, msg):
        gyro, xl = parse_imu_msg(msg)

        # Test IMU data for stationarity


if __name__ == '__main__':
    rospy.init('imu_reset_monitor')
Exemplo n.º 16
0
#!/usr/bin/env python2
import rospy
from jsk_rviz_plugins.msg import diagnostics_msgs
from jsk_rviz_plugins.msg import diagnostics_updater

if __main__ == "main":
    rospy.init("diagnostics")
Exemplo n.º 17
0
from Phidget22.Devices.Gyroscope import *
from Phidget22.Devices.Accelerometer import *
from Phidget22.PhidgetException import *
from Phidget22.Phidget import *
from Phidget22.Net import *

rospy.init_node('imu')
pub = rospy.Publisher('imu_data', Imu, queue_size = 10)

if __name__ == __main__:

    # Setting up Phidget object
    try:
        ch = Gyroscope()
    except RuntimeError as e:
        print("Runtime Exception %s" % e.details)
        print("Press Enter to Exit...\n")
        readin = sys.stdin.read(1)
        exit(1)
    try:
        ch.open()
    except PhidgetException as e:
        print (“Phidget Exception %i: %s” % (e.code, e.details))

    # Opening ROS publisher
    rospy.init('imu_data', anonymous=True)
    r = rospy.Rate(20)
    while not rospy.is_shutdown():
        pub.publish()
        r.sleep()