This package is used to control the robot in the CoppeliaSim environment using the go_to_point behavior. A random goal pose is generated, and the robot aligns itself toward that point.
The robot first sets its linear velocity to move toward the goal position. Once the goal position is reached, it adjusts its angular position to match the required orientation. If the robot is not stopped, this process continues in a loop by generating a new target destination and pose.
The go_to_point behavior is implemented as a server. The robot can be stopped only when it reaches the goal, and it will restart when a new goal is generated. This process continues in a loop when the robot receives the stop command.
dr20_ros_ctrl: Lua script used to control the DR20 mobile robot from the ROS environment.- This script does not use an action server, so when the user sends a stop command, the robot stops only after reaching the target.
go_to_point: Implements a service to drive the robot toward a point in the Gazebo/CoppeliaSim environment.
It publishes velocity commands on/cmd_veland reads robot position from/odom.user_interface: Prompts the user to start or stop the robot and calls the service implemented in the finite state machine node.
position_server: Implements a random position service. It returns random values forx,y, andtheta, wherexandyare limited between minimum and maximum values.state_machine: Controls the robot behavior by starting or stopping it and by requesting a new goal pose when needed. It sends the goal to thego_to_pointaction server.
├── CMakeLists.txt
├── coppeliaros.gif
├── dr20_ros_ctrl_Vrep.ttt
├── index.html
├── launch
│ ├── ros_2.launch
│ ├── ros2_sim.launch
│ └── vrep.launch
├── package.xml
├── scripts
│ ├── go_to_point.py
│ └── user_interface.py
├── src
│ ├── position_service.cpp
│ └── state_machine.cpp
├── srv
│ ├── Command.srv
│ ├── Position.srv
│ └── RandomPosition.srv
└── urdf
└── my_robot.urdfBefore running this package, make sure you have:
- ROS installed.
- CoppeliaSim installed.
- A ROS workspace configured correctly.
- Required dependencies for the package installed.
Open a terminal and source your ROS1 workspace:
source ~/catkin_ws/devel/setup.bashUse the provided launch file to start all required nodes:
roslaunch rt2_assignment1 vrep.launchIn a second terminal, run the following command to open CoppeliaSim:
../CoppeliaSim_Edu_V4_2_0_Ubuntu20_04/.coppeliaSim.shOnce CoppeliaSim starts, the robot should be controlled by the ROS nodes and begin interacting with the environment.
- The robot behaves in a loop by generating new random goal poses.
- The stop command takes effect after the robot reaches the current target.
- Make sure the workspace is sourced before launching the simulation.
- Ensure the launch file paths match your local workspace setup.
Muhammad Malook Bugti