AS: creating packages
This commit is contained in:
1
workspace/build/.built_by
Normal file
1
workspace/build/.built_by
Normal file
@@ -0,0 +1 @@
|
||||
colcon
|
||||
0
workspace/build/COLCON_IGNORE
Normal file
0
workspace/build/COLCON_IGNORE
Normal file
@@ -0,0 +1,102 @@
|
||||
import rclpy
|
||||
from rclpy.node import Node
|
||||
from sensor_msgs.msg import JointState
|
||||
from osc4py3.as_eventloop import *
|
||||
from osc4py3 import oscbuildparse
|
||||
|
||||
class JointStateOSC(Node):
|
||||
def __init__(self):
|
||||
super().__init__('joint_states_osc')
|
||||
|
||||
# Create a ROS 2 subscriber to /joint_states topic
|
||||
self.subscription = self.create_subscription(
|
||||
JointState,
|
||||
'/joint_states',
|
||||
self.joint_states_callback,
|
||||
1 # Queue size
|
||||
)
|
||||
|
||||
# Open Sound Control (OSC) Client settings
|
||||
self.osc_ip = "127.0.0.1" # Replace with the target IP
|
||||
self.osc_port = 8000 # Replace with the target port
|
||||
|
||||
# Start the OSC system
|
||||
osc_startup()
|
||||
|
||||
# Make client channels to send packets
|
||||
osc_udp_client(self.osc_ip, self.osc_port, "osc_client")
|
||||
|
||||
def joint_states_callback(self, msg):
|
||||
"""Callback function to handle incoming joint states."""
|
||||
header = msg.header
|
||||
joint_names = msg.name
|
||||
joint_positions = msg.position
|
||||
joint_velocity = msg.velocity
|
||||
joint_effort = msg.effort
|
||||
|
||||
joint_names_str = "\n- ".join(joint_names)
|
||||
joint_positions_str = "\n- ".join(map(str, joint_positions))
|
||||
joint_velocity_str = "\n- ".join(map(str, joint_velocity))
|
||||
joint_effort_str = "\n- ".join(map(str, joint_effort))
|
||||
|
||||
info = f"""
|
||||
---
|
||||
header:
|
||||
stamp:
|
||||
sec: {header.stamp.sec}
|
||||
nanosec: {header.stamp.nanosec}
|
||||
name:
|
||||
- {joint_names_str}
|
||||
position:
|
||||
- {joint_positions_str}
|
||||
velocity:
|
||||
- {joint_velocity_str}
|
||||
effort:
|
||||
- {joint_effort_str}
|
||||
---"""
|
||||
|
||||
# Send the info message
|
||||
msg_info = oscbuildparse.OSCMessage("/joint_states", None, info)
|
||||
msg_name = oscbuildparse.OSCMessage("/joint_states/name", None, type(joint_names))
|
||||
msg_position = oscbuildparse.OSCMessage("/joint_states/position", None, type(joint_positions))
|
||||
msg_velocity = oscbuildparse.OSCMessage("/joint_states/velocity", None, type(joint_velocity))
|
||||
msg_effort = oscbuildparse.OSCMessage("/joint_states/effort", None, type(joint_effort))
|
||||
|
||||
bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY, [msg_info, msg_name, msg_position, msg_velocity, msg_effort])
|
||||
|
||||
osc_send(bun, "osc_client")
|
||||
osc_process()
|
||||
#print(f"Publishing: {info}")
|
||||
|
||||
|
||||
'''
|
||||
# Send each joint state as an OSC message
|
||||
for i, name in enumerate(joint_names):
|
||||
#msg_sec = oscbuildparse.OSCMessage(f"/joint_states/header/sec", None, [header.stamp.sec])
|
||||
#msg_nanosec = oscbuildparse.OSCMessage(f"/joint_states/header/nanosec", None, [header.stamp.nanosec])
|
||||
msg_position = oscbuildparse.OSCMessage(f"/joint_states/{name}/position", None, [joint_positions[i]])
|
||||
msg_velocity = oscbuildparse.OSCMessage(f"/joint_states/{name}/velocity", None, [joint_velocity[i]])
|
||||
msg_effort = oscbuildparse.OSCMessage(f"/joint_states/{name}/effort", None, [joint_effort[i]])
|
||||
|
||||
bun = oscbuildparse.OSCBundle(oscbuildparse.unixtime2timetag(header.stamp.sec + header.stamp.nanosec), [msg_position, msg_velocity, msg_effort])
|
||||
#bun = oscbuildparse.OSCBundle(oscbuildparse.OSC_IMMEDIATELY , [msg_position, msg_velocity, msg_effort])
|
||||
osc_send(bun, "osc_client")
|
||||
osc_process()
|
||||
#print(f"OSC bundle sent for joint {name}")
|
||||
'''
|
||||
|
||||
def main():
|
||||
rclpy.init()
|
||||
node = JointStateOSC()
|
||||
print(f"Publishing joint states to OSC on {node.osc_ip}:{node.osc_port}...")
|
||||
try:
|
||||
rclpy.spin(node)
|
||||
except KeyboardInterrupt:
|
||||
print("shutting down...")
|
||||
finally:
|
||||
node.destroy_node()
|
||||
rclpy.shutdown()
|
||||
osc_terminate()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,39 @@
|
||||
from osc4py3.as_eventloop import *
|
||||
from osc4py3 import oscmethod as osm
|
||||
import time
|
||||
|
||||
def joint_states_handler(*args):
|
||||
"""Handler function to process incoming joint states."""
|
||||
for arg in args:
|
||||
print(arg)
|
||||
|
||||
def main():
|
||||
ip = "0.0.0.0" # IP address to listen on
|
||||
port = 8000 # Port to listen on
|
||||
|
||||
# Start the OSC system
|
||||
osc_startup()
|
||||
|
||||
# Make server channels to receive packets
|
||||
osc_udp_server(ip, port, "osc_server")
|
||||
|
||||
# Associate Python functions with message address patterns
|
||||
osc_method("/joint_states", joint_states_handler, argscheme=osm.OSCARG_DATAUNPACK)
|
||||
|
||||
print(f"Listening for OSC messages on {ip}:{port}...")
|
||||
|
||||
try:
|
||||
# Run the event loop
|
||||
while True:
|
||||
osc_process() # Process OSC messages
|
||||
time.sleep(0.01) # Sleep to avoid high CPU usage
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("")
|
||||
|
||||
finally:
|
||||
# Properly close the system
|
||||
osc_terminate()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
1
workspace/build/joint_info/colcon_build.rc
Normal file
1
workspace/build/joint_info/colcon_build.rc
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
# generated from colcon_core/shell/template/command_prefix.sh.em
|
||||
@@ -0,0 +1,21 @@
|
||||
AMENT_PREFIX_PATH=/BA/workspace/install/joint_info:/opt/ros/humble
|
||||
COLCON=1
|
||||
COLCON_PREFIX_PATH=/BA/workspace/install:/BA/ros_osc/install
|
||||
HOME=/root
|
||||
HOSTNAME=3230bc57d699
|
||||
LANG=C.UTF-8
|
||||
LC_ALL=C.UTF-8
|
||||
LD_LIBRARY_PATH=/opt/ros/humble/opt/rviz_ogre_vendor/lib:/opt/ros/humble/lib/x86_64-linux-gnu:/opt/ros/humble/lib
|
||||
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
|
||||
OLDPWD=/BA/workspace/src
|
||||
PATH=/opt/ros/humble/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
PWD=/BA/workspace/build/joint_info
|
||||
PYTHONPATH=/BA/workspace/install/joint_info/lib/python3.10/site-packages:/opt/ros/humble/lib/python3.10/site-packages:/opt/ros/humble/local/lib/python3.10/dist-packages
|
||||
ROS_DISTRO=humble
|
||||
ROS_LOCALHOST_ONLY=0
|
||||
ROS_PYTHON_VERSION=3
|
||||
ROS_VERSION=2
|
||||
SHLVL=1
|
||||
TERM=xterm
|
||||
_=/usr/bin/colcon
|
||||
_colcon_cd_root=/opt/ros/foxy/
|
||||
1
workspace/build/joint_info/joint_info
Symbolic link
1
workspace/build/joint_info/joint_info
Symbolic link
@@ -0,0 +1 @@
|
||||
/BA/workspace/src/joint_info/joint_info
|
||||
12
workspace/build/joint_info/joint_info.egg-info/PKG-INFO
Normal file
12
workspace/build/joint_info/joint_info.egg-info/PKG-INFO
Normal file
@@ -0,0 +1,12 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: joint-info
|
||||
Version: 0.0.0
|
||||
Summary: TODO: Package description
|
||||
Home-page: UNKNOWN
|
||||
Maintainer: root
|
||||
Maintainer-email: root@todo.todo
|
||||
License: TODO: License declaration
|
||||
Platform: UNKNOWN
|
||||
|
||||
UNKNOWN
|
||||
|
||||
21
workspace/build/joint_info/joint_info.egg-info/SOURCES.txt
Normal file
21
workspace/build/joint_info/joint_info.egg-info/SOURCES.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
package.xml
|
||||
setup.cfg
|
||||
setup.py
|
||||
../../build/joint_info/joint_info.egg-info/PKG-INFO
|
||||
../../build/joint_info/joint_info.egg-info/SOURCES.txt
|
||||
../../build/joint_info/joint_info.egg-info/dependency_links.txt
|
||||
../../build/joint_info/joint_info.egg-info/entry_points.txt
|
||||
../../build/joint_info/joint_info.egg-info/requires.txt
|
||||
../../build/joint_info/joint_info.egg-info/top_level.txt
|
||||
../../build/joint_info/joint_info.egg-info/zip-safe
|
||||
joint_info/__init__.py
|
||||
joint_info/osc_joint_states_pub.py
|
||||
joint_info/osc_joint_states_sub.py
|
||||
joint_info.egg-info/PKG-INFO
|
||||
joint_info.egg-info/SOURCES.txt
|
||||
joint_info.egg-info/dependency_links.txt
|
||||
joint_info.egg-info/entry_points.txt
|
||||
joint_info.egg-info/requires.txt
|
||||
joint_info.egg-info/top_level.txt
|
||||
joint_info.egg-info/zip-safe
|
||||
resource/joint_info
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[console_scripts]
|
||||
joint_states_pub = joint_info.osc_joint_states_pub:main
|
||||
joint_states_sub = joint_info.osc_joint_states_sub:main
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
setuptoolsosc4py3
|
||||
@@ -0,0 +1 @@
|
||||
joint_info
|
||||
1
workspace/build/joint_info/joint_info.egg-info/zip-safe
Normal file
1
workspace/build/joint_info/joint_info.egg-info/zip-safe
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
workspace/build/joint_info/package.xml
Symbolic link
1
workspace/build/joint_info/package.xml
Symbolic link
@@ -0,0 +1 @@
|
||||
/BA/workspace/src/joint_info/package.xml
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
import sys
|
||||
if sys.prefix == '/usr':
|
||||
sys.real_prefix = sys.prefix
|
||||
sys.prefix = sys.exec_prefix = '/BA/workspace/install/joint_info'
|
||||
1
workspace/build/joint_info/resource/joint_info
Symbolic link
1
workspace/build/joint_info/resource/joint_info
Symbolic link
@@ -0,0 +1 @@
|
||||
/BA/workspace/src/joint_info/resource/joint_info
|
||||
1
workspace/build/joint_info/setup.cfg
Symbolic link
1
workspace/build/joint_info/setup.cfg
Symbolic link
@@ -0,0 +1 @@
|
||||
/BA/workspace/src/joint_info/setup.cfg
|
||||
1
workspace/build/joint_info/setup.py
Symbolic link
1
workspace/build/joint_info/setup.py
Symbolic link
@@ -0,0 +1 @@
|
||||
/BA/workspace/src/joint_info/setup.py
|
||||
@@ -0,0 +1 @@
|
||||
prepend-non-duplicate;PYTHONPATH;/BA/workspace/build/joint_info
|
||||
@@ -0,0 +1,3 @@
|
||||
# generated from colcon_powershell/shell/template/hook_prepend_value.ps1.em
|
||||
|
||||
colcon_prepend_unique_value PYTHONPATH "$env:COLCON_CURRENT_PREFIX\/BA/workspace/build/joint_info"
|
||||
@@ -0,0 +1,3 @@
|
||||
# generated from colcon_core/shell/template/hook_prepend_value.sh.em
|
||||
|
||||
_colcon_prepend_unique_value PYTHONPATH "/BA/workspace/build/joint_info"
|
||||
Reference in New Issue
Block a user