diff --git a/PARTICIPANTS_TODO.md b/PARTICIPANTS_TODO.md index 8e4e7e1..82a4bff 100644 --- a/PARTICIPANTS_TODO.md +++ b/PARTICIPANTS_TODO.md @@ -40,17 +40,13 @@ Read [this](https://github.com/remaro-network/tudelft_hackathon#installation) fi #### Run bluerov agent * Run the bluerov agent both in the real BlueROV2 and in Gazebo (Ignition) -* Complete the [random wall avoidance](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/random_wall_avoidance.py) code and run it both in the real BlueROV2 and Gazebo (Ignition) (solution on [90e272a](https://github.com/remaro-network/tudelft_hackathon/blob/90e272a09d1053d0afcec1402f8cc63476f0c6cc/scripts/random_wall_avoidance.py)) +* Complete the [potential_avoidance]((https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/potential_avoidance.py) code and run it both in the real BlueROV2 and Gazebo (Ignition). Issue [#36](https://github.com/remaro-network/tudelft_hackathon/issues/36). #### Improve the system Suggestions: +* Issues marked with `hackathon_task` label. You can find them in this [project tab](https://github.com/remaro-network/tudelft_hackathon/projects/2) * Better avoidance algorithm * Adjust velocity parameters and sonar "field-of-view" -* Test sonar data with SLAM algorithm ([#4](https://github.com/remaro-network/tudelft_hackathon/issues/4)) -* Add visual to bluerov in ignition ([#8](https://github.com/remaro-network/tudelft_hackathon/issues/8)) -* Prevent the bluerov to go over the walls ([#12](https://github.com/remaro-network/tudelft_hackathon/issues/12)) -* Change Ignition initial world camera position ([#13](https://github.com/remaro-network/tudelft_hackathon/issues/13)) -* Add model for bluerov2 heavy kit version ([#14](https://github.com/remaro-network/tudelft_hackathon/issues/14)) * More elaborated world * Improve launch files * Improve formatting diff --git a/README.md b/README.md index 6bec0a0..78ae931 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,11 @@ can begin to understand the challenges and differences of deploying a robot in s The use case selected for this training is “wall avoidance”. Basically, the goal is for the robot to navigate an environment and not crash into walls using only sonar data. An initial code for a random -avoidance mission is provided with missing parts, and the idea is for participants to complete the -code and work to develop better missions through training or improve the system in general. +avoidance mission is provided, and the idea is that participants work to develop better missions during this training and improve the system in general. More details on instructions for participants can be found in the [PARTICIPANTS_TODO](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/PARTICIPANTS_TODO.md) -You can check the intended behavior on the video: +You can check the random wall avoidance behavior on the video: [![Youtube video](https://user-images.githubusercontent.com/20564040/175087210-6706607d-c2db-4b25-888e-1973e3d093fb.png)](https://www.youtube.com/watch?v=Zv-int_BIJw) @@ -29,15 +28,17 @@ You can find some slides with useful information here (**ADD SLIDES LINK**) You can find a system architecture of the system developed here (**ADD ARCHITECTURE LINK**) ## Summary -- [Computer setup](https://github.com/remaro-network/tudelft_hackathon#computer-setup) +- [Computer setup](https://github.com/remaro-network/tudelft_hackathon#setup) - [Bluerov setup](https://github.com/remaro-network/tudelft_hackathon#bluerov-setup) -- [Install prerequisites to run with docker](https://github.com/remaro-network/tudelft_hackathon#install-prerequisites) -- [Install locally](https://github.com/remaro-network/tudelft_hackathon#install-locally) +* [Installation](https://github.com/remaro-network/tudelft_hackathon#installation) + - [Install prerequisites to run with docker](https://github.com/remaro-network/tudelft_hackathon#install-prerequisites-to-run-with-docker) + - [Install locally](https://github.com/remaro-network/tudelft_hackathon#install-locally) - [Run it with docker via CLI](https://github.com/remaro-network/tudelft_hackathon#run-it-with-docker-via-cli) -- [Run with docker with VSCode ](https://github.com/remaro-network/tudelft_hackathon#run-it-with-docker) +- [Run with docker with VSCode ](https://github.com/remaro-network/tudelft_hackathon#run-it-with-docker-with-vscode) - [Run locally](https://github.com/remaro-network/tudelft_hackathon#run-it-locally) - [Explanation](https://github.com/remaro-network/tudelft_hackathon#explanation) -- [Additional information](https://github.com/remaro-network/tudelft_hackathon#additional-information) +- [Exercises](https://github.com/remaro-network/tudelft_hackathon#exercises) +- [Additional information](https://github.com/remaro-network/tudelft_hackathon#additional-info) - [Acknowledgments](https://github.com/remaro-network/tudelft_hackathon#acknowledgments) ## Setup @@ -76,7 +77,7 @@ In those cases go for the [local installation](https://github.com/remaro-network - Install docker on your machine. You can find instructions [here](https://docs.docker.com/engine/install/ubuntu/) - Allow non-root users to manage docker. Instructions [here](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user) - Install VSCode. Instructions [here](https://code.visualstudio.com/download) -- Install [nvidia-docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker) +- Install [nvidia-docker](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)(only needed if you have a nvidia GPU) ### Configure computer to connect with the BlueROV2 Follow [Bluerobotics instructions](https://bluerobotics.com/learn/bluerov2-software-setup/#software-introduction) @@ -123,6 +124,12 @@ If you want to use MAC, follow [this instruction](https://ardupilot.org/dev/docs #### Install ardusub_plugin +**IMPORTANT:** Clone into the ignition-garden instead of fortress: + +```Bash +$ git clone https://github.com/ArduPilot/ardupilot_gazebo -b ignition-garden +``` + Install ardupilot_gazebo plugin following the instructions in the [repo](https://github.com/ArduPilot/ardupilot_gazebo/tree/ignition-garden) #### Install hackathon workspace @@ -338,7 +345,7 @@ A `service_timer` timer is created with 2Hz rate. Then we have a while loop that After that, we create a new timer with 0.5Hz rate. The `ardusub.toogle_rc_override(True)` method is called to make the ardusub node start publishing messages in the `/mavros/rc/override` topic. Then, we use the method `ardusub.set_rc_override_channels(forward=0.5)` to make the robot move forward with half of its thrust, this is achieved internally by the ardusub node by publishing the appropriate message in the `/mavros/rc/override` topic. Following, the program sleeps for 2 seconds and then we make the robot move again to other directions, in order to go "around" a square. And that is it. -The [random_wall_avoidance](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/random_wall_avoidance.py) has the following behavior. The robot set its flight mode to `MANUAL`, then arms the thrusters, then starts moving forward. The agent subscribes to the sonar topic and every time it receives sonar readings it checks if there is an obstacle in its front, e.g. 180°, closer than a certain threshold, e.g. 1m, and in case there is it rotates randomly until there are no more obstacle. (This node should be completed during the hackathon, a solution can be found in [90e272a](https://github.com/remaro-network/tudelft_hackathon/blob/90e272a09d1053d0afcec1402f8cc63476f0c6cc/scripts/random_wall_avoidance.py)). For this, the agent uses the topics & services listed in the mavros section, and the `/scan` topic described in the ping360 driver section. +The [random_wall_avoidance](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/random_wall_avoidance.py) has the following behavior. The robot set its flight mode to `ALT HOLD`, then arms the thrusters, then starts moving forward. The agent subscribes to the sonar topic and every time it receives sonar readings it checks if there is an obstacle in its front, e.g. 180°, closer than a certain threshold, e.g. 1.25m, and in case there is it rotates randomly until there are no more obstacle. For this, the agent uses the topics & services listed in the mavros section, and the `/scan` topic described in the ping360 driver section. ### Simulated BlueROV2 @@ -372,7 +379,9 @@ Note that the topic where the lidar data is published has the same name (`/scan` ## Exercises -Check [PARTICIPANTS_TODO](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/PARTICIPANTS_TODO.md#activities-to-be-done-during-hackathon). The main task is to complete the [random wall avoidance algorithm](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/scripts/random_wall_avoidance.py). +The main exercise of this training is to implement an avoidance algorithm based on potential fields, you can find more info on the issue [#36](https://github.com/remaro-network/tudelft_hackathon/issues/36). + +Check [PARTICIPANTS_TODO](https://github.com/remaro-network/tudelft_hackathon/blob/ros2/PARTICIPANTS_TODO.md#activities-to-be-done-during-hackathon) for extra info. ## Additional info diff --git a/scripts/random_wall_avoidance.py b/scripts/random_wall_avoidance.py index bc6dabd..620b4c5 100755 --- a/scripts/random_wall_avoidance.py +++ b/scripts/random_wall_avoidance.py @@ -13,16 +13,17 @@ def laser_scan_cb(msg, ardusub): min_distance = 1.25 yaw_speed = 0.3 forward_speed = 0.12 - - # TODO: Do something with the sonar msg in order to make the robot not - # crash into the walls - # - # CHEAT: - # LaserScan msg definition can be found here: https://docs.ros2.org/latest/api/sensor_msgs/msg/LaserScan.html - # Before checking the solution provided, check this example: - # https://github.com/gazebosim/docs/blob/master/citadel/sensors.md#avoid-the-wall + allGreater = True for scan in msg.ranges: - pass + if scan < min_distance: + allGreater = False + _yaw_speed = (-1)**random.choice([1, 2])*yaw_speed + ardusub.set_rc_override_channels( + forward=-forward_speed/4, + yaw=_yaw_speed) + break + if allGreater: + ardusub.set_rc_override_channels(throttle=0, pitch=0, forward=forward_speed) if __name__ == '__main__': @@ -36,21 +37,24 @@ def laser_scan_cb(msg, ardusub): thread = threading.Thread(target=rclpy.spin, args=(ardusub, ), daemon=True) thread.start() - # TODO: Set flight mode to MANUAL, STABILIZE or DEPTH HOLD + service_timer = ardusub.create_rate(2) + while ardusub.status.mode != "ALT_HOLD": + ardusub.set_mode("ALT_HOLD") + service_timer.sleep() - print("Manual mode selected") + print("ALT HOLD mode selected") - # TODO: Arm motors + while ardusub.status.armed == False: + ardusub.arm_motors(True) + service_timer.sleep() print("Thrusters armed") print("Initializing mission") - # TODO: start publishing on /mavros/rc/override - - # TODO: start moving forward + ardusub.toogle_rc_override(True) + ardusub.set_rc_override_channels(throttle=0.0, pitch=0.0, forward=0.12) - # Sonar subscriber laser_subscriber = ardusub.create_subscription( LaserScan, '/scan', (lambda msg: laser_scan_cb(msg, ardusub)), 10)