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

Add MotorTemperaturePublisher tool #951

Merged
merged 3 commits into from
Mar 15, 2024
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
1 change: 1 addition & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ add_subdirectory(depth2kin)
add_subdirectory(fingertipsPortScope)
add_subdirectory(oculus)
add_subdirectory(wholeBodyPlayer)
add_subdirectory(motorTemperaturePublisher)
7 changes: 7 additions & 0 deletions app/motorTemperaturePublisher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright: (C) 2024 iCub Facility - Istituto Italiano di Tecnologia
# Authors: Jacopo Losi
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

set(appname motorTemperaturePublisher)
file(GLOB conf ${CMAKE_CURRENT_SOURCE_DIR}/conf/*.ini)
yarp_install(FILES ${conf} DESTINATION ${ICUB_CONTEXTS_INSTALL_DIR}/${appname})
5 changes: 5 additions & 0 deletions app/motorTemperaturePublisher/conf/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[GENERAL]
robotname ergocub
period 0.002
portprefix /left_leg
listofjoints (0 1 2 3 4 5)
41 changes: 41 additions & 0 deletions app/motorTemperaturePublisher/motorTemperaturePublisher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: "3.7"

# the directory defined as ${ROOT_DIR}=/home/icub is basically the home directory of the default icub user
# which is the default user created with the user-based image.
# ROOT_DIR is an environmental variable defined in the .bashrc file of the user home directory
# if you are using this deployment files in your machine remember to choose one of the following options
# to run the containers correctly:
# - declare that env varibale when running the docker compose command and so then export the variable per each terminal opened
# - add the variable exporting in your .bashrc file so each time you open a terminal you have it declared
# - add it to the .bash_aliases file considering that that special file is looked for by the .bashrc

x-MotorTemperaturePublisher: &MotorTemperaturePublisher
image: ghcr.io/icub-tech-iit/docker-deployment-images/cd_superbuild-icubhead-withuser:master-unstable_sources
environment:
- YARP_FORWARD_LOG_ENABLE=1
- DISPLAY=${DISPLAY}
- QT_X11_NO_MITSHM=1
- XAUTHORITY=${ROOT_DIR}/.Xauthority
volumes:
- "${HOME}/.config/yarp:${ROOT_DIR}/.config/yarp"
- "${HOME}/workspace:${ROOT_DIR}/workspace"
- "/tmp/.X11-unix:/tmp/.X11-unix"
- "${XAUTHORITY}:${ROOT_DIR}/.Xauthority"
working_dir: ${ROOT_DIR}/workspace/ICUB_FIRM/icub-main/src/tools/motorTemperaturePublisher
network_mode: "host"

services:
app:
<<: *MotorTemperaturePublisher
restart: on-failure
command: ./build/MotorTemperaturePublisher --from app/conf/config.ini

splitter:
<<: *MotorTemperaturePublisher
restart: on-failure
command: yarp split /ergocub2S/upper_arm/stateExt:o

scope:
<<: *MotorTemperaturePublisher
restart: on-failure
command: yarpscope --xml temperatureScopeUpperArm.xml
50 changes: 50 additions & 0 deletions app/motorTemperaturePublisher/plotTemperatureLeftLeg.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" ?>
<portscope rows="1" columns="1" carrier="mcast">
<plot gridx="0"
gridy="0"
hspan="1"
vspan="1"
minval="0"
maxval="60"
title="Left Leg Temperature"
bgcolor="LightSlateGrey">
<graph remote="/left_leg/motor_temperatures:o"
index="1"
color="red"
title="hip_pitch"
type="lines"
size="3" />
<graph remote="/left_leg/motor_temperatures:o"
index="3"
color="blue"
title="hip_roll"
type="lines"
size="3" />
<graph remote="/left_leg/motor_temperatures:o"
index="5"
color="purple"
title="hip_yaw"
type="lines"
size="3" />
<graph remote="/left_leg/motor_temperatures:o"
index="7"
color="orange"
title="knee"
type="lines"
size="3" />
<graph remote="/left_leg/motor_temperatures:o"
index="9"
color="yellow"
title="ankle_pitch"
type="lines"
size="3" />
<graph remote="/left_leg/motor_temperatures:o"
index="11"
color="green"
title="ankle_roll"
type="lines"
size="3" />
</plot>


</portscope>
54 changes: 54 additions & 0 deletions app/motorTemperaturePublisher/temperatureScopeUpperArm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" ?>
<portscope rows="1" columns="1" carrier="mcast">
<plot gridx="0"
gridy="0"
hspan="1"
vspan="1"
minval="-10"
maxval="50"
title="Motor temperature Plot"
bgcolor="LightSlateGrey">
<graph remote="/upper_arm/motor_temperatures:o"
index="1"
color="purple"
title="temperature pitch"
type="lines"
size="3" />
<graph remote="/upper_arm/motor_temperatures:o"
index="5"
color="darkgreen"
title="temperature yaw"
type="lines"
size="3" />
<graph remote="/upper_arm/motor_temperatures:o"
index="7"
color="orange"
title="temperature elbow"
type="lines"
size="3" />
<graph remote="/ergocub2S/upper_arm/stateExt:o/split16:o"
index="0"
color="red"
title="current pitch"
type="lines"
size="3" />
<graph remote="/ergocub2S/upper_arm/stateExt:o/split16:o"
index="1"
color="blue"
title="current roll"
type="lines"
size="3" />
<graph remote="/ergocub2S/upper_arm/stateExt:o/split16:o"
index="2"
color="green"
title="current yaw"
type="lines"
size="3" />
<graph remote="/ergocub2S/upper_arm/stateExt:o/split16:o"
index="3"
color="yellow"
title="current elbow"
type="lines"
size="3" />
</plot>
</portscope>
1 change: 1 addition & 0 deletions src/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ add_subdirectory(imageBlender)
add_subdirectory(imageCropper)
add_subdirectory(embObjProtoTools/boardTransceiver)
add_subdirectory(wholeBodyPlayer)
add_subdirectory(motorTemperaturePublisher)

add_subdirectory(canLoader)
add_subdirectory(ethLoader)
Expand Down
14 changes: 14 additions & 0 deletions src/tools/motorTemperaturePublisher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright: (C) 2024 iCub Facility - Istituto Italiano di Tecnologia
# Authors: Jacopo Losi
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

project(motorTemperaturePublisher)
# find YARP
find_package(YARP COMPONENTS os sig dev)
# set up our program
add_executable(${PROJECT_NAME} ./src/MotorTemperaturePublisher.h ./src/MotorTemperaturePublisher.cpp ./src/main.cpp )

# link with YARP libraries
target_link_libraries(${PROJECT_NAME} ${YARP_LIBRARIES})

install(TARGETS ${PROJECT_NAME} DESTINATION bin)
94 changes: 94 additions & 0 deletions src/tools/motorTemperaturePublisher/motorTemperaturePublisher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="yarpmanifest.xsl"?>


<module>
<name>MotorTemperaturePublisher</name>
<doxygen-group>icub_tools</doxygen-group>
<description>Motor Temperature Detector and Publisher</description>
<copypolicy>Released under the terms of the GNU GPL v2.0</copypolicy>
<version>1.0</version>

<description-long>
This module is a working example for building a YARP device that exploits the iMotor YARP
interfaces to interact with the motion control module.
Specifically to this example, we are defining a <i><b>PolyDriver</b></i> device that interacts with the
pointer to the <i><b>iMotor</b></i> yarp interface and prints the motor temperatures to an output port.
Those temperatures value can be obtained exploiting the interface method <i>getTemperatures()</i> and
saved to a c-array of doubles.
Considering that, a properly built yarp module should derive from the public interface
<i><b>yarp::os::RFModule</b></i>, whose complete explanation is available at <a href="https://yarp.it/latest/thrift_tutorial_simple.html#thrift_tutorial_simple_module">this link</a> the
following methods should be overridden:
<list type="bullet">
<item>
<description>configure()</description>
</item>
<item>
<description>getPeriod()</description>
</item>
<item>
<description>updateModule()</description>
</item>
<item>
<description>close()</description>
</item>
</list>

In order to use this module, whose final target is to print at the port called <i><b>/portprefix/motor_temperatures:o</b></i> the temperatures of the motors connected, the following steps
should be done:
<list>
<item>
<description>supposed to have the correct setup running on the yarpserver sending data to state ports</description>
</item>
<item>
<description>./build/MotorTemperaturePublisher --from app/conf/config.ini</description>
</item>
</list>

This will instantiate the aformentioned port, where with a frequence of <i><b>_updatePeriod</b></i> time,
the following values will be streamed on the port:

<list>
<item>
<description>timeStamp | temperature_motor_0 | boolean_limit_overcame_0 | ... | temperature_motor_N | boolean_limit_overcame_N |</description>
</item>
</list>

the <i><b>config.ini</b></i> file should be filled in with the following data:
<list>
<item>
<description>robotname: name of the robot as set in the configuration files</description>
</item>
<item>
<description>period: times used for streaming the data to the port</description>
</item>
<item>
<description>listofjoints: joints, as list a list, i.e. (0 1 2), which you wanna get the temperatures</description>
</item>
</list>

</description-long>

<arguments>
<param default="MotorTemperaturePublisher" desc="select the current context.">context</param>
<param default="config.ini" desc="configuration file name.">from</param>
<param default="MotorTemperaturePublisher"
desc="module's name; all the open ports will be tagged with the prefix /name.">name</param>
<param default="ergocub" desc="name of the robot to connect to.">robot</param>
</arguments>

<authors>
<author email="jacopo.losi@iit.it"> Jacopo Losi </author>
</authors>

<data>
<output>
<type>yarp::os::Bottle</type>
<port carrier="tcp">/ergocub/subpart/motor_temperature:o</port>
<description>
show the temperature of the motors of the subpart
</description>
</output>
</data>

</module>
Loading