Skip to content

Commit 2257426

Browse files
committed
Add ROS Sensor, Odometry, Base controller and mapping
1 parent c86a781 commit 2257426

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

Courses/ROS/Tutorials.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,8 +2128,86 @@ add_executable(tf_listener src/tf_listener.cpp)
21282128
target_link_libraries(tf_broadcaster ${catkin_LIBRARIES})
21292129
target_link_libraries(tf_listener ${catkin_LIBRARIES})
21302130
```
2131+
### Sensor Information
2132+
Navigation stack uses information from sensors to avoid obstacles in the world. It assumes that sensors are publishing sensor_msgs/Laserscan. The data structure is printed below
2133+
```
2134+
# Single scan from a planar laser range-finder
2135+
#
2136+
# If you have another ranging device with different behavior (e.g. a sonar
2137+
# array), please find or create a different message, since applications
2138+
# will make fairly laser-specific assumptions about this data
2139+
2140+
Header header # timestamp in the header is the acquisition time of
2141+
# the first ray in the scan.
2142+
#
2143+
# in frame frame_id, angles are measured around
2144+
# the positive Z axis (counterclockwise, if Z is up)
2145+
# with zero angle being forward along the x axis
2146+
2147+
float32 angle_min # start angle of the scan [rad]
2148+
float32 angle_max # end angle of the scan [rad]
2149+
float32 angle_increment # angular distance between measurements [rad]
2150+
2151+
float32 time_increment # time between measurements [seconds] - if your scanner
2152+
# is moving, this will be used in interpolating position
2153+
# of 3d points
2154+
float32 scan_time # time between scans [seconds]
2155+
2156+
float32 range_min # minimum range value [m]
2157+
float32 range_max # maximum range value [m]
2158+
2159+
float32[] ranges # range data [m] (Note: values < range_min or > range_max should be discarded)
2160+
float32[] intensities # intensity data [device-specific units]. If your
2161+
# device does not provide intensities, please leave
2162+
# the array empty.
2163+
```
2164+
There is a tutorial on write a node for publishing sensor data over sensor_msgs/Laserscan [here](http://wiki.ros.org/navigation/Tutorials/RobotSetup/Sensors). Most commercial LIDARs provide ros packages which contains nodes for publishing over sensor_msgs/Laserscan.
2165+
2166+
2167+
### Odometry
2168+
The navigation stack requires that odometry information be published using tf and nav_msgs/Odometry message.
2169+
2170+
We will understand how to publish the nav_msgs/Odometry information over ROS and the transform from 'odom` frame to `base_link` frame over tf2.
2171+
2172+
The navigation stack uses tf to determine the location of the robot in the world. However, tf does not provide velocity information. Therefore navigation stack requires that any odometry source publish both transform and Odometry messages over ROS. We will look at example code that accomplishes this task.
2173+
2174+
2175+
Odometry message stores an estimate of the position and velocity of a robot in the odometric frame along with covariance for the certainity of the pose estimate. The twist in the message corresponds to robot's velocity in child frame, normally the coordinate frame of the mobile base and the covariance of the velocity estimate.
2176+
```
2177+
Header header
2178+
string child_frame_id
2179+
geometry_msgs/PoseWithCovariance pose
2180+
geometry_msgs/TwistWithCovariance twist
2181+
```
21312182
2183+
### Base Controller
2184+
Navigation stack assumes that it can send `geometry_msgs/Twist` messages assumed to be in the base coordinate frame of the robot on the `cmd_vel` topic. This means there must be a node subscribing to the `cmd_vel` topic that is capable of taking the Twist message (vx, vy and vtheta) and converting them into motor commands to send to a mobile base.
21322185
2186+
### Mapping
2187+
see [here](http://wiki.ros.org/slam_gmapping/Tutorials/MappingFromLoggedData#record)
2188+
Here we will learn how to create a 2D map for navigation purposes from logger transform and laser scan data.
2189+
2190+
1. First create a bag file for scan data - it can be one geenrated from the robot or download an existing one
2191+
2192+
2. Bring up the master
2193+
```
2194+
roscore
2195+
```
2196+
3. Set the parameter `use_sim_time` to true before starting any nodes
2197+
4. start `slam_gmapping` node and which will injest the laser scan data and create a map.
2198+
```
2199+
> rosrun gmapping slam_gmapping scan:=base_scan
2200+
```
2201+
Note that we had previously genrated a bag file with Odometry published over topic /base_scan.
2202+
5. In a new terminal start playing back the bag file to feed data to slam_gmapping.
2203+
```
2204+
> rosbag play --clock <name of the bag that you downloaded / created in step 2>
2205+
```
2206+
6. Save map to disk
2207+
```
2208+
> rosrun map_server map_saver -f <map_name>
2209+
```
2210+
You now have a map saved locally as **map.pgm**.
21332211
21342212
21352213
## References

0 commit comments

Comments
 (0)