You are right. The LED will be a subscriber, the switch will publish the switches state, although both functionalities can go in the same node.
std_msgs/Bool
might probably be the thing you'd want to use for that.
Originally posted by dornhege with karma: 31395 on 2013-06-25
This answer was ACCEPTED on the original site
Post score: 0
Original comments
Comment by Praseen on 2013-06-25:
Hi dornhege, How do I go about creating the ROS node required Which part of the tutorial tells how to create a node? I am working on the Basic Tutorial now. As mentioned in the question I also have an I2C connector connecting the Rasberry Pi and the switches and the LED. Will that make a difference?
Comment by dornhege on 2013-06-25:
The basic tutorials should contain info on creating and building packages. From then on, you'll need to do the hardware integration as you'd do with any other binary. The only difference to other nodes is that you might need a thread depending on how you access the hardware.
Comment by Praseen on 2013-06-25:
Hi dornhege, I would be indebted, if it would be possible to let me know of a step by step procedure or a link containing an example solution for such a problem? So in this case the thread which you talk of should be used to implement an I2C send/receive?
Comment by dornhege on 2013-06-25:
Not necessarily. It just depends on how you do the hardware connection. I don't know what interfaces/device drivers you have available to do that. Maybe you can do that quite simply.
Comment by Praseen on 2013-06-25:
Hi dornhege, I am building this system as part of a building block for a robot, that is the reason why I wanted to use an I2C interface. However right now I am happy to just use some GPIOs to connect the LED and switch to the RPi. I would eventually want to use an I2C connector later.