Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/included_plugins/drive_wheel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ DriveWheel applies a traction-limited force at a wheel center on a model body.
Use one plugin per driven wheel; the wheel has no Box2D rotational body. Wheel
position is integrated from measured forward speed, so slip or external motion
is reflected in the reported state. A wheel also resists sideways motion.
This plugin is provided by ``flatland_controls_plugins``.

.. code-block:: yaml

plugins:
- type: DriveWheel
- type: flatland_controls_plugins::DriveWheel
name: left_drive
body: base
offset: [0.0, 0.3, 0.0]
Expand Down
3 changes: 2 additions & 1 deletion docs/included_plugins/steering_motor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ SteeringMotor

SteeringMotor actuates a model's revolute Box2D joint and publishes its angle,
angular speed and applied torque as joint state.
This plugin is provided by ``flatland_controls_plugins``.

.. code-block:: yaml

plugins:
- type: SteeringMotor
- type: flatland_controls_plugins::SteeringMotor
name: front_steering
joint: steering_joint
mode: position
Expand Down
5 changes: 3 additions & 2 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ Flatland Simulator is a light weight, performance centric 2D robot simulator. It
is built to integrate directly with ROS and uses Box2D for physics simulation.
The build fetches Box2D 3.1.1 (MIT license).

This project is divided into four ROS packages: flatland_server, flatland_plugins,
and flatland_viz, and flatland messages.
Core simulator functionality is provided by ``flatland_server``,
``flatland_plugins``, and ``flatland_controls_plugins``, with visualization in
``flatland_viz`` and message definitions in ``flatland_msgs``.

Flatland Server
---------------
Expand Down
71 changes: 71 additions & 0 deletions flatland_controls_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
cmake_minimum_required(VERSION 3.10)

project(flatland_controls_plugins)

if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 23)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(control_msgs REQUIRED)
find_package(flatland_server REQUIRED)
find_package(interactive_markers REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)

add_library(flatland_controls_plugins_lib SHARED
src/drive_wheel.cpp
src/steering_motor.cpp
)

target_include_directories(flatland_controls_plugins_lib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_link_libraries(flatland_controls_plugins_lib PUBLIC
flatland_server::flatland_lib
pluginlib::pluginlib
rclcpp::rclcpp
${control_msgs_TARGETS}
${sensor_msgs_TARGETS}
)

ament_export_targets(export_flatland_controls_plugins_lib HAS_LIBRARY_TARGET)
ament_export_dependencies(control_msgs flatland_server interactive_markers pluginlib rclcpp sensor_msgs)

pluginlib_export_plugin_description_file(flatland_server plugin_description.xml)

install(
TARGETS flatland_controls_plugins_lib
EXPORT export_flatland_controls_plugins_lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

install(
DIRECTORY include/
DESTINATION include
FILES_MATCHING PATTERN "*.h"
)

if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
find_package(OpenCV REQUIRED)
ament_add_gtest(joint_actuator_test test/joint_actuator_test.cpp)
target_include_directories(joint_actuator_test PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(joint_actuator_test flatland_controls_plugins_lib)
endif()

ament_package()
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef FLATLAND_PLUGINS_DRIVE_WHEEL_H
#define FLATLAND_PLUGINS_DRIVE_WHEEL_H
#ifndef FLATLAND_CONTROLS_PLUGINS_DRIVE_WHEEL_H
#define FLATLAND_CONTROLS_PLUGINS_DRIVE_WHEEL_H

#include <flatland_server/model_plugin.h>
#include <control_msgs/msg/joint_command.hpp>
#include <sensor_msgs/msg/joint_state.hpp>

namespace flatland_plugins
namespace flatland_controls_plugins
{

class DriveWheel : public flatland_server::ModelPlugin
Expand Down Expand Up @@ -35,6 +35,6 @@ class DriveWheel : public flatland_server::ModelPlugin
rclcpp::Publisher<sensor_msgs::msg::JointState>::SharedPtr state_pub_;
};

} // namespace flatland_plugins
} // namespace flatland_controls_plugins

#endif // FLATLAND_PLUGINS_DRIVE_WHEEL_H
#endif // FLATLAND_CONTROLS_PLUGINS_DRIVE_WHEEL_H
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef FLATLAND_PLUGINS_STEERING_MOTOR_H
#define FLATLAND_PLUGINS_STEERING_MOTOR_H
#ifndef FLATLAND_CONTROLS_PLUGINS_STEERING_MOTOR_H
#define FLATLAND_CONTROLS_PLUGINS_STEERING_MOTOR_H

#include <flatland_server/model_plugin.h>
#include <control_msgs/msg/joint_command.hpp>
#include <sensor_msgs/msg/joint_state.hpp>

namespace flatland_plugins
namespace flatland_controls_plugins
{

class SteeringMotor : public flatland_server::ModelPlugin
Expand All @@ -26,6 +26,6 @@ class SteeringMotor : public flatland_server::ModelPlugin
rclcpp::Publisher<sensor_msgs::msg::JointState>::SharedPtr state_pub_;
};

} // namespace flatland_plugins
} // namespace flatland_controls_plugins

#endif // FLATLAND_PLUGINS_STEERING_MOTOR_H
#endif // FLATLAND_CONTROLS_PLUGINS_STEERING_MOTOR_H
27 changes: 27 additions & 0 deletions flatland_controls_plugins/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>flatland_controls_plugins</name>
<version>2.0.0</version>
<description>Control command plugins for Flatland</description>
<license>BSD</license>

<maintainer email="joseph@avidbots.com">Joseph Duchesne</maintainer>
<author email="joseph@avidbots.com">Joseph Duchesne</author>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>control_msgs</depend>
<depend>flatland_server</depend>
<depend>interactive_markers</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>sensor_msgs</depend>

<test_depend>ament_cmake_gtest</test_depend>
<test_depend>libopencv-dev</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
8 changes: 8 additions & 0 deletions flatland_controls_plugins/plugin_description.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<library path="flatland_controls_plugins_lib">
<class type="flatland_controls_plugins::DriveWheel" base_class_type="flatland_server::ModelPlugin">
<description>Traction-limited wheel controlled by joint commands</description>
</class>
<class type="flatland_controls_plugins::SteeringMotor" base_class_type="flatland_server::ModelPlugin">
<description>Revolute steering joint controlled by joint commands</description>
</class>
</library>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <flatland_plugins/drive_wheel.h>
#include <flatland_controls_plugins/drive_wheel.h>
#include <flatland_server/yaml_reader.h>
#include <pluginlib/class_list_macros.hpp>

#include <algorithm>
#include <cmath>

namespace flatland_plugins
namespace flatland_controls_plugins
{

void DriveWheel::OnInitialize(const YAML::Node & config)
Expand Down Expand Up @@ -109,6 +109,6 @@ void DriveWheel::AfterPhysicsStep(const flatland_server::Timekeeper & timekeeper
state_pub_->publish(state);
}

} // namespace flatland_plugins
} // namespace flatland_controls_plugins

PLUGINLIB_EXPORT_CLASS(flatland_plugins::DriveWheel, flatland_server::ModelPlugin)
PLUGINLIB_EXPORT_CLASS(flatland_controls_plugins::DriveWheel, flatland_server::ModelPlugin)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <flatland_plugins/steering_motor.h>
#include <flatland_controls_plugins/steering_motor.h>
#include <flatland_server/yaml_reader.h>
#include <pluginlib/class_list_macros.hpp>

Expand All @@ -7,7 +7,7 @@
#include <limits>
#include <numbers>

namespace flatland_plugins
namespace flatland_controls_plugins
{

void SteeringMotor::OnInitialize(const YAML::Node & config)
Expand Down Expand Up @@ -101,6 +101,6 @@ void SteeringMotor::AfterPhysicsStep(const flatland_server::Timekeeper & timekee
state_pub_->publish(state);
}

} // namespace flatland_plugins
} // namespace flatland_controls_plugins

PLUGINLIB_EXPORT_CLASS(flatland_plugins::SteeringMotor, flatland_server::ModelPlugin)
PLUGINLIB_EXPORT_CLASS(flatland_controls_plugins::SteeringMotor, flatland_server::ModelPlugin)
Loading
Loading