Skip to content

Commit

Permalink
Merge branch 'master' into jrivero/src_install
Browse files Browse the repository at this point in the history
  • Loading branch information
azeey authored Sep 4, 2024
2 parents 9819c56 + 0bb6ed2 commit 4157636
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 33 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
with:
name: website
path: dist
if-no-files-found: 'error'
include-hidden-files: 'true'

# Build Docs
build_docs:
Expand Down Expand Up @@ -67,6 +69,8 @@ jobs:
with:
name: docs
path: .build
if-no-files-found: 'error'
include-hidden-files: 'true'

deploy:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion harmonic/ros2_spawn_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ Additionally, it's possible to spawn new models at any time. To do so using ROS
we have provided the following mechanisms:

## Spawn a model using the launch file included in `ros_gz_sim`.
*Currently only available in Rolling.*

The package `ros_gz_sim` contains a launch file named
`ros_gz_spawn_model.launch.py`. You can use it to spawn a new model into an
existing simulation. Here's an example:

```bash
ros2 launch ros_gz_sim gz_spawn_model.launch.py world:=empty file:=$(ros2 pkg prefix --share ros_gz_sim_demos)/models/vehicle/model.sdf name:=my_vehicle x:=5.0 y:=5.0 z:=0.5
ros2 launch ros_gz_sim ros_gz_spawn_model.launch.py world:=empty file:=$(ros2 pkg prefix --share ros_gz_sim_demos)/models/vehicle/model.sdf name:=my_vehicle x:=5.0 y:=5.0 z:=0.5
```

Check [this block](https://github.com/gazebosim/ros_gz/blob/cadae1c8323a74395c09a37e3de4c669c8c09d4f/ros_gz_sim/launch/ros_gz_spawn_model.launch.py#L33-L44)
Expand Down
29 changes: 7 additions & 22 deletions ionic/install_ubuntu_src.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,17 @@ sudo apt install python3-pip lsb-release gnupg curl

## vcstool and colcon from pip

PIP is available on all platforms:
PIP is available on all platforms. Using a PIP workspace to install the tools:

```bash
pip install vcstool || pip3 install vcstool
python3 -m venv $HOME/vcs_colcon_installation
. $HOME/vcs_colcon_installation/bin/activate
pip3 install vcstool colcon-common-extensions
```

```bash
pip install -U colcon-common-extensions || pip3 install -U colcon-common-extensions
```

Check that no errors were printed while installing with PIP. If your system is not recognising the commands, and you're using a system that is compatible with Debian or Ubuntu packages, see the instructions below to install using `apt`.

After installing `vcstool` and `colcon` with PIP, you may need to add their executables to your `$PATH`.
Check where the installation of these packages took place:

```bash
pip show vcstool || pip3 show vcstool | grep Location

pip show colcon-common-extensions || pip3 show colcon-common-extensions | grep Location
```

If your install path is prefixed with `$HOME/.local`, you'll probably need to add the executables within this directory to your `$PATH` in order to avoid "command not found" errors when using `vcstool` and `colcon` later on:

```bash
export PATH=$PATH:$HOME/.local/bin/
```
`vcs` and `colcon` are now available from the PIP workspace in the current
terminal. For using them in other terminals run the `activate` script as
done above.

## vcstool and colcon from apt

Expand Down
23 changes: 21 additions & 2 deletions ionic/moving_robot.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,26 @@ The last command will display all messages sent on `/keyboard/keypress` topic.

In the Gazebo window press different keys and you should see data (numbers) on the terminal where you run the `gz topic -e -t /keyboard/keypress` command.

![KeyPublisher](tutorials/moving_robot/keypublisher_data.png)
```
$ gz topic -e -t /keyboard/keypress
data: 68
data: 85
data: 72
data: 74
data: 81
data: 16777235
data: 16777234
data: 16777237
data: 16777236
```

We want to map these keystrokes into messages of type `Twist` and publish them to the `/cmd_vel` topic which our model listens to.
The `TriggeredPublisher` plugin will do this.
Expand Down Expand Up @@ -116,7 +135,7 @@ It accepts messages of type `gz.msgs.Int32` on the `/keyboard/keypress` topic an

Now launch `building_robot.sdf` then add the Key Publisher plugin and our robot should move forward as we press the Up arrow key ↑ (make sure you start the simulation by pressing the play button to see the robot move forward after pressing the Up arrow key).

There is a demo explaining how the [Triggered Publisher](https://github.com/gazebosim/gz-sim/blob/gz-sim7/tutorials/triggered_publisher.md) works.
There is a demo explaining how the [Triggered Publisher](https://github.com/gazebosim/gz-sim/blob/gz-sim9/tutorials/triggered_publisher.md) works.

### Moving using arrow keys

Expand Down
17 changes: 9 additions & 8 deletions ionic/sensors.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The last command listens to the messages sent over the `/imu` topic. The IMU dat

![Imu_message](tutorials/sensors/imu_msgs.png)

Move your robot forward using the keyboard up key. You should see the sensor values changing.
Move your robot forward using the keyboard up key. To do so, don't forget to enable the Key Publisher Plugin. You should see the sensor values changing.

## Contact sensor

Expand Down Expand Up @@ -315,24 +315,25 @@ To do that, we'll write a short C++ program that listens to
the sensor data and sends velocity commands to the robot.
This program is called a node. We will build a node that subscribes
to the `/lidar` topic and reads its data.
Have a look at this [tutorial](https://gazebosim.org/api/transport/9.0/messages.html)
Have a look at this [tutorial](https://gazebosim.org/api/transport/14/messages.html)
to learn how to build a `publisher` and a `subscriber` node.
You can download the finished node for this demo from [here](https://github.com/gazebosim/docs/blob/master/ionic/tutorials/sensors/lidar_node.cc).

#### The lidar_node

```cpp
gz::transport::Node node;
std::string topic_pub = "/cmd_vel";
gz::msgs::Twist data;
gz::transport::Node node;
auto pub = node.Advertise<gz::msgs::Twist>(topic_pub);
```

We declare a `node` which will publish to `cmd_vel` topic and defined the message type `Twist`. Then advertise our node.
We declare a `node` which will publish to `cmd_vel` topic. Then advertise our node.

```cpp
void cb(const gz::msgs::LaserScan &_msg)
{
gz::msgs::Twist data;

bool allMore = true;
for (int i = 0; i < _msg.ranges_size(); i++)
{
Expand Down Expand Up @@ -362,11 +363,11 @@ If so we publish a message to our car to move forward. Otherwise we make the rob
```cpp
int main(int argc, char **argv)
{
std::string topic = "/lidar";
std::string topic_sub = "/lidar";
// Subscribe to a topic by registering a callback.
if (!node.Subscribe(topic, cb))
if (!node.Subscribe(topic_sub, cb))
{
std::cerr << "Error subscribing to topic [" << topic << "]" << std::endl;
std::cerr << "Error subscribing to topic [" << topic_sub << "]" << std::endl;
return -1;
}
Expand Down
Binary file removed ionic/tutorials/moving_robot/keypublisher_data.png
Binary file not shown.

0 comments on commit 4157636

Please sign in to comment.