... | @@ -137,7 +137,13 @@ At this point, your node is not doing anything interesting. First we will make o |
... | @@ -137,7 +137,13 @@ At this point, your node is not doing anything interesting. First we will make o |
|
|
|
|
|
Before starting, you should study the [official python tutorial](https://docs.ros.org/en/galactic/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html) or the [official C++ tutorial](https://docs.ros.org/en/galactic/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html).
|
|
Before starting, you should study the [official python tutorial](https://docs.ros.org/en/galactic/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html) or the [official C++ tutorial](https://docs.ros.org/en/galactic/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html).
|
|
|
|
|
|
Modify the publisher example to instead publish a ```geometry_msgs/msg/Twist``` (you can import it from ```import geometry_msgs.msg```) with a linear velocity of ```0.1``` and angular velocity of ```0.05```. My advice is to copy/paste the publisher example from the documentation in your ```lab2_node.py``` or ```lab2_node.cpp``` file, try to run it, check that it works by using ```rostopic echo``` or ```rqt```. And once it works, do the modification needed.
|
|
Modify the publisher example to instead publish a ```geometry_msgs/msg/Twist``` (you can import it from ```import geometry_msgs.msg```) with a linear velocity of ```0.1``` and angular velocity of ```0.05```. We strongly advise that you follow the an incremental approach:
|
|
|
|
|
|
|
|
* Copy/paste the publisher example from the respective tutorials into your ```lab2_node.py``` or ```lab2_node.cpp```
|
|
|
|
* Make sure you understand what is happening, if you have doubts, ask questions to your lab assistant
|
|
|
|
* Build your project with ```tdde05_build``` and then use ```ros2 run ...``` to start your node. Alternatively for python, you can start the script directly from the source directory.
|
|
|
|
* Check that it runs properly, you can use ```rostopic echo ...``` or ```rqt``` to check that a message is published by the node, it should be a string.
|
|
|
|
* Modify the script to publish a ```geometry_msgs/msg/Twist``` on ```/cmd_vel``` with a linear velocity of ```0.1``` and angular velocity of ```0.05```.
|
|
|
|
|
|
The documentation for ```geometry_msgs/Twist``` can be found online at [geometry_msgs/Twist](https://docs.ros2.org/galactic/api/geometry_msgs/msg/Twist.html) or by running ```ros2 msg info geometry_msgs/Twist```.
|
|
The documentation for ```geometry_msgs/Twist``` can be found online at [geometry_msgs/Twist](https://docs.ros2.org/galactic/api/geometry_msgs/msg/Twist.html) or by running ```ros2 msg info geometry_msgs/Twist```.
|
|
|
|
|
... | @@ -146,7 +152,11 @@ Listen on a topic |
... | @@ -146,7 +152,11 @@ Listen on a topic |
|
|
|
|
|
In the previous part, we have created a node that publish on a topic and make your robot move, but it never stops. In this part, we will listen to the ```/odom``` topic and use that information to stop when the robot has moved more than 1.0 meter away from its start position.
|
|
In the previous part, we have created a node that publish on a topic and make your robot move, but it never stops. In this part, we will listen to the ```/odom``` topic and use that information to stop when the robot has moved more than 1.0 meter away from its start position.
|
|
|
|
|
|
Check in the Python or C++ tutorial to see how you can subscribe on a topic.
|
|
Check in the Python or C++ tutorial to see how you can subscribe on a topic. You will have to somehow combine together the publisher and subscriber classes. We strongly advise that you follow the an incremental approach:
|
|
|
|
|
|
|
|
* Add a subscriber to your ```lab2_node```
|
|
|
|
* Add a printout in the callback to check that you receive a message
|
|
|
|
* Modify your program so that it exit once the distance has been computed
|
|
|
|
|
|
Parameters
|
|
Parameters
|
|
----------
|
|
----------
|
... | @@ -216,9 +226,9 @@ We will use the ```NavigateToPose``` action, you can check its type with: |
... | @@ -216,9 +226,9 @@ We will use the ```NavigateToPose``` action, you can check its type with: |
|
ros2 interface show nav2_msgs/action/NavigateToPose
|
|
ros2 interface show nav2_msgs/action/NavigateToPose
|
|
```
|
|
```
|
|
|
|
|
|
Before starting the implementation, study the [official action tutorial](https://docs.ros.org/en/galactic/Tutorials/Intermediate/Writing-an-Action-Server-Client/Py.html)
|
|
Before starting the implementation, study the [official action tutorial](https://docs.ros.org/en/galactic/Tutorials/Intermediate/Writing-an-Action-Server-Client/Py.html).
|
|
|
|
|
|
You can use the following in ```random_exploration.py``` to go to a single location:
|
|
We already modified the tutorial, so that you can use the following in ```random_exploration.py``` to go to a single location:
|
|
|
|
|
|
```python
|
|
```python
|
|
import rclpy
|
|
import rclpy
|
... | | ... | |