Skip to content

Commit a862383

Browse files
A300 (#106)
* Added lynx hardware interface * Lynx motor driver Rename clearpath_platform namespace to clearpath_hardware_interfaces * Added A300 and Inventus battery to generator * A300 lighting * Dependencies and README * Rename platform to hardware_interfaces in hardware.xml * Fix append of bms in generator * Removed wheel_joints_ map --------- Co-authored-by: Luis Camero <[email protected]>
1 parent 88a6259 commit a862383

File tree

33 files changed

+5143
-24
lines changed

33 files changed

+5143
-24
lines changed

clearpath_generator_robot/clearpath_generator_robot/launch/generator.py

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from clearpath_config.common.types.platform import Platform
3737
from clearpath_config.platform.battery import BatteryConfig
38-
from clearpath_generator_common.common import LaunchFile, Package
38+
from clearpath_generator_common.common import LaunchFile, Package, ParamFile
3939
from clearpath_generator_common.launch.generator import LaunchGenerator
4040
from clearpath_generator_common.launch.writer import LaunchWriter
4141
from clearpath_generator_robot.launch.sensors import SensorLaunch
@@ -149,8 +149,11 @@ def __init__(self, setup_path: str = '/etc/clearpath/') -> None:
149149
arguments=['-s', setup_path]
150150
)
151151

152-
# Valence BMS
152+
# BMS
153153
self.bms_launch_file = None
154+
self.bms_node = None
155+
156+
# Valence BMS
154157
if (self.clearpath_config.platform.battery.model in
155158
[BatteryConfig.VALENCE_U24_12XP, BatteryConfig.VALENCE_U27_12XP]):
156159

@@ -176,6 +179,40 @@ def __init__(self, setup_path: str = '/etc/clearpath/') -> None:
176179
package=Package('valence_bms_driver'),
177180
args=bms_launch_args
178181
)
182+
# Inventus BMS
183+
elif (self.clearpath_config.platform.battery.model in
184+
[BatteryConfig.S_24V20_U1]):
185+
186+
pkg_inventus_bmu = Package('inventus_bmu')
187+
launch_args = self.clearpath_config.platform.battery.launch_args
188+
189+
inventus_bmu_params_file = ParamFile('default', package=pkg_inventus_bmu)
190+
inventus_bmu_params = inventus_bmu_params_file.full_path
191+
192+
can_dev = 'can1'
193+
194+
if launch_args:
195+
if 'params' in launch_args:
196+
inventus_bmu_params = launch_args['params']
197+
if 'can_device' in launch_args:
198+
can_dev = launch_args['can_device']
199+
200+
self.bms_node = LaunchFile.Node(
201+
'inventus_bmu',
202+
'inventus_bmu',
203+
'inventus_bmu_driver',
204+
self.namespace,
205+
parameters=[
206+
inventus_bmu_params,
207+
{'can_device': can_dev}
208+
],
209+
remappings=[
210+
('bms/battery_state', 'platform/bms/state'),
211+
('modules', 'platform/bms/modules'),
212+
('bms/low_soc_alarm', 'platform/bms/low_soc_alarm'),
213+
('bms/soc_difference_alarm', 'platform/bms/soc_difference_alarm')
214+
]
215+
)
179216

180217
# Lighting
181218
self.lighting_node = LaunchFile.Node(
@@ -203,6 +240,15 @@ def __init__(self, setup_path: str = '/etc/clearpath/') -> None:
203240
namespace=self.namespace,
204241
)
205242

243+
# BLDC Multi-Drive Node
244+
self.lynx_node = LaunchFile.Node(
245+
package='lynx_motor_driver',
246+
executable='lynx_motor_driver',
247+
parameters=[os.path.join(self.platform_params_path, 'control.yaml')],
248+
name='lynx_control',
249+
namespace=self.namespace,
250+
)
251+
206252
# ROS2 socketcan bridges
207253
ros2_socketcan_package = Package('clearpath_ros2_socketcan_interface')
208254
self.can_bridges = []
@@ -231,10 +277,13 @@ def __init__(self, setup_path: str = '/etc/clearpath/') -> None:
231277
common_platform_components = [
232278
self.wireless_watcher_node,
233279
self.diagnostics_launch,
234-
self.battery_state_estimator,
235280
self.battery_state_control,
236281
]
237282

283+
# Only add estimator when no BMS is present
284+
if self.bms_launch_file is None and self.bms_node is None:
285+
common_platform_components.append(self.battery_state_estimator)
286+
238287
if len(self.can_bridges) > 0:
239288
common_platform_components.extend(self.can_bridges)
240289

@@ -247,6 +296,12 @@ def __init__(self, setup_path: str = '/etc/clearpath/') -> None:
247296
self.nmea_driver_node
248297
],
249298
Platform.A200: common_platform_components,
299+
Platform.A300: common_platform_components + [
300+
self.eth_uros_node,
301+
self.configure_mcu,
302+
self.lighting_node,
303+
self.lynx_node,
304+
],
250305
Platform.W200: common_platform_components + [
251306
self.imu_0_filter_node,
252307
self.imu_0_filter_config,
@@ -336,6 +391,9 @@ def generate_platform(self) -> None:
336391
if self.bms_launch_file:
337392
platform_service_launch_writer.add(self.bms_launch_file)
338393

394+
if self.bms_node:
395+
platform_service_launch_writer.add(self.bms_node)
396+
339397
platform_service_launch_writer.generate_file()
340398

341399
def generate_manipulators(self) -> None:

clearpath_generator_robot/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<exec_depend>micro_ros_agent</exec_depend>
2020
<!--<exec_depend>sevcon_traction</exec_depend>-->
2121
<exec_depend>valence_bms_driver</exec_depend>
22+
<exec_depend>wireless_msgs</exec_depend>
2223
<exec_depend>wireless_watcher</exec_depend>
2324

2425
<test_depend>ament_lint_auto</test_depend>

clearpath_hardware_interfaces/CMakeLists.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ find_package(ament_cmake_python REQUIRED)
1616
find_package(controller_interface REQUIRED)
1717
find_package(controller_manager REQUIRED)
1818
find_package(controller_manager_msgs REQUIRED)
19+
find_package(clearpath_motor_msgs REQUIRED)
1920
find_package(clearpath_platform_msgs REQUIRED)
2021
find_package(hardware_interface REQUIRED)
2122
find_package(pluginlib REQUIRED)
22-
find_package(clearpath_motor_msgs REQUIRED)
2323
find_package(rclcpp REQUIRED)
2424

2525
find_package(geometry_msgs REQUIRED)
@@ -37,6 +37,7 @@ find_package(tf2_ros REQUIRED)
3737
set(LIGHTING_EXECUTABLE lighting_node)
3838
set(LIGHTING_LIB clearpath_platform_lighting)
3939
set(LIGHTING_DEPENDENCIES
40+
clearpath_motor_msgs
4041
clearpath_platform_msgs
4142
sensor_msgs
4243
rclcpp
@@ -170,17 +171,42 @@ ament_target_dependencies(
170171
rclcpp
171172
)
172173

174+
# Lynx Hardware
175+
add_library(
176+
lynx_hardware
177+
SHARED
178+
src/lynx/hardware.cpp
179+
src/lynx/hardware_interface.cpp
180+
)
181+
182+
target_include_directories(
183+
lynx_hardware
184+
PRIVATE
185+
include
186+
)
187+
188+
ament_target_dependencies(
189+
lynx_hardware
190+
clearpath_motor_msgs
191+
clearpath_platform_msgs
192+
hardware_interface
193+
pluginlib
194+
rclcpp
195+
)
196+
173197
pluginlib_export_plugin_description_file(hardware_interface src/a200/hardware.xml)
174198
pluginlib_export_plugin_description_file(hardware_interface src/j100/hardware.xml)
175199
pluginlib_export_plugin_description_file(hardware_interface src/w200/hardware.xml)
176200
pluginlib_export_plugin_description_file(hardware_interface src/puma/hardware.xml)
201+
pluginlib_export_plugin_description_file(hardware_interface src/lynx/hardware.xml)
177202

178203
# INSTALL
179204
install(
180205
TARGETS a200_hardware
181206
j100_hardware
182207
w200_hardware
183208
puma_hardware
209+
lynx_hardware
184210
${LIGHTING_EXECUTABLE}
185211
${LIGHTING_LIB}
186212
LIBRARY DESTINATION lib
@@ -208,6 +234,7 @@ ament_export_libraries(
208234
j100_hardware
209235
w200_hardware
210236
puma_hardware
237+
lynx_hardware
211238
${LIGHTING_LIB}
212239
)
213240
ament_export_dependencies(

clearpath_hardware_interfaces/include/clearpath_hardware_interfaces/lighting/color.hpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ struct hsv_t {
6262
}
6363
};
6464

65-
static const hsv_t COLOR_RED = hsv_t(0.0, 100.0, 100.0);
66-
static const hsv_t COLOR_RED_DIM = hsv_t(0.0, 100.0, 10.0);
67-
static const hsv_t COLOR_MAGENTA = hsv_t(300.0, 100.0, 100.0);
68-
static const hsv_t COLOR_BLUE = hsv_t(240.0, 100.0, 100.0);
69-
static const hsv_t COLOR_BLUE_DIM = hsv_t(240.0, 100.0, 10.0);
70-
static const hsv_t COLOR_CYAN = hsv_t(180.0, 100.0, 100.0);
71-
static const hsv_t COLOR_GREEN = hsv_t(120.0, 100.0, 100.0);
72-
static const hsv_t COLOR_GREEN_DIM = hsv_t(120.0, 100.0, 10.0);
73-
static const hsv_t COLOR_YELLOW = hsv_t(60.0, 100.0, 100.0);
74-
static const hsv_t COLOR_ORANGE = hsv_t(30.0, 100.0, 100.0);
75-
static const hsv_t COLOR_WHITE = hsv_t(0.0, 0.0, 100.0);
76-
static const hsv_t COLOR_WHITE_DIM = hsv_t(0.0, 0.0, 10.0);
65+
static const hsv_t COLOR_RED = hsv_t(0.0, 100.0, 37.5);
66+
static const hsv_t COLOR_RED_DIM = hsv_t(0.0, 100.0, 18.75);
67+
static const hsv_t COLOR_MAGENTA = hsv_t(300.0, 100.0, 25.0);
68+
static const hsv_t COLOR_BLUE = hsv_t(240.0, 100.0, 25.0);
69+
static const hsv_t COLOR_BLUE_DIM = hsv_t(240.0, 100.0, 12.5);
70+
static const hsv_t COLOR_CYAN = hsv_t(180.0, 100.0, 25.0);
71+
static const hsv_t COLOR_GREEN = hsv_t(120.0, 100.0, 25.0);
72+
static const hsv_t COLOR_GREEN_DIM = hsv_t(120.0, 100.0, 12.5);
73+
static const hsv_t COLOR_YELLOW = hsv_t(60.0, 100.0, 25.0);
74+
static const hsv_t COLOR_ORANGE = hsv_t(30.0, 100.0, 25.0);
75+
static const hsv_t COLOR_WHITE = hsv_t(0.0, 0.0, 25.0);
76+
static const hsv_t COLOR_WHITE_DIM = hsv_t(0.0, 0.0, 12.5);
7777
static const hsv_t COLOR_BLACK = hsv_t(0.0, 0.0, 0.0);
7878

7979

@@ -87,6 +87,22 @@ class ColorHSV
8787
double h() { return hsv_.h; };
8888
double s() { return hsv_.s; };
8989
double v() { return hsv_.v; };
90+
91+
void setH(const double h)
92+
{
93+
hsv_.h = h;
94+
}
95+
96+
void setS(const double s)
97+
{
98+
hsv_.s = s;
99+
}
100+
101+
void setV(const double v)
102+
{
103+
hsv_.v = v;
104+
}
105+
90106
private:
91107
hsv_t hsv_;
92108
};

clearpath_hardware_interfaces/include/clearpath_hardware_interfaces/lighting/lighting.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#include "clearpath_platform_msgs/msg/power.hpp"
4545
#include "clearpath_platform_msgs/msg/stop_status.hpp"
4646

47+
#include "clearpath_motor_msgs/msg/lynx_system_protection.hpp"
48+
4749
#include "geometry_msgs/msg/twist_stamped.hpp"
4850
#include "sensor_msgs/msg/battery_state.hpp"
4951
#include "std_msgs/msg/bool.hpp"
@@ -68,7 +70,9 @@ class Lighting : public rclcpp::Node
6870
{
6971
BatteryFault = 0,
7072
ShoreFault,
71-
//PumaFault,
73+
MotorFault,
74+
MotorOverheated,
75+
MotorThrottled,
7276
ShoreAndCharged,
7377
ShoreAndCharging,
7478
ShorePower,
@@ -101,6 +105,7 @@ class Lighting : public rclcpp::Node
101105
void batteryStateCallback(const sensor_msgs::msg::BatteryState::SharedPtr msg);
102106
void stopEngagedCallback(const std_msgs::msg::Bool::SharedPtr msg);
103107
void cmdVelCallback(const geometry_msgs::msg::TwistStamped::SharedPtr msg);
108+
void systemProtectionCallback(const clearpath_motor_msgs::msg::LynxSystemProtection::SharedPtr msg);
104109

105110
/** Updates the current lighting state based on all inputs */
106111
void setState(Lighting::State new_state);
@@ -117,6 +122,7 @@ class Lighting : public rclcpp::Node
117122
rclcpp::Subscription<sensor_msgs::msg::BatteryState>::SharedPtr battery_state_sub_;
118123
rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr stop_engaged_sub_;
119124
rclcpp::Subscription<geometry_msgs::msg::TwistStamped>::SharedPtr cmd_vel_sub_;
125+
rclcpp::Subscription<clearpath_motor_msgs::msg::LynxSystemProtection>::SharedPtr system_protection_sub_;
120126

121127
// Timers
122128
rclcpp::TimerBase::SharedPtr lighting_timer_;
@@ -130,6 +136,7 @@ class Lighting : public rclcpp::Node
130136
sensor_msgs::msg::BatteryState battery_state_msg_;
131137
std_msgs::msg::Bool stop_engaged_msg_;
132138
geometry_msgs::msg::TwistStamped cmd_vel_msg_;
139+
clearpath_motor_msgs::msg::LynxSystemProtection system_protection_msg_;
133140

134141
// Variables
135142
Platform platform_;

clearpath_hardware_interfaces/include/clearpath_hardware_interfaces/lighting/platform.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ namespace clearpath_lighting
4343

4444
enum Platform
4545
{
46+
A300,
4647
DD100,
4748
DO100,
4849
DD150,
@@ -53,6 +54,7 @@ enum Platform
5354

5455
static std::map<std::string, Platform> ClearpathPlatforms
5556
{
57+
{"a300", Platform::A300},
5658
{"dd100", Platform::DD100},
5759
{"do100", Platform::DO100},
5860
{"dd150", Platform::DD150},
@@ -63,6 +65,7 @@ static std::map<std::string, Platform> ClearpathPlatforms
6365

6466
static std::map<Platform, int> PlatformNumLights
6567
{
68+
{Platform::A300, 4},
6669
{Platform::DD100, 4},
6770
{Platform::DO100, 4},
6871
{Platform::DD150, 4},
@@ -71,6 +74,17 @@ static std::map<Platform, int> PlatformNumLights
7174
{Platform::W200, 4},
7275
};
7376

77+
static std::map<Platform, float> PlatformBrightness
78+
{
79+
{Platform::A300, 0.5f},
80+
{Platform::DD100, 1.0f},
81+
{Platform::DO100, 1.0f},
82+
{Platform::DD150, 1.0f},
83+
{Platform::DO150, 1.0f},
84+
{Platform::R100, 1.0f},
85+
{Platform::W200, 1.0f},
86+
};
87+
7488
}
7589

7690
#endif // CLEARPATH_HARDWARE_INTERFACES__LIGHTING__PLATFORM_HPP_

clearpath_hardware_interfaces/include/clearpath_hardware_interfaces/lighting/sequence.hpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,38 @@ class Sequence
6161
{
6262

6363
public:
64+
Sequence();
65+
6466
clearpath_platform_msgs::msg::Lights getLightsMsg();
6567
void reset();
6668
static LightingState fillLightingState(ColorHSV color, clearpath_lighting::Platform platform);
6769
static LightingState fillFrontRearLightingState(ColorHSV front_color, ColorHSV rear_color, clearpath_lighting::Platform platform);
6870
static LightingState fillLeftRightLightingState(ColorHSV left_color, ColorHSV right_color, clearpath_lighting::Platform platform);
6971
static LightingState fillOppositeCornerLightingState(ColorHSV front_left_color, ColorHSV front_right_color, clearpath_lighting::Platform platform);
70-
Sequence();
72+
const LightingSequence& getSequence() const;
73+
void setSequence(LightingSequence sequence);
74+
75+
uint16_t getNumStates() const;
76+
void setNumStates(const uint16_t num_states);
77+
78+
Sequence operator+(Sequence const& other)
79+
{
80+
Sequence s;
81+
LightingSequence ls, other_ls;
82+
83+
ls = sequence_;
84+
other_ls = other.getSequence();
85+
86+
for (std::size_t i = 0; i < sequence_.size(); i++)
87+
{
88+
ls.at(i).insert(ls.at(i).end(), other_ls.at(i).begin(), other_ls.at(i).end());
89+
}
90+
91+
s.setSequence(ls);
92+
s.setNumStates(num_states_ + other.getNumStates());
93+
94+
return s;
95+
}
7196

7297
protected:
7398
LightingSequence sequence_;

0 commit comments

Comments
 (0)