Ask Your Question
0

how to call arduino codes using topics

asked 2017-12-06 09:36:11 -0600

pamis5 gravatar image

updated 2017-12-08 09:36:26 -0600

bpinaya gravatar image

the codes are dc motor controller, PID controller, ultrasonic sensor

edit retag flag offensive close merge delete

Comments

Welcome! What do you mean by "call arduino codes using topics"? What are you trying to accomplish? Also, please see http://wiki.ros.org/Support#Guideline...

jayess gravatar imagejayess ( 2017-12-06 10:21:17 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-12-06 12:45:55 -0600

fandrade gravatar image

updated 2017-12-06 12:46:40 -0600

If you want to interact with Arduino from ROS you have to do it by serial communication. I think the simplest way is python scripting. I did it a few years ago. I had implement a protocol with SYNC, OP_ID, PARAMETERS and CHECKSUM between the PC (ROS) and Arduino

This was my Python script imports:

  ...
    import rospy
    import os
    import comm
    from datetime import datetime
    ....

where comm is the python file wich manages communication with arduino board

Here I am reading a message from arduino in my ros node file (this is the arduino objetc: ArdIfc)

...
  newMsg = ArdIfc.recv()
            if newMsg != None:
                if newMsg.mod == comm.MOD_SENSORS: 
                    if newMsg.op == comm.OP_GETCURRENTDIST:
                        torsoPos = newMsg.param[0]
...

Here I am sending a message to the Arduino from my ros node file

...
 rospy.loginfo("Torso-> Stop message.")
                msgMotor = comm.Msg(comm.ARDUINO_ID, comm.MOD_MOTORS, comm.OP_STOP_MOTOR, [], 0)
                ArdIfc.send(msgMotor)
                msgMotor_ack_received = False 
...

If you want the code I can send it to you.

best, Fedeico

edit flag offensive delete link more

Comments

@fandrade instead of privately sharing code, can you please update your answer with it instead? That way the entire community can benefit from it instead of just one person.

jayess gravatar imagejayess ( 2017-12-06 14:45:54 -0600 )edit
1

@jayess if this is what @pamis5 need, I completeley agree to share the files here. Since I am not sure about the real question, I am waiting for his answer.

fandrade gravatar imagefandrade ( 2017-12-06 15:05:39 -0600 )edit

Sir may i learn how to connect a arduino based Robotic arm with MoveIt

lagankapoor gravatar imagelagankapoor ( 2018-01-15 02:35:55 -0600 )edit

@lagankapoor: comments aren't an appropriate place to ask questions. You should create your own question instead of asking in a comment.

jayess gravatar imagejayess ( 2018-01-15 02:38:56 -0600 )edit

thanks sir check i ask new question today please if you know about that help me

lagankapoor gravatar imagelagankapoor ( 2018-01-17 22:48:39 -0600 )edit
0

answered 2017-12-06 14:30:25 -0600

pedro1713 gravatar image

I would recommend taking a look at http://wiki.ros.org/rosserial?distro=... maybe that could work.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-12-06 09:36:11 -0600

Seen: 56 times

Last updated: Dec 06 '17