Creating and building ROS2 in the Fleet Manager
If there is a problem with the action in FleetManager/ROS2, or a problem with the topic in FleetManager/StateVector, you need to modify the folder to create the action or the topic again.
State Vector Subscriber
Delete files
In FleetManager/StateVector, move the src folder and remove all the folders except grpc.
Create a workspace
cd StateVector
mkdir src
cd src
Create a package
In StateVector/src, execute:
ros2 pkg create --build-type ament_python --license Apache-2.0 state_vector_pubsub
Import the subscriber node
Navigate into StateVector/src/state_vector_pubsub/state_vector_pubsub. Then, move into the directory the .py modules that are in src/state_vector_pubsub/state_vector_pubsub.
Add dependencies
Add the following dependencies into package.xml (StateVector/src/state_vector_pubsub):
<exec_depend>rclpy</exec_depend>
<exec_depend>std_msgs</exec_depend>
Add an entry point
In setup.py, add the following line within the console_scripts brackets of the entry_points field:
entry_points={
'console_scripts': [
'listener = py_pubsub.subscriber_member_function:main',
],
}
Check setup.cfg
Check that setup.cfg has the following content:
[develop]
script_dir=$base/lib/state_vector_pubsub
[install]
install_scripts=$base/lib/state_vector_pubsub
Build and run
Still in the root of your workspace, StateVector, build your new package:
colcon build --packages-select state_vector_pubsub
Open a new terminal, navigate to StateVector, and source the setup files:
source install/setup.bash
Now run the listener node:
ros2 run state_vector_pubsub listener
Action Client
Delete files
In FleetManager/ROS2, move the src folder and remove all the folders except grpc.
Create a workspace
cd ROS2
mkdir src
cd src
Create an interface package
In ROS2/src, execute:
ros2 pkg create --license Apache-2.0 commands_action_interface
Restore the action
Create an action directory in the ROS 2 package commands_action_interface:
cd commands_action_interface
mkdir action
Move Commands.action from src/commands_action_interface/action into ROS2/src/commands_action_interface/action.
Building the action
Add the following lines to CMakeLists.txt before the ament_package() line:
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"action/Commands.action"
)
Add the required dependencies to package.xml:
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<member_of_group>rosidl_interface_packages</member_of_group>
Build the package by executing the following commands:
# Change to the root of the workspace
cd ~/ROS2
# Build
colcon build
Run the server
Move all the .py modules from src/commands_action_interface/src to ROS2/src/commands_action_interface/src.
To run the server, open a new terminal, navigate to ROS2, and source the setup files:
source install/setup.bash
Now run the client:
python3 src.commands_action_interface.src.commands_action_client.py