by:
George Knibbs
Henrique Mira
Ivan Li Hoi Him
Luke Sykes
Youssef Hany
-In [workspace name]/src/[package name]
, ie: ~/ros_workspace/src/rosbot_bath
, REPLACE:
- package.xml
- CMakeLists.txt
with the ones in this folder, or you can modify the files yourself, guides below.
-In [workspace name]/src/[package name]/src
, ie: ~/ros_workspace/src/rosbot_bath/src
, ADD:
- distanceHandler.py
- lidarHandler.py
- objectAvoid.py
- terminate.py
- yawHandler.py
basically all the .py scripts in the "SCRIPTS" folder
-In [workspace name]/src/[package name]/srv
, ie: ~/ros_workspace/src/rosbot_bath/srv
, ADD:
- distanceHandler.srv
-In [workspace name]/src/[package name]/msg
, ie: ~/ros_workspace/src/rosbot_bath/msg
, ADD:
- lidarHandler.msg
-In [workspace name]/src/[package name]/launch
, ie: ~/ros_workspace/src/rosbot_bath/launch
, ADD:
- rosbot_test.launch
- Make them executable programs (either by checking the option in file properties tab/ do "chmod +x [path to file]/[filename]")
- Do "catkin_make" (and probably "source /devel.setup.sh") after doing all the modifications required
In [workspace name]/src/[package name]
, ie: ~/ros_workspace/src/rosbot_bath
:
1: ./run_rosbot.sh
In separate terminal, in [workspace name]
, ie: ~/ros_workspace
:
2: roslaunch [package name] [launch file name]
, ie: roslaunch rosbot_bath rosbot_test.launch
- instead of having the only logic script subscribing to all the sensory data and doing all the logic stuff to process them,
- we now have different nodes subscribed to different sensors, process them into data used by the logic handling program,
- then publish/respond-when-needed the data to the logic node for all the fancy stuff
-
The processing/ logic itself is 99.9% identical to its original version, only split into different scripts with extra lines of code to link them up.
-
If you run the scripts as intended it the rosbot should behave exactly as before.
-
However, this assumes the original logic works fine, and you already understand what's going on.
-
For a visual on how the structure has changed, please refer to "Ros Structure Comparison.png"
NOTE: The way the logic node interacts with the controls of the robot is completely untouched, as I'm tired AF and this is the part where we can add action nodes, which I have 0 clue how they work.
- the new TOPICS have the same names as the new NODES and new SCRIPTS because I'm not sure which is which either and I can't be bothered to change them now
- The Proxy Sensors are used directly in the code and they are needed constantly, so they are directly PUBLISHED to the logic node
- takes imu data by subscribing to
/imu
- does the euler thing to turn them into understandable orientations
- change the measurement of
current_yaw
(the only orientation we care about) from radians to degrees - measure difference from ideal orientation (0 degrees)
- PUBLISHES with the topic
yawHandler
of the difference in yaw as that's all we care about
- The odomHandler needs constant update on robot orientation to do fwd_distance measurements, topic is preferred, else service would have been fine as the data is only needed during CORRECTION state of the robot
- takes odom data by SUBSCRIBING to
/odom
- does the distance formula things
- takes yaw error data by SUBSCRIBING to
yawHandler
- calculates forward distance by normalizing the distance traveled based on the angle 4.5. this method might not be right, could be modified later but right now, idc
- responds the data with topic
distanceHandler
as a SERVICE
- The distance logging is just for data logging, just call it occasionally and on code termination
- new .srv file as distanceHandler returns to distance data:
total_distance
: total distance the robot has traveled in all 4 directionstotal_fwd_distance
: total distance the robot has traveled FORWARDS
- takes the massive array of lidar values from
/LaserScan
- does the split-lidar-data-into-quadrants thing
- PUBLISHES the 3 data values with topic
lidarHandler
- The bot constantly searches stuff with lidar data 24/7, it's better to use topics for constant data updates
- custom .msg file cause the script publishes 3 float32 datas for:
- front
- right
- left
- Same Script as the old test.py, but with the sensory logic functions removed
- renamed for convenience
- Simply here to request and log distance info from odomHandler on program termination
- runs all the scripts at once
- you still need a separate terminal to do
./run_rosbot.sh
though
- needed so that the new .srv and .msg files could work
- clearer structure now that the big code is separated into smaller ones
- better resource management as less important functions are now services that only run when needed
- better division of labor as more people can work on different parts of the robot instead of everyone diving into the same code
- probably some sort of more efficient debugging/failsafe that I need time to think about how to BS through
Have something like this:
find_package(catkin REQUIRED COMPONENTS
roscpp tf
rospy
std_msgs
message_generation
)
...
## Generate messages in the 'msg' folder
add_message_files(
FILES
lidarHandler.msg
)
## Generate services in the 'srv' folder
add_service_files(
FILES
distanceHandler.srv
# Service1.srv
# Service2.srv
)
## Generate actions in the 'action' folder
add_action_files(
FILES
objectAvoid.action
# Action1.action
# Action2.action
)
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
actionlib_msgs
std_msgs
# Or other packages containing msgs
)
...
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES rosbot_bath
CATKIN_DEPENDS roscpp
std_msgs
# DEPENDS system_lib
)
--------------------------------------------------------------------------
package.xml MODIFICATIONS:
Have something like:
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
<build_depend>actionlib_msgs</build_depend>
<exec_depend>actionlib_msgs</exec_depend>
---
commented code stuff
---
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_export_depend>roscpp</build_export_depend>
<exec_depend>roscpp</exec_depend>
<build_depend>std_msgs</build_depend>
<exec_depend>std_msgs</exec_depend>
---
uncommented code stuff
---
--------------------------------------------------------------------------