WWU-Robotics-Club / Rover

1 stars 1 forks source link

Create an example ROS topic for communicating with an arduino #14

Open CalebJ2 opened 5 years ago

CalebJ2 commented 5 years ago

This seems like a good way to start getting the hang of ROS.

CalebJ2 commented 4 years ago

Went through the rosserial arduino setup tutorial: http://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup And the basic publisher tutorial: http://wiki.ros.org/rosserial_arduino/Tutorials/Hello%20World Need to figure out why the ros_lib in the libraries folder isn't being recognized.

khalilxl commented 4 years ago

https://wiki.ros.org/rosserial_arduino/Tutorials/Servo%20Controller We got this tutorial running to set the speed of the motor. We had to use this command to get it to run though on a different terminal. rosrun rosserial_arduino serial_node.py _port:=/dev/ttyUSB0

The Arduino Serial Library cannot be used at the same time as the Arduino rosserial.

khalilxl commented 4 years ago
#!/usr/bin/ env python

import rospy
from std_msgs.msg import String

def talker():
    pub = rospy.Publisher('chatter', String, queue_size=10)
    rospy.init_node('talker', anonymous=True)
    rate = rospy.Rate(10)
    while not rospy.is_shutdown():
        test_str = input("Let get this tested out: ")
        rospy.loginfo(test_str)
        pub.publish(test_str)
        rate.sleep()
if __name__ == '__main__':
    try:
        talker()
    except rospy.ROSInterruptException:
        pass
khalilxl commented 4 years ago
 #!/usr/bin/python
import rospy
from std_msgs.msg import String

def callback(data):
    rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)

def listener():

    rospy.init_node('listener', anonymous=True)

    rospy.Subscriber("chatter", String, callback)

    rospy.spin()

if __name__ == '__main__':
    listener()