--Consists of NuSMV Encoding--
--Consists of a ros2 workspace--
--Consists of the Gazebo .sdf files for simulating 3D environment and vehicles--
5. my_car_controller [Final deployment package]
This package consists of the following files
- init.py
- moveTurtle.py
- turtle_publisher.py
- turtle_subscriber.py
- advanced_turtle1.py
- advanced_turtle2.py
- advanced_turtle3.py
It initialises the python package and marks the directory as a package.
It consists of the class MoveTurtle class which creates a publisher to control the turtle movement and subscriber to receive the co-ordinates of the turtle in the same terminal.
The turtle movement is controlled to draw a circle by changing the linear velocity, angular velocity and angle of the turtlesim node.
Run the code following the instructions at the end and using the name moveTurtle.
rclpy
Node from rclpy.node
Twist from geometry_msgs.msg
Pose from turtlesim.msg
It consists of the class TurtlePublisher which controls the turtlesim node to move in a circle.
The turtle movement is controlled to draw a circle by changing the linear velocity, angular velocity and angle of the turtlesim node.
Run the code following the instructions at the end and using the name turtle_publisher.
rclpy
Node from rclpy.node
Twist from geometry_msgs.msg
time
It consists of the class "TurtleSubscriber" which receoves the messages from the turtlesim node x and y coordinates.
Run the code following the instructions at the end and using the name turtle_subscriber.
rclpy
Node from rclpy.node
Pose from turtlesim.msg
It is used to control the movement of the turtlesim node by implementing a Behavior Tree (BT).
It consists of the class
- "MoveForward" which inherits from the py_trees.behavior.Behavior and moves the turtlesim node forward.
- "ZigZag" which turns the turtle left and right to move in a zigzag motion
The BT structure is as below:
Sequence (Root)
|
|-- MoveForward (Action node)
|
|-- Zigzag (Action node)
The main function is used to define the structure of BT.
Run the code following the instructions at the end and using the name advanced_turtle1.
py_trees
rclpy
Node from rclpy.node
Twist from geometry_msgs.msg\
It is used to control the movement of the turtlesim node by implementing a Behavior Tree (BT).
It consists of the class
- "MoveForward" which inherits from the py_trees.behavior.Behavior and moves the turtlesim node forward.
- "ZigZag" which turns the turtle left and right to move in a zigzag motion
- "RotateClockwise" which rotates the turtle clockwise using the angular component of the node.
- "RotateCounterClockwise" which rotates the turtle counter-clockwise using the angular component of the node.
The BT structure is as below:
Sequence (Root: Sequence node)
|
|-- MoveForward (Action node)
|
|-- Zigzag (Action node)
|
|-- RotateClockwise (Action node)
|
|-- RotateCounterClockwise (Action node)\
The main function is used to define the structure of BT.
Run the code following the instructions at the end and using the name advanced_turtle2.
py_trees
rclpy
Node from rclpy.node
Twist from geometry_msgs.msg
It is used to control the movement of the turtlesim node by implementing a Behavior Tree (BT).
It consists of the class
- "MoveForward" which inherits from the py_trees.behavior.Behavior and moves the turtlesim node forward.
- "ZigZag" which turns the turtle left and right to move in a zigzag motion
- "RotateClockwise" which rotates the turtle clockwise using the angular component of the node.
- "RotateCounterClockwise" which rotates the turtle counter-clockwise using the angular component of the node.
The BT structure is as below:
RootSelector (Root : Selector node)
|
|-- ForwardNode (Sequence node)
| |
| |-- MoveForward (Action node)
| |
| |-- Zigzag (Action node)
|
|-- RotationNode (Sequence node)
|
|-- RotateClockwise (Action node)
|
|-- RotateCounterClockwise (Action node)\
The main function is used to define the structure of BT.
Run the code following the instructions at the end and using the name advanced_turtle3.
py_trees
rclpy
Node from rclpy.node
Twist from geometry_msgs.msg
This package consists of the following executable files
my_behavior_tree.cpp
my_behavior_tree implements a basic Behavior tree (BT) which inherits from behaviortree_cpp C++ package. This file executes a BT by traversing the xml file /behavior_trees/my_behavior_tree.xml. As the BT is executed the output is printed in the console.
The contents of my_behavior_tree.xml are given below,
- MainTree
- Sequence (RootSequence)
- MoveForward
- TurnLeft
- MySelector (BatteryCheckSelector)
- CheckBattery
- Sequence (MoveTurnSequence)
- MoveRight
- StopMovement
- Sequence (RootSequence)
We see the following ouput in the console:
Update the path in the my_behavior_tree.cpp file for the xml file as in your local directory before running the code. Run the file following the instructions at the end and using the name my_behavior_tree.
behaviortree_cpp
iostream
This package consists of the following executable files
my_turtle_behavior.cpp
my_turtle_behavior implements a Behavior tree (BT) which inherits from behaviortree_cpp C++ package. This file executes a BT by traversing the xml file /behavior_trees/my_turtle_behavior.xml. As the BT is executed the turtlesim node is controlled to trace the path in a hexagon fashion.
The behavior tree which is stored in the xml as follows:
- MainTree
- Sequence
- Sequence
- MoveForward
- RotateClockwise
- Sequence
- MoveForward
- RotateClockwise
- Sequence
- MoveForward
- RotateClockwise
- Sequence
- MoveForward
- RotateClockwise
- Sequence
- MoveForward
- RotateClockwise
- Sequence
- MoveForward
- RotateClockwise
- Sequence
- MoveForward
- RotateClockwise
- Sequence
- Sequence
Update the path in the my_turtle_behaviore.cpp file for the xml file as in your local directory before running the code. Run the file following the instructions at the end and using the name my_turtle_controller.
behaviortree_cpp
rclcpp
geometry_msgs
turtlesim\
This package consists of the following executable files
- my_car_controller.cpp
my_car_controller implements a Behavior tree (BT) which inherits from behaviortree_cpp C++ package. This file executes a BT by traversing the xml file /behavior_trees/my_car_behavior.xml. As the BehaviorTree is traversed it interacts with the simulated bot in the Gazebo environment. It publishes in the /cmd_vel topic to control the movement of the car. It also subscribes to the lidar and contact information for autonmous navigation.
Update the path in the my_car_controller.cpp file for the xml file as in your local directory before running the code.
Run the file following the instructions at the end and using the name my_car_controller.
behaviortree_cpp
rclcpp
geometry_msgs\
- Environment_1.sdf -- Simulation environment with contact sensors and autonomous vehicle with lidar sensor.
- Environment_2.sdf -- Simulation environment with an actor and autonomous vehicle with lidar sensor.
Reference : https://github.com/gazebosim/docs/blob/master/fortress/tutorials/moving_robot/moving_robot.sdf
It is a 3D world with a differential drive robot.
-
Navigate to the ros2_ws in the terminal (ros2 workspace : cd ros2_ws)
-
execute the command "colcon build" or for particular packages use command : "colcon build --packages-select name-of-pkg"
-
execute the command : "source install/setup.bash"
-
If the executable is for a turtlesim node run command : ros2 run turtlesim turtlesim_node
-
Run the desired file by executing the command : ros2 run "package name" "access name". Access name is the same as the file name without the extension (e.g. .py for python)
- For Gazebo Fottress use the command "ign gazebo file_name.sdf"
- Establish a bridge between ROS2 ansd Gazebo topic run the command "ros2 run ros_gz_bridge parameter_bridge /cmd_vel@geometry_msgs/msg/Twist]ignition.msgs.Twist"
- Establish a bridge for Lidar "ros2 run ros_gz_bridge parameter_bridge /lidar@sensor_msgs/msg/LaserScan[gz.msgs.LaserScan"
- Establish a bridge for contact sensor "ros2 run ros_gz_bridge parameter_bridge /wall/touched@std_msgs/msg/Bool[gz.msgs.Boolean"