PDA

View Full Version : ROS + Serializer



Pi Robot
11-20-2010, 12:29 PM
Hi Patrick
I just got my serializer robot up and running is there a thread to discuss using your ros package?

peter

Hey Peter,

We didn't have a thread on this topic yet, so I've started this one. I've been using my Serializer ROS package as part of the navigation stack and it seems to work quite well. (The SLAM videos I posted earlier were done using the Serializer for odometry.) I haven't created any specific releases yet but I also haven't had to touch the trunk for a long time so feel free to try it out at:

svn co https://pi-robot-ros-pkg.googlecode.com/svn/trunk/pi-robot-ros-stack/serializer serializer-ros-pkg

(Note: you'll want to 'cd' to somewhere in your ROS path before executing the above command or alternatively, move the resulting serializer-ros-pkg directory into your ROS path after the checkout.)

Once checked out, 'cd' into the serializer-ros-pkg and do:

rosdep install serializer
rosmake serializer

Assuming everything builds without errors, you should tweak the params.yaml file to set your PID parameters appropriate to your robot. To launch the node, use something like this as part of your launch file:



<node name="serializer" pkg="serializer" type="serializer_node.py">
<rosparam file="$(find serializer)/params.yaml" command="load" />
</node>I get the best results if the Serializer is connected via USB to a CPU on the robot. However, it also works fairly well over an XBee connection.

--patrick

Peter_heim
11-21-2010, 06:16 AM
Hi Patrick
downloading and installing worked fine
1 issue i had was when i launched the serializer for the second time my ticks per meter was only 2508 not the normal
5300 and the drive was unstable (wild) i change the drive params in the serializer drive file my drive is now smooth and ticks per meter is always correct.

Thanks for the help with the urdf that works great now.
I had a bit of a surprise when i first start to drive with teleop robbie went backwards i changed the motor wiring and encoders so now it heading in the right direction driving with teleop now works

i tried setting a simple nav goal in rviz (move forward about 1 meter) the robot moved forward but it wouldn't stop in rviz the base_link stayed in place and the rest just drove around in a large circle (the display window was very unstable) the only way to stop the robot was to turn off power and kill the serializer, rviz thread
could the encoders be wired wrong ie left expected encoder is on the right i have motor 1 and encoder 1 on the left side view from the rear of the robot?

regards peter

Peter_heim
11-24-2010, 06:17 AM
Hi Patrick
It seams that something got hungry and ate the last couple of posts i read your reply to my last post before it became lunch:happy:

how do you define hobby servos in the launch file?


regards peter

Pi Robot
11-24-2010, 08:55 AM
Hey Peter,

I haven't yet set up a servo controller in the same way that Fergs has for the ArbotiX, partly because I am using the ArbotiX + AX-12 servos rather than the Serializer + hobby servos. In the meantime, you can still control hobby servos on the Serializer using the SetServo service defined in serializer_node.py. Here's an example of how you would use it in an arbitrary node:


def setServo(self, id, position):
rospy.wait_for_service('SetServo')
try:
servoProxy = rospy.ServiceProxy('SetServo', SetServo)
return servoProxy(id, position)
except rospy.ServiceException, e:
print "Service call failed: %s"%e

servo_id = 1
goal_position = 23
self.setServo(servo_id, goal_position)Bear in mind that the following table maps servo ids into GPIO pin ids on the Serializer:

Servo Id (firmware)
1 2 3 4 5 6
GPIO Pin Id (header)
8 9 6 7 4 5

--patrick

DresnerRobotics
11-24-2010, 01:49 PM
Tue 11/23/2010 9:28 AM
Pi Robot has just posted


Hi Peter,

Looks like I haven't added all the PID parameters to the ROS node serializer_node.py so it was picking them all up from the driver file serializer_driver.py and those values are set for my robot. I'll fix that today. Ditto for the reversal of the motors as I have my motor's external gears behind the wheels.

Not sure about your nav goal issues in RViz. But to make sure your encoder connections are correct, run something like the following straight out of the serializer_driver.py file:

Code:
---------
mySerializer.travel_distance(0.25, 0.1) # Travel 0.25 meters forward at 0.1 meters per second.
while mySerializer.get_pids(): # Test for completion of the movement.
time.sleep(0.1)
print "Wheel velocities", mySerializer.vel_m_per_s(), "Encoder counts:", mySerializer.get_encoder_count([1, 2])


mySerializer.rotate(math.radians(45), 0.5) # Rotate 45 degrees to the left at speed 0.5 radians per second.
while mySerializer.get_pids():
time.sleep(0.1)
print "Wheel velocities", mySerializer.vel_m_per_s(), "Encoder counts:", mySerializer.get_encoder_count([1, 2])
---------

--patrick

DresnerRobotics
11-24-2010, 02:17 PM
Tue 11/23/2010 2:30 PM
Peter_heim has just posted

Hi Patrick

Thanks for that I'll give it a try tonight on another subject how do i define hobby servo parameters in the yaml file

regards peter

Peter_heim
11-25-2010, 03:20 AM
Hi Patrick
Navigation and driving now work the upper assy no longer wanders around by its self
the problem was this line

<!-- Comment if using the base controller.
<node pkg="tf" type="static_transform_publisher" name="odom_base_link_broadcaster" args="0 0 0 0 0 0 /odom /base_link 100" />
-->
once i quoted out this line and the other parameters reflected my values it all and the URDF worked every thing came together.
I didn't realize that the base_controller published the odom base_link transformation


regards Peter

Pi Robot
11-25-2010, 07:10 AM
Awesome! Would be great to see a video of your robot in action one of these days.

--patrick

Pi Robot
11-26-2010, 08:51 PM
I put together a short article on ROS and SLAM including the video I posted earlier of Pi Robot mapping out part of the apartment. Since I am currently using the Serializer for odometry, I'm posting the link to the write-up on this thread:

http://www.pirobot.org/blog/0015/

http://forums.trossenrobotics.com/attachment.php?attachmentid=2212&stc=1&d=1290826108 (http://www.pirobot.org/blog/0015/)

--patrick

lnxfergy
11-26-2010, 08:58 PM
I put together a short article on ROS and SLAM including the video I posted earlier of Pi Robot mapping out part of the apartment. Since I am currently using the Serializer for odometry, I'm posting the link to the write-up on this thread:

http://www.pirobot.org/blog/0015/

--patrick

I'm going to try and not completely side-track this thread (if I do, I'll split this post and responses off to another thread), but: Any plans to play with your omni vision in ROS?

It's the Christmas season again, and I definitely hit up Walmart the other day to pick up some nicer shatterproof ornaments (I bought silly glass ones last year) I'm planning to be playing a bit with such things over break, and was wondering what your thoughts/plans were.

-Fergs

Pi Robot
11-26-2010, 09:12 PM
Funny you should bring that up. I was just starting to play with OpenCV and got camshift working to track a colored object. One thought I had for the omnidirectional vision was to use the low points of an edge map (like I did here (http://www.pirobot.org/blog/0004/)) to feed into the navigation stack instead of a laser scan. The idea would be to make the assumption that the lower the point, the closer it is to the robot, then do some initial calibration to turn vertical pixel distance into horizontal distance in meters. I haven't thought this all the way through, but that's the basic idea.

--patrick

P.S. By "vertical distance" above I mean assuming the omni image is unwrapped into a rectangle. But if there is no need to unwrap it, then it would be "radial distance".

lnxfergy
11-26-2010, 09:39 PM
Funny you should bring that up. I was just starting to play with OpenCV and got camshift working to track a colored object. One thought I had for the omnidirectional vision was to use the low points of an edge map (like I did here (http://www.pirobot.org/blog/0004/)) to feed into the navigation stack instead of a laser scan. The idea would be to make the assumption that the lower the point, the closer it is to the robot, then do some initial calibration to turn vertical pixel distance into horizontal distance in meters. I haven't thought this all the way through, but that's the basic idea.

--patrick

P.S. By "vertical distance" above I mean assuming the omni image is unwrapped into a rectangle. But if there is no need to unwrap it, then it would be "radial distance".

So, I've been thinking about trying a similar approach -- especially since I now have access to a laser scanner to calibrate against -- I was inspired by both your setup, and by a paper I came across a couple of weeks ago (Monocular Range Sensing: A Non-Parametric Learning Approach (http://linkinghub.elsevier.com/retrieve/pii/S0921889010000539)).

Is there an image unwarping feature in OpenCV? The only open version I knew of was Bob Mottram's omniclops (which is actually what I've just starting playing with).

-Fergs

Pi Robot
11-26-2010, 09:59 PM
Nice find Fergs! And the authors are just down the street from my office. One of these days I'll have to knock on their door and see what kind of mirror they have.


Is there an image unwarping feature in OpenCV?Not that I know of. I found this interesting method:

http://tech.groups.yahoo.com/group/OpenCV/message/34386

And here is a result for estimating distance directly from the omni image after empirical calibration (scroll down to the last section):

http://cgi.cse.unsw.edu.au/~cs4411/wiki/index.php?title=Omnidirectional_Image_Processing&printable=yes (http://cgi.cse.unsw.edu.au/%7Ecs4411/wiki/index.php?title=Omnidirectional_Image_Processing&printable=yes)

--patrick

Peter_heim
12-08-2010, 08:44 PM
Hi Patrick
I have a strange problem with Rviz if i set the pose of the robot to say 90 deg the robot moves 90 deg but rviz stops short by about 15 deg i tried adjusting the encoder values and the wheel base but that changes the robots final position and rviz remains the same

I will post a video of the robot soon (after i have worked out how to do it)

peter

Pi Robot
12-09-2010, 09:35 AM
Hi Peter,

I just tried my setup and I can't see a discrepancy between the robot's movement and RViz. However, you can significantly alter the precision of the robot's rotation (when setting a 2D Nav Goal in RViz) by adjusting the parameter yaw_goal_tolerance in your base_local_planner_params.yaml file that is used by the move_base node. For example, a tolerance setting of 0.2 means stop if the robot is within 0.2 radians or 11 degrees. So if you set the 2D Nav Goal to rotate 90 degrees, your robot may stop after 79 degrees rotation. So try a smaller setting for this parameter like 0.1 or 0.05.

--patrick

Peter_heim
12-10-2010, 06:47 AM
Hi Patrick
I adjusted the yaw goal value to 0.05 now Robbie turns 90 deg but rviz still shows the angle short
I have attached a screen shot

I have attached a polou 30 amp current sensor to pin 0 on the serializer and i can read the value with rosservice call /PhidgetsCurrent 0 false and this returns the value 4
how do i use the values from the serializer.yaml file ?
my best guess is below but how do i get values for head_ir and drive_current?



publish_sensors: True


analog: {'head_ir': {'pin': 1, 'type': 'GP2D12'}, 'drive_current': {'pin': 0, 'type': 'PhidgetsCurrent'} }
peter

Pi Robot
12-10-2010, 08:47 AM
Hi Peter,

I'm still baffled by your RViz discrepancy. I thought it might be caused by having an incorrect width for the robot in your URDF file but I tried that and it makes no difference. So no answer there yet.

As for the Serializer sensor stuff, it's been awhile since I have looked at the serializer_node.py file in SVN and it appears I left it in kind of a mess. Back up your current version and try this one on for size:

http://code.google.com/p/pi-robot-ros-pkg/source/browse/trunk/pi-robot-ros-stack/serializer/bin/serializer_node.py?r=105 (http://code.google.com/p/pi-robot-ros-pkg/source/browse/trunk/pi-robot-ros-stack/serializer/bin/serializer_node.py?r=105)

Now your yaml file should work OK but be sure to do a "rosparam delete /serializer" before trying it out.

Once you launch your Serializer node, the sensor values are published on the /sensors topic so do a "rostopic echo /sensors" to see the result.

--patrick

P.S. Note that the PhidgetsCurrent sensor type uses the formula for the Phidgets current sensor to map the raw analog value to a current value in amps. So I don't know how this compares to the Pololu current sensor.

Peter_heim
12-21-2010, 03:53 AM
Hi Patrick
Things seam a bit quite at the moment :happy: may be it the end of year cheer. I tried using a joystick to control Robbie and to my great surprise it worked I used Fergs ammadillo teleop launch and yaml files and the generic joystick tutorials all i had to do was remap the dead man switch and the xbox 360 controller worked.
Now the only problem is how do i get the kids to play with something else:happy:

When i did get to play with the remote I think i found the problem with rviz it appears when i do a full 360 rotation of the actual robot i only get about 280 in rviz. the distance traveled is good so it must be with the wheel track is this measured from the center of the drive wheels or the overall width between the drive wheels?

regards Peter

lnxfergy
12-21-2010, 07:21 AM
When i did get to play with the remote I think i found the problem with rviz it appears when i do a full 360 rotation of the actual robot i only get about 280 in rviz. the distance traveled is good so it must be with the wheel track is this measured from the center of the drive wheels or the overall width between the drive wheels?

It's tough to say -- because it depends on how squishy your wheels are, and how level to the ground they are, etc. I typically calibrate the track width based on a bit of trial and error if I have wide wheels (so that the bot does to a proper 360).

-Fergs

Pi Robot
12-21-2010, 08:53 AM
It's tough to say -- because it depends on how squishy your wheels are, and how level to the ground they are, etc. I typically calibrate the track width based on a bit of trial and error if I have wide wheels (so that the bot does to a proper 360).
-Fergs

Hi Peter,

Like Fergs, I start my estimate of wheel track by measuring center-to-center between the wheels and then tweaking against real-world rotation. However, rotation also depends on wheel diameter since the number of wheel rotations (and hence encoder ticks) for a given angle depends on the ratio of the wheel track over the wheel diameter. So I start by calibrating wheel diameter to get accurate straight movement over a given distance. Then I leave the wheel diameter number fixed and calibrate rotation by adjusting wheel track.

What I still don't understand is that it sounds like your calibration is actually OK because your robot is rotating 360 degrees in the real world. So why the disconnect with how it appears in RViz? Any ideas Fergs?

--patrick

Peter_heim
01-04-2011, 03:52 PM
Hi Patrick
Is there a way to make acceleration slower? i have Accel set to 1 in DPID and loop set to 24 in VPID (if i go higher drive becomes unstable VPID = 1 0 1 24 DPID = 1 0 0 1 25)
The main part of the problem is my drive belts slip on start ( the robot weighs 20 Kg) now i know i should fix the slippage but this is also handy if the robot gets hung up the motors won't stall i have 2 boys ( 9 and 5) that think Robbie is a over sized R C car
I tried setting the Accel to .5 but that caused a error

Peter

Pi Robot
01-04-2011, 06:28 PM
Hi Peter,

As it turns out, I asked this question on the Robotics Connection forum some time ago. You can see the discussion at the following link but the answer seems to be that if you're setting the acceleration to 1, that is as slow as it can go...

http://www.roboticsconnection.com/userForums/Topic1532-6-1.aspx

--patrick

Pi Robot
01-06-2011, 08:57 PM
Hi Peter,

Just a heads up that some time this evening I'm going to take a snapshot of a first "official" release of the Serializer ROS package and I made a small but important change to the API that might affect you: namely I have placed the services and the "sensors" topic under the "/serializer" namespace. For example, instead of referring to the "/SetServo" service, you'll now use "/serializer/SetServo" instead. Similarly, instead of subscribing to the "/sensors" topic, you'll now subscribe to "/serializer/sensors".

None of this will affect you until if and when you update your SVN copy so no need to change anything right away. Also, I have named the parameter file "sample_params.yaml" in the SVN copy so it shouldn't overwrite your own params file.

--patrick

Pi Robot
01-07-2011, 01:20 PM
I posted the following message to the ros-users list regarding the availability of the ROS package for the Serializer:

Hello All,

I have released a ROS package for the Serializer microcontroller made by the Robotics Connection. I have been using and developing this package for several months along with at least one other ROS user so I hope I have most of the egregious bugs fixed. Please let me know if you run into trouble with either the code or the Wiki page:

Wiki: http://www.ros.org/wiki/serializer

SVN: http://pi-robot-ros-pkg.googlecode.com/svn/trunk/serializer/
(http://pi-robot-ros-pkg.googlecode.com/svn/trunk/serializer/)
The Serializer has both analog and digital sensor pins, a PWM servo controller, and a PID controller that works well with the ROS navigation stack.

The underlying driver is written in Python and provides some convenience functions for specific sensors such as the Phidgets temperature, voltage and current sensors, the Sharp GP2D12 IR sensor, and the Ping sonar sensor. It also includes two PID drive commands: Rotate(angle, speed) and TravelDistance(distance, speed) for controlling the drive motors. Most of the Serializer functions have been implemented though a few have not been tested since I don't currently have some of the supported sensors. The functions that have not been tested are:


step (used with a bipolar stepper motor)
sweep (also used with a bipolar stepper motor)
srf04, srf08 and srf10 (used with a Devantech SRF04, SRF08 and SRF10 sonar sensors)
tpa81 (used with the Devantech TPA81 thermopile sensor)

The driver requires Python 2.6.5 or higher and PySerial 2.3 or higher. It has been tested on Ubuntu Linux 10.04.

Documentation for the Python Serializer library can be found at:
http://www.pirobot.org/code/serializer.html

(http://www.pirobot.org/code/serializer.html)
The official Serializer manual can be found at:

http://www.roboticsconnection.com/multimedia/docs/Serializer_3.0_UserGuide.pdf


--patrick

ringo42
03-08-2011, 09:51 PM
I'm brand new to ROS,linux, and python. I installed Ubunto and ROS, and worked through the beginner tutorials.
Then I installed the Serializer ROS package.
I can launch the serializer package and it connects to the serializer ok.
I can do
rosservice call /serializer/Voltage False
and I get back the voltage so everything is communication ok.
Now I want to start working on my first program in python.
My robot is called Botbert so I did a
$ roscreate-pkg botbert std_msgs rospy roscpp serializer geometry_msgs nav_msgs tf
then I created the bin, launch, src and params subdirectories.
Then I did $ rosmake --rosdep-install

I went into the bin directory and created botbert_test.py
I did a make and then
rosrun botbert botbert_test.py
the program just seems to lock up. I'm sure I screwed it up in a dozen ways so instead of posting it could someone post a simple python program that does a few things with the serializer?
Something easy to understand for us newbies?

Any help will be greatly appreciated.
Ringo

Pi Robot
03-09-2011, 10:09 AM
Hi Ringo,

Good to see you here on the forum! BTW, you don't have to run make or rosmake when adding or changing Python scripts. You only need to do that when using C++. Before I list an example Python script, I can highly recommend the Python tutorial at:

http://docs.python.org/tutorial (http://docs.python.org/tutorial/)

I didn't know a byte of Python before running through this tutorial about 6 months ago. Having said that, if you're a C++ programmer, you don't have to learn Python to do ROS! In fact, some parts of ROS (like PCL) are still primarily C++ oriented.

Here now is a sample node you can try out with the Serializer. First fire up your main Serializer node as you have already succeeded in doing, then launch this node in a separate terminal with the command:

$ rosrun serializer sample_node.py

All this node does is subscribe to the sensors topic and echos back the results once every second. It also tests the value of the first sensor and moves a servo depending on that sensor's value. In my case I have a current sensor on analog pin 0 who's raw value fluctuates between 6.3 and 6.5 so I used a value of 6.4 as a threshold and the servo periodically moves between position -50 and 50.

Here now is the code. Place this file in your bin directory and make sure it is executable by using the command "chmod 755 sample_node.py". Be sure to change the name of the package in the load manifest line from 'pi_robot' to your package name.


#!/usr/bin/env python

"""
sample_node.py - This sample program subscribes to the /serializer/SensorState
topic and echos the results. It also moves a servo on GPIO pin 8 (servo ID 1)
if the value of the first sensor (index 0) is above or below a certain threshold.

Created for the Pi Robot Project: http://www.pirobot.org
Copyright (c) 2011 Patrick Goebel. All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details at:

http://www.gnu.org/licenses/gpl.html
"""

import roslib; roslib.load_manifest('pi_robot')
import rospy
from serializer.srv import *
from serializer.msg import *

class sample_node():
def __init__(self):
# Name this node
rospy.init_node("sample_node")

# Execute this function when shutting down
rospy.on_shutdown(self.shutdown)

# Set the update rate to 1 second by default
self.rate = rospy.get_param("~node_rate", 1)
r = rospy.Rate(self.rate)

# Initialize the sensor value array
self.sensor_state = SensorState()

# Subscribe to the senors topic
rospy.Subscriber('/serializer/sensors', SensorState, self.getSensorState)

# Subscribe the SetServo service
rospy.wait_for_service('/serializer/SetServo')
self.servo_proxy = rospy.ServiceProxy('/serializer/SetServo', SetServo)

# Begin the main loop
while not rospy.is_shutdown():
# Echo back the current sensor values
rospy.loginfo(self.sensor_state)

# Move one of the servos depending on the value of one of the sensors
try:
if self.sensor_state.value[0] > 6.4:
self.servo_proxy(1, 50)
else:
self.servo_proxy(1, -50)
except:
pass

# Sleep for 1/rate seconds
r.sleep()

# Callback for the sensor state subscriber
def getSensorState(self, data):
self.sensor_state = data

# Callback for the SetServo subscriber
def setServo(self, id, position):
try:
return self.servo_proxy(id, position)
except rospy.ServiceException, e:
print "Service call failed: %s"%e

# Shutdown function just prints a message.
def shutdown(self):
rospy.loginfo("Shutting down Sample Node...")

if __name__ == '__main__':
try:
my_node = sample_node()
except rospy.ROSInterruptException:
pass
Hope this helps!
patrick

ringo42
03-09-2011, 10:14 AM
That looks great! thanks. Just what I was looking for.
I have started the python tutorial already. I use C but not C++. I think I'll stick with python for now, it looks pretty friendly.
Thanks Again.
Ringo

Pi Robot
03-09-2011, 10:20 AM
Ooops, the line above that reads:

$ rosrun serializer sample_node.py

should really read:

$ rosrun botbert sample_node.py

if you put the script in your botbert bin directory.

--patrick

ringo42
03-09-2011, 09:11 PM
in the serializer.yaml file

timeout: 1 what is this?
sensor_rate: 10 what are the units (ms or hz)
use_base_controller: True what does this mean?
base_controller_rate: 10 what are the units (ms or hz)
wheel_diameter: 6 what are the units
wheel_track: 8 what are the units

Ringo

Pi Robot
03-09-2011, 09:27 PM
in the serializer.yaml file

timeout: 1 what is this?
sensor_rate: 10 what are the units (ms or hz)
use_base_controller: True what does this mean?
base_controller_rate: 10 what are the units (ms or hz)
wheel_diameter: 6 what are the units
wheel_track: 8 what are the unitsHi Ringo,

Where did you get those parameters? Below is the sample_params.yaml file in the SVN package. Timeout is in seconds, rate is in Hz and all distance measurements are in meters. The use_base_controller parameter is set to True if you want to use the PID controller for doing odometry. If set to True, then the base_controller_rate determines update polling rate in Hz (which is separate from the sensor_rate).

sample_params.yaml


port: /dev/ttyUSB0
baud: 19200
timeout: 1
sensor_rate: 10
#use_base_controller: True
#base_controller_rate: 10
#wheel_diameter: <fill in and uncomment for your robot>
#wheel_track: <fill in and uncomment for your robot>
#encoder_type: 1
#encoder_resolution: <fill in and uncomment for your robot>
#gear_reduction: <fill in and uncomment for your robot>
#motors_reversed: False
#init_pid: True
#units: 0
#VPID_P: <fill in and uncomment for your robot>
#VPID_I: <fill in and uncomment for your robot>
#VPID_D: <fill in and uncomment for your robot>
#VPID_L: <fill in and uncomment for your robot>
#DPID_P: <fill in and uncomment for your robot>
#DPID_I: <fill in and uncomment for your robot>
#DPID_D: <fill in and uncomment for your robot>
#DPID_A: <fill in and uncomment for your robot>
#DPID_B: <fill in and uncomment for your robot>

publish_sensors: True

# Examples only - change accordingly for your robot.
analog: { voltage: {pin: 5, type: Voltage}, drive_current: {pin: 1, type: PhidgetsCurrent}, light_sensor: {pin: 2, type: Analog} }
#digital: { base_sonar: {pin: 5, type: Ping} }

ringo42
03-09-2011, 09:38 PM
I just made up numbers. The serializer is not connected to a robot right now. I just wanted to see if the motor leds would come on. They do !!:-)

Thanks
Ringo

Pi Robot
03-09-2011, 09:40 PM
Cool! I just wanted to make sure I didn't have my old "English unit" numbers lying around in the code somewhere. ROS does everything in meters and radians.

--p

Peter_heim
06-21-2011, 06:44 AM
Hi Patrick
I have 4 sensors published on the topic /serializer/sensors when i do a rostopic echo /serializer/sensors i get
all 4 values how do i get just 1 of them ?


header:
seq: 900
stamp:
secs: 1308652826
nsecs: 263901948
frame_id: sensors
name: ['Accell_y', 'Accell_x', 'battery_current', 'gyro']
value: [2.5, 3.0999999046325684, -6.5, -19.100000381469727]

I 'm after the gyro value i tried [gyro] and [3]

regards peter

Pi Robot
06-21-2011, 08:22 AM
Hi Peter,

Try this:

rostopic echo /serializer/sensors/value[3]

In general, you can drill down a ROS topic by separating the field names by / characters, just like going down subdirectories.

--patrick

ringo42
06-22-2011, 10:29 AM
I see the PING command, is the maxez1 command available? That is what I currently have. The difference is 2 pins versus 1 pin.
Ringo

ringo42
06-22-2011, 12:23 PM
I see here http://www.ros.org/wiki/serializer you mention that the SRF04 (same as maxez) has been implemented but not tested. Can you tell me how to specify a couple of them in the sample_params.yaml file and how to subscribe to them in the python file?
Thanks
Ringo

Pi Robot
06-23-2011, 08:49 AM
Hi Ringo,

The MaxEZ1 is supported at the driver level but I don't yet have a service for it at the node level. I'll add one later today and publish an update to SVN then let you know when it is ready to try.

--patrick

Pi Robot
06-23-2011, 04:19 PM
Hi Ringo,

I've added support for the MaxEZ1--at least what I *think* should work since I don't have one on hand to test it. Use "svn update" in your serializer ROS directory to get the changes. You can look at the end of the updated sample_params.yaml file to see how to add a MaxEZ1 sensor with given trigger and output pins. (The example uses pins 6 and 7 but substitute your own of course. The line is also commented out in the sample file so uncommented in your own file.)

To query the sonar value in your ROS node, subscribe to the '/serializer/sensors' topic as shown in the sample-node.py file in the bin directory:


rospy.Subscriber('/serializer/sensors', SensorState, self.getSensorState)Then in your getSensorState callback, do something like this:


def getSensorState(self, data):
self.sensor_state = data
self.maxez1 = data.value[i]where i is the index of your MaxEZ1 sensor in the sensor array (not the pin number).

Let me know if you run into any trouble.

--patrick

Peter_heim
07-24-2011, 03:44 AM
Hi Patrick
I tried the serializer package with ubuntu 11.4 64bit and the beta version of ros electric and i got this error

self.mySerializer.connect()
File "/home/robbie/ros/serializer/src/serializer_driver.py", line 122, in connect
test = (self.port.readline(eol='>')[0:-3]).strip()
TypeError: readline() takes no keyword arguments
[INFO] [WallTime: 1311496173.025067] Shutting down Serializer Node.
[serializer-2] process has died [pid 2479, exit code 1].
log files: /home/robbie/.ros/log/e34f960c-b5ce-11e0-a81a-0023cdfebf39/serializer-2*.log

11.4 uses pyserial 2.5 could this be similar to the windows pyserial bug we had in windows?
peter

Pi Robot
07-25-2011, 08:19 AM
Hi Peter,

I don't have 11.4 or 64-bit so I just tried it on my trusty Lucid machine (10.04LTS 32-bit) under ROS Electric beta and PySerial 2.3 and it still works fine. So perhaps you can try downgrading your PySerial to 2.3 to see if that fixes it.

--patrick

lnxfergy
07-25-2011, 12:30 PM
self.mySerializer.connect()
File "/home/robbie/ros/serializer/src/serializer_driver.py", line 122, in connect
test = (self.port.readline(eol='>')[0:-3]).strip()
TypeError: readline() takes no keyword arguments
[INFO] [WallTime: 1311496173.025067] Shutting down Serializer Node.
[serializer-2] process has died [pid 2479, exit code 1].
log files: /home/robbie/.ros/log/e34f960c-b5ce-11e0-a81a-0023cdfebf39/serializer-2*.log


This is a really interesting error -- because as far as I can tell from browsing the SVN commit history of PySerial, readline has always taken eol as a keyword argument -- sounds like this could be a bug in PySerial and should be forwarded to the developers.

Also, have you modified the serializer drivers? Looking at Patrick's SVN, I don't find a "serializer_driver.py"...

-Fergs

Pi Robot
07-25-2011, 01:04 PM
Hey Fergs,

The file serializer_driver.py is there in SVN but it is tucked under src rather than bin. Also, I think you may be right about there being a bug in PySerial 2.5 as I think I ran into Peter's exact same issue a few moons ago but couldn't spend time on it then...

--patrick

lnxfergy
07-25-2011, 01:20 PM
And here we go: bug status "won't fix": http://sourceforge.net/tracker/?func=detail&aid=3118719&group_id=46487&atid=446302

-Fergs

Pi Robot
07-25-2011, 01:34 PM
Dang--bit of a mess there. Good find on the ticket...

--patrick

Peter_heim
07-26-2011, 05:22 PM
Hi Patrick
I downgraded to pyserial 2.3 and every thing works
peter

Pi Robot
07-26-2011, 07:05 PM
Hi Peter,

That's great! Not the best solution, I admit, but at least you are up and running again.

--patrick

ringo42
07-29-2011, 12:56 PM
Patrick, is odometry published automatically when the serializer service is running? If not is it something you enable, or do you have to write a node to publish something in a loop?
Thanks
Ringo

Pi Robot
07-29-2011, 01:24 PM
Hi Ringo,

Yes, as long as you have the parameter use_base_controller set to True in your params file (which I think you do since we talked earlier about tweaking the PID parameters), odometry info will be published on the /odom topic. So once you fire up your serializer node, you can do a 'rostopic echo /odom' in another terminal to see if you are getting data.

--patrick

ringo42
08-02-2011, 05:55 PM
It is set to true. When I start the serialized stack it says it is publishing odometry at 10 Hz.
Rostopic list shows Odom. But rostopic echo /Odom shows nothing. It just waits. Also in rviz I added odometry and topic Odom but it says no messages received. Am I missing something?

ringo42
08-02-2011, 06:17 PM
It is set to true. When I start the serializer stack it says it is publishing odometry at 10 Hz.
Rostopic list shows Odom. But rostopic echo /Odom shows nothing. It just waits. Also in rviz I added odometry and topic Odom but it says no messages received. Am I missing something?

ringo42
08-02-2011, 06:22 PM
I just noticed that nothing works like not even rosservice call /serialized/Voltage false.
What did ibreak?

Pi Robot
08-02-2011, 07:41 PM
Hi Ringo,

Perhaps you are just typing "/Odom" with a capital O in your message, but the topic name is actually "/odom" with a lower case "o". You won't see anything on "/Odom" as it doesn't exist. Of course, this doesn't explain your problem that nothing else is working--I don't suppose by any chance you just upgraded your Linux to a new version of Ubuntu? Peter Heim found that Ubuntu 11.4 uses PySerial 2.5 which breaks my current serializer ROS driver. He had to downgrade his PySerial back to 2.3 to get it working again.

--patrick

ringo42
08-02-2011, 08:09 PM
My phone keeps changing things on me. I had the little o.
I have not upgraded anything, still running 10.10

Serial is obviously working because when I start the serializer it reports the battery voltage.
I get this

Connecting to Serializer on port /dev/ttyUSB0 ...
Connected at 19200 baud. Current voltage: 9.08203125
Updating Units and PID parameters.
[INFO] [WallTime: 1312333624.351582] Starting Serialzier base controller...
[INFO] [WallTime: 1312333624.387893] Started Base Controller 'Serializer PID' for a base of 0.2032m wide with 1503.0 ticks per meter
[INFO] [WallTime: 1312333624.389365] Publishing Odometry data at: 10.0 Hz

and rostopic gives me this

[email protected]:~/SVN/stuff/linux$ rostopic list
/cmd_vel
/odom
/rosout
/rosout_agg
/serializer/sensors
/tf
[email protected]:~/SVN/stuff/linux$ rostopic echo /odom

Any other thoughts?
Ringo

ringo42
08-02-2011, 08:19 PM
I figured it out. The Maxez was disconnected. I removed it from the yaml file and it started working.
Is there any way to fix that? 1 sensor fails and it all stops working.
Ringo

Pi Robot
08-03-2011, 09:53 AM
Hi Ringo,

Glad you figured it out and thanks for reporting the bug (which I just confirmed). Seems the trigger pulse on the MaxEZ (or a Ping sensor) is not timing out when the sensor is not attached so everything just waits forever. I'll post back when I have a fix.

--patrick