스마트 요양 지원 시스템 RoboCare : 프로젝트 (로봇팔 궤적 계획)
안녕하세요!! 오늘은 MATLAB으로 프로젝트를 더 업그레이드 시키고자 포스팅합니다.
진행하고 있는 프로젝트를 ROS로만 해보는것이 아니라 MATLAB 시뮬링크로 MBD기반 프로그램 설계를 해보는겁니다!!

벌써 설레죠??
MBD기반 설계부터 설명 드리겠습니다!!
MATLAB을 활용한 모델 기반 설계(Model-Based Design, MBD)는
시스템 개발 과정에서 모델을 체계적으로 사용하는 방법입니다.
MBD의 주요 단계
- 요구사항 정의:
- 시스템의 요구사항을 수집하고 이를 명확히 정의합니다. MATLAB과 Simulink를 사용하여 요구사항을 모델에 반영합니다.
- 모델링:
- 시스템의 동작을 모델링합니다. Simulink를 사용하여 시스템의 동적 동작을 시뮬레이션하고, 다양한 시나리오를 테스트할 수 있습니다.
- 시뮬레이션 및 검증:
- 모델을 시뮬레이션하여 시스템의 동작을 검증합니다. 이 단계에서 오류를 발견하고 수정할 수 있습니다.
- 코드 생성:
- 검증된 모델을 바탕으로 자동으로 C/C++ 코드를 생성합니다. 이 코드는 임베디드 시스템에 직접 배포할 수 있습니다.
- HIL(Hardware-in-the-Loop) 테스트:
- 실제 하드웨어 환경에서 모델을 테스트하여 시스템의 성능을 검증합니다. 이를 통해 실시간으로 시스템의 동작을 확인할 수 있습니다
MBD의 장점
- 개발 시간 단축: 모델을 사용하여 초기 단계에서 시스템의 동작을 검증할 수 있어, 개발 시간을 크게 단축할 수 있습니다.
- 품질 향상: 시뮬레이션을 통해 다양한 시나리오를 테스트하고, 오류를 조기에 발견하여 수정할 수 있습니다.
- 효율적인 커뮤니케이션: 모델을 통해 개발자와 이해관계자 간의 의사소통이 원활해집니다.
- 자동 코드 생성: 검증된 모델을 바탕으로 자동으로 코드를 생성하여, 코드 작성 시간을 줄이고, 오류를 최소화할 수 있습니다
적용 사례
MBD는 자동차, 항공, 로봇 등 다양한 산업 분야에서 사용됩니다. 예를 들어, 자동차 산업에서는 차량의 제어 시스템을 모델링하고, 시뮬레이션을 통해 성능을 검증한 후, 자동으로 코드를 생성하여 실제 차량에 적용합니다.
이와 같은 MBD 접근법은 특히 복잡한 시스템을 개발할 때 매우 유용합니다. MATLAB과 Simulink를 활용한 MBD는 시스템의 요구사항부터 설계, 검증, 코드 생성, 실시간 테스트까지의 전체 개발 프로세스를 지원합니다.
모델 기반 설계 - MATLAB & Simulink (mathworks.com)
모델 기반 설계
모델 기반 설계는 임베디드 시스템을 개발하는 효율적이고 경제적인 방법입니다.
kr.mathworks.com
자 그러면 그건 그렇고 내가 쓰려고 하는건 뭐냐!!!
바로 Moveit2를 활용하는게 아니라
시뮬링크로 로봇팔 궤적계획을 설계하는겁니다.
결국 matrix하는건 똑같아용
로봇 팔의 궤적 계획
"로봇 개발자가 직접 구현하는데 어려움을 느낄 수 있는 아래와 같은 알고리즘들을 Robotics System Toolbox와 Navigation Toolbox를 이용하여 손쉽게 구현하는 방법에 대해 소개합니다. - 로봇 팔의 정/역
kr.mathworks.com
그중에서 매트랩 RRT 최적 경로계획 알고리즘을 사용합니다.

아니 근데 주인장아 Matlab을 사용하려는 이유는 뭐냐??
라고 물으신다면!!
Matlab과 simulink는 첨단제어 경로계획알고리즘에 사용되고
물체를 쥐거나 들어올리는 동작과 같은 작업순서는 stateflow로 설계하게 된다면,
안정적인 SW설계와 시간 단축을 이뤄낼수 있습니다 ㅎㅎ
HIL : hardware in the loop 도 편하고
테스트용 코드를 자동 생성하고 이렇게 생성된코드는 실시간 운전도 가능하니
모델기반 설계를 통해 복잡한 기능 실행에 걸리는 시간을 대폭 불일수 있습니다.
자동 코드 생성을 통해 수작업 코딩으로 인한 에러 발생 가능성을 제거함으로써
개발팀은 복잡한 시스템 설계에 집중할 수 있습니다.
어때요??

How can I model and simulate robots and sensors?
How can I discover and design autonomous algorithms?
How can I test and deploy robotics applications?
"어떻게 로봇을 모델링해서 시뮬레이션할 수 있을까?"
어떻게로봇을 알고리즘 설계할까
"어떻게 통합 테스트를 하고, 하드웨어에 배포할 수 있을까?"
매트랩 충실도
Simscape 제품과 같은 물리 모델링 툴은 바디나 조인트 같은 물리적 부품뿐 아니라
Kinematics model 이용해서 자율성높은 설계도가능하다는 점.
안쓸 이유가 없죠 없어

로보틱스 및 자율 시스템 개발 동향 및 솔루션
MathWorks 제품의 고객 사용 사례를 포함, 로보틱스 시스템 및 응용 프로그램 개발 동향을 소개합니다. 새로운 로보틱스 플랫폼 설계부터 로봇을 위한 자율 기술 개발에 이르기까지 복잡한 자율 로
kr.mathworks.com
elephant robotics
mycobot320 m5 배포 자료
https://github.com/elephantrobotics/mycobot_ros
GitHub - elephantrobotics/mycobot_ros: A ros package for myCobot.
A ros package for myCobot. Contribute to elephantrobotics/mycobot_ros development by creating an account on GitHub.
github.com
https://www.elephantrobotics.com/en/support-en/
RoboFlow - Elephant Robotics
Technical Support Latest software installation package and technical documents Handbook and Brochure Video Tutorials FAQ Handbook and Brochure Download Handbook myPalletizer-260-M5 myPalletizer-260-Pi MechArm M5 MechArm pi myCobot280-M5 myCobot280-Pi myCob
www.elephantrobotics.com
https://docs.elephantrobotics.com/docs/mycobot-320-m5-en/7-ApplicationBasePython/7.10_drag.html
9 Drag to teach · GitBook
Trajectory recording (including adaptive gripper) and playback can be realized. Python version drag and teach only supports Pi and Jetson Nano versions in 280, 270, and 320 models.
docs.elephantrobotics.com
1 Slider Control
Open a command line and run:
- 2022 mycobot 320-M5 version:
-
# The default serial port name of 2022 mycobot 320-M5 version is "/dev/ttyUSB0", and the baud rate is 115200. The serial port name of some models is "dev/ttyACM0". If the default serial port name is wrong, you can change the serial port name to "/dev/ttyACM0". roslaunch new_mycobot_320 mycobot_320_slider.launch port:=/dev/ttyUSB0 baud:=115200
- 2022 mycobot 320-M5 version:
-
roslaunch new_mycobot_320 mycobot_320_follow_display.launch
-
# The default serial port name of 2022 mycobot 320-M5 version is "/dev/ttyUSB0", and the baud rate is 115200. The serial port name of some models is "dev/ttyACM0". If the default serial port name is wrong, you can change the serial port name to "/dev/ttyACM0". roslaunch new_mycobot_320 mycobot_320_simple_gui.launch port:=/dev/ttyUSB0 baud:=115200
Using MyCobot
- 2022 mycobot 320-M5 version:
roslaunch new_mycobot_320_moveit mycobot320_moveit.launch
- 2022 mycobot 320-M5 version:
# The default serial port name of 2022 mycobot 320-M5 version is "/dev/ttyUSB0", and the baud rate is 115200. The serial port name of some models is "dev/ttyACM0". If the default serial port name is wrong, you can change the serial port name to "/dev/ttyACM0". rosrun new_mycobot_320_moveit sync_plan.py _port:=/dev/ttyUSB0 _baud:=115200
Modify motion speed
In order to prevent the joints from shaking during the movement of the real robotic arm, the movement speed of the joints needs to be reduced.- In the sync_plan.py file, modify the speed parameter of the robot arm Python API, here it is changed to 25.
- .
- In the Moveit RViz interface, modify the scaling ratio of speed and acceleration. Here, change it to 0.5, and then save the current configuration.
여기서 해결중
https://github.com/Tiryoh/mycobot_ros
GitHub - Tiryoh/mycobot_ros: 🦾 unofficial myCobot ROS package
🦾 unofficial myCobot ROS package. Contribute to Tiryoh/mycobot_ros development by creating an account on GitHub.
github.com
moveit 안에 fake controller 라는게 있음.
자세한건 나중에!
위에는 먼저 gazebo환경에서 mycobot을 돌려보는겁니다.
비교를 위한 셋업이라고 할 수 있습니다!
반면 아래는 Matlab수업 들은거 캡쳐
RRT => RRT* => Bi-directional RRT*(양방향 RRT* 알고리즘)
궤적 추종을 위한 로봇 팔 제어기 설계
"계획된 궤적을 추종하는 제어기를 설계하는 방법에 대해 다룹니다. - 액츄에이터 제어를 위한 PID 제어기 설계 - Stateflow를 이용한 모션 제어기 - Nonlinear MPC를 이용한 충돌 회피 가능한 최적 궤적
kr.mathworks.com
강화학습까지 추가해서 제작 과정을 설명함
지금은 이렇게 러프하게 포스팅 하지만
점차 Deep해질수 있게 꾸준히 포기하지 않고
포스팅 해보겠습니다!!