Skip to content

Commit

Permalink
Restored to the latest state due to data loss.
Browse files Browse the repository at this point in the history
Signed-off-by: kozenikanta <[email protected]>
  • Loading branch information
kantakozeni0213 committed Nov 22, 2024
1 parent 0456dbd commit d006d41
Show file tree
Hide file tree
Showing 9 changed files with 922 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.8)
project(power_controller)

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

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclpy REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(power_controller_msgs REQUIRED)
find_package(std_srvs REQUIRED)


add_executable(power_controller src/power_controller.cpp)

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

target_compile_features(power_controller PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
ament_target_dependencies(
power_controller
"rclcpp"
"rclpy"
"ament_cmake_python"
"std_msgs"
"sensor_msgs"
"rosidl_default_generators"
"power_controller_msgs"
"std_srvs"
)

install(TARGETS power_controller
DESTINATION lib/${PROJECT_NAME})

# Install launch files.
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}/
)

if(BUILD_TESTING)
find_package(ament_cmake_copyright REQUIRED)
find_package(ament_cmake_cpplint REQUIRED)
find_package(ament_cmake_lint_cmake REQUIRED)
find_package(ament_cmake_uncrustify REQUIRED)

set(MAX_LINE_LENGTH 200)
ament_copyright()
ament_cpplint(MAX_LINE_LENGTH ${MAX_LINE_LENGTH})
ament_lint_cmake()
ament_uncrustify(MAX_LINE_LENGTH ${MAX_LINE_LENGTH})
endif()

ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# powe_controller-kx

manage each power supply and output battery information via topic communication

## Node
- power_controller

## Services
- **set_24v_power_odrive** (std_srvs::srv::SetBool)
- managing odrive's power supply
- **set_12v_power_d455_front** (std_srvs::srv::SetBool)
- managing framos front power supply
- **set_12v_power_d455_right** (std_srvs::srv::SetBool)
- managing framos right power supply
- **set_12v_power_d455_left** (std_srvs::srv::SetBool)
- managing framos left power supply
- **set_5v_power_mcu** (std_srvs::srv::SetBool)
- managing mcu power supply
- **reboot** (std_srvs::srv::Empty)
- managing power supply
- **shutdown** (std_srvs::srv::Empty)
- managing power supply



|power|`true`|`false`|behavior|
|---|---|---|---|
|set_24v_power_odrive|turn on odrive|turn off odrive|odrive power management|
|set_12v_power_d455_front|turn on front framos|turn off front framos|front framos power management|
|set_12v_power_d455_right|turn on right framos|turn off right framos|right framos power management|
|set_12v_power_d455_left|turn on left framos|turn off left framos|left framos power management|
|set_5v_power_mcu|turn on mcu|turn off mcu|mcu power management|
|reboot|----|----|restart begins when called by client|
|shutdown|----|----|performs shutdown when called by the client|

# Publisher
- **/battery_state** (power_controller_msgs::msg::BatteryArray): publish information on multiple batteries

# Subscriber
- **/fan_controller** (std_msgs::msg::UInt8): fan is regulated using PWM control(0~100)

# Parameters
- **can_interface** (std::string): the interface of CAN can be changed
- **number_of_batteries** (int): number of batteries can be changed
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'''
*******************************************************************************
* Copyright (c) 2024 Miraikan and Carnegie Mellon University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*******************************************************************************
'''

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
# launchの構成を示すLaunchDescription型の変数の定義
ld = LaunchDescription()

# publisher nodeを、"talker_renamed1"という名前で定義
power_controller_node = Node(
package='power_controller',
executable='power_controller',
name='power_controller',
respawn="true"
)

ld.add_action(power_controller_node)
return ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<!--
*******************************************************************************
* Copyright (c) 2024 Miraikan and Carnegie Mellon University
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*******************************************************************************
-->

<package format="3">
<name>power_controller</name>
<version>0.0.0</version>
<description>Node that controls battery information and each power source</description>
<maintainer email="[email protected]">developer</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>rclpy</depend>
<depend>ament_cmake_python</depend>
<depend>std_msgs</depend>
<depend>sensor_msgs</depend>
<depend>power_controller_msgs</depend>
<depend>launch_ros</depend>
<build_depend>rosidl_default_generators</build_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading

0 comments on commit d006d41

Please sign in to comment.