rosserial, Arduino and uArm
Hi guys,
I`m trying to control my uArm (made by uFactory) via ROS, which has a Arduino UNO in it.
I installed as tutorials wrote and could run all the examples.
Then I modified "float64test" example and added "#include
When I added the sentence "UF_uArm uarm; ", which tries to initialize the uArm, the connection failed as:
$ rosrun rosserial_python serial_node.py _port:=/dev/ttyUSB0
[INFO] [WallTime: 1424100015.682196] ROS Serial Python Node
[INFO] [WallTime: 1424100015.685933] Connecting to /dev/ttyUSB0 at 57600 baud
/opt/ros/indigo/lib/python2.7/dist-packages/rosserial_python/SerialClient.py:336: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information.
self.pub_diagnostics = rospy.Publisher('/diagnostics', diagnostic_msgs.msg.DiagnosticArray)
[ERROR] [WallTime: 1424100032.791215] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
The version of rosserial is Indigo so I think there shouldn`t be mismatch in versions...
I already searched for many solutions but all failed.
Anyone have any idea?
Thank you so much!!
Asked by Kahn on 2015-02-16 11:22:48 UTC
Answers
I am also trying to get my uArm working with rosserial.
I experienced the same odd behaviour, that the chatter example works perfectly, the uArm Motion demo works perfectly, but when I try to combine both the connection to rosserial is not working anymore or the robot is moving very odd.
Any ideas someone?
I tried this without luck: http://answers.ros.org/question/164191/rosserial-arduino-cant-connect-arduino-micro/
Here my code
#include <EEPROM.h>
#include <UF_uArm.h>
#include <ros.h>
#include <sensor_msgs/JointState.h>
UF_uArm uarm; // initialize the uArm library
float positions[5] = {0.0};
char *joint_names[5] = {"SERVO_ROT", "SERVO_L", "SERVO_R", "SERVO_HAND_ROT", "SERVO_HAND"};
ros::NodeHandle nh;
sensor_msgs::JointState joint_state_msg;
ros::Publisher joint_state_pub("/joint_states", &joint_state_msg);
void setup()
{
uarm.init(); // initialize the uArm position
uarm.setServoSpeed(SERVO_R, 50); // 0=full speed, 1-255 slower to faster
uarm.setServoSpeed(SERVO_L, 50); // 0=full speed, 1-255 slower to faster
uarm.setServoSpeed(SERVO_ROT, 50); // 0=full speed, 1-255 slower to faster
nh.initNode();
nh.advertise(joint_state_pub);
joint_state_msg.position_length = 5;
joint_state_msg.position = positions;
joint_state_msg.name_length = 5;
joint_state_msg.name = joint_names;
delay(500);
}
void loop()
{
uarm.setPosition(0, 0, 0, 0); // original pose
joint_state_msg.header.stamp = nh.now();
joint_state_msg.position[0] = (float)uarm.readAngle(SERVO_ROT);
joint_state_msg.position[1] = (float)uarm.readAngle(SERVO_L);
joint_state_msg.position[2] = (float)uarm.readAngle(SERVO_R);
joint_state_msg.position[3] = (float)uarm.readAngle(SERVO_HAND_ROT);
joint_state_msg.position[4] = (float)uarm.readAngle(SERVO_HAND);
joint_state_pub.publish( &joint_state_msg );
uarm.gripperDetach();
delay(100);
nh.spinOnce();
}
Asked by LorenzH on 2015-09-06 12:42:21 UTC
Comments