Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a tutorial #8

Merged
merged 7 commits into from
Apr 2, 2023

Conversation

stevehenderson
Copy link
Contributor

I added a step by step tutorial for this excellent repo.

Thank you @mengchaoheng for all the tips in #3

@jaypatrikar
Copy link

Hello! Just curious if this has been tried with multiple agents? Thanks

@stevehenderson
Copy link
Contributor Author

Hello! Just curious if this has been tried with multiple agents? Thanks

Hi @jaypatrikar -- no I haven't tried it yet

Copy link
Owner

@Jaeyoung-Lim Jaeyoung-Lim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the thorough tutorial

I think overall it looks good, but I am a little uncomfortable of adding binary images to the repository. Would you be able to remove them from the commit, and reduce them / add them as text to the tutorial file?

@mengchaoheng
Copy link

@Jaeyoung-Lim binary images is good, why you don't like it?

@Jaeyoung-Lim
Copy link
Owner

@mengchaoheng It is not good practice to have large binaries in trees since it increases the size of the repository.

Also having screenshots of a terminal as a image does not provide more information compared to text

@mengchaoheng
Copy link

All right. Can you fix it? @stevehenderson

@stevehenderson
Copy link
Contributor Author

All right. Can you fix it? @stevehenderson

Yes, no problem!

@stevehenderson
Copy link
Contributor Author

All right. Can you fix it? @stevehenderson

Yes, no problem!

@Jaeyoung-Lim
Copy link
Owner

@stevehenderson Any updates?

@stevehenderson
Copy link
Contributor Author

stevehenderson commented Apr 1, 2023

Hi @Jaeyoung-Lim I just pushed a new commit with the requested modifications.

Copy link
Owner

@Jaeyoung-Lim Jaeyoung-Lim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

I left a few comments that would be nice to address

### Prerequisites

* [ROS2 Installed](https://docs.px4.io/main/en/ros/ros2_comm.html#install-ros-2), and setup for your operating system (e.g. [Linux Ubuntu](https://docs.px4.io/main/en/dev_setup/dev_env_linux_ubuntu.html)) with Gazebo
* [FastDDS Installed](https://docs.px4.io/main/en/dev_setup/fast-dds-installation.html)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link seems to be dead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. It doesnt seem fastdds is in the current px4 branch, so I linked to the last supported version.


### Example System Details

* Ubuntu 22.02
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Ubuntu 22.02
* Ubuntu 22.04

* [PX4-Autopilot downloaded](https://docs.px4.io/main/en/dev_setup/building_px4.html)
* [QGroundControl installed](https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html)

### Example System Details
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be part of the Prerequisites

cd ~
mkdir px4_ros_com_ws
cd px4_ros_com_ws
git clone https://github.com/PX4/px4_ros_com.git
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need px4_ros_com for this package to work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

```
cd ~
mkdir px4_ros_com_ws
cd px4_ros_com_ws
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cd px4_ros_com_ws
cd <colcon_workspace_path>

Comment on lines 47 to 57

```
Starting >>> px4_msgs
Finished <<< px4_msgs [6.42s]
Starting >>> px4_ros_com
Finished <<< px4_ros_com [0.13s]

Summary: 2 packages finished [6.71s]
```

You may see some warnings interspered with the output. As long as there are no __*errors*__ you should be OK..
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```
Starting >>> px4_msgs
Finished <<< px4_msgs [6.42s]
Starting >>> px4_ros_com
Finished <<< px4_ros_com [0.13s]
Summary: 2 packages finished [6.71s]
```
You may see some warnings interspered with the output. As long as there are no __*errors*__ you should be OK..

Comment on lines 87 to 179
#### Building the micro_ros_agent

From: [Building micro-ROS-Agent](https://github.com/micro-ROS/micro_ros_setup#building-micro-ros-agent)

```
cd ~
mkdir ~/microros_ws
cd microros_ws
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git
mkdir src
mv micro_ros_setup/ src/
```

*Note how the `ROS_DISTRO` environment variable is used to specify the correct branch...

Now build


```
colcon build
source install/local_setup.sh
ros2 run micro_ros_setup create_agent_ws.sh
ros2 run micro_ros_setup build_agent.sh
```


This should build and may flash a few warnings:

```
colcon build
[0.584s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/analyst/microros_ws/install/micro_ros_setup' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.584s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/analyst/microros_ws/install/micro_ros_agent' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.584s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/analyst/microros_ws/install/micro_ros_msgs' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.585s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/analyst/microros_ws/install/micro_ros_setup' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.585s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/analyst/microros_ws/install/micro_ros_agent' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.585s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/analyst/microros_ws/install/micro_ros_msgs' in the environment variable CMAKE_PREFIX_PATH doesn't exist
Starting >>> micro_ros_setup
Finished <<< micro_ros_setup [1.52s]

Summary: 1 package finished [1.80s]
analyst@casa:~/microros_ws$ source install/local_setup.sh
analyst@casa:~/microros_ws$ ros2 run micro_ros_setup create_agent_ws.sh
..
=== ./uros/micro-ROS-Agent (git) ===
Cloning into '.'...
=== ./uros/micro_ros_msgs (git) ===
Cloning into '.'...
#All required rosdeps installed successfully
analyst@casa:~/microros_ws$ ros2 run micro_ros_setup build_agent.sh
Building micro-ROS Agent
[0.593s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/analyst/microros_ws/install/micro_ros_agent' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.593s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/home/analyst/microros_ws/install/micro_ros_msgs' in the environment variable AMENT_PREFIX_PATH doesn't exist
[0.593s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/analyst/microros_ws/install/micro_ros_agent' in the environment variable CMAKE_PREFIX_PATH doesn't exist
[0.593s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path '/home/analyst/microros_ws/install/micro_ros_msgs' in the environment variable CMAKE_PREFIX_PATH doesn't exist
Starting >>> micro_ros_msgs
Finished <<< micro_ros_msgs [5.51s]
Starting >>> micro_ros_agent
--- stderr: micro_ros_agent
Cloning into 'xrceagent'...
Switched to a new branch 'ros2'
HEAD is now at 3eb56b5 Release v2.3.0
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (tinyxml2)
does not match the name of the calling package (TinyXML2). This can lead
to problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
cmake/modules/FindTinyXML2.cmake:40 (find_package_handle_standard_args)
/opt/ros/humble/share/fastrtps/cmake/fastrtps-config.cmake:51 (find_package)
CMakeLists.txt:153 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.

---
Finished <<< micro_ros_agent [23.2s]

Summary: 2 packages finished [29.0s]
1 package had stderr output: micro_ros_agent

```

Try running the agent:

```
source install/local_setup.sh
ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888
```

It should respond with:

```
[1670101284.566587] info | UDPv4AgentLinux.cpp | init | running... | port: 8888
[1670101284.566822] info | Root.cpp | set_verbose_level | logger setup | verbose_level: 4
```
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just link the instruction to an external link? building a micro-ros-agent is not really related to this package

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

```
cd ~/microros_ws
export ROS_DOMAIN_ID=0
export PYTHONOPTIMIZE=1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. As a newbie, I struggled for hours before I realized that my ROS_DOMAIN_ID had to be consistent across the 3 processes. PYTHONOPTIMIZE is required in my environment for GAZEBO to work.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why PYTHONOPTIMIZE is required? what environment are you on?

Copy link
Contributor Author

@stevehenderson stevehenderson Apr 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My environment:

   * Ubuntu 22.04
   * ROS2 Humble
   * Python 3.10

When I ran through this the first time, months ago, I got this error:

image

After several hours, I found the solution here

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, strange

@Jaeyoung-Lim Jaeyoung-Lim merged commit 324c51a into Jaeyoung-Lim:master Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants