Giter Club home page Giter Club logo

cybergear_m5's Introduction

cybergear_m5

M5 stack library for cybergear

"Remember, with great torque comes great responsibility."

Supported framework

  • Arduino for ESP32

Supported device (ESP32)

  • M5Stack Basic V2.7

H/W Components (MCP2515)

image

H/W Components (ESP32 + CAN Transceiver Unit)

How to use Official GUI tool

This software requires a specific CAN to USB module. The official documentation recommends YourCee's USB to CAN module, which supports the serial protocol with a frame header of 41 54 and frame tail of 0D 0A, but this is not readily available, so we searched Aliexpress for an alternative. ※ Note that this will not work for general modules.

Tested(for reference):

Recommended pre-crimped cables

How to run sample

Arduino IDE

  1. Clone MCP_CAN_LIB and cygergear_m5 to Arduino Library directory.
cd ~/Arduino/libraries
git clone https://github.com/coryjfowler/MCP_CAN_lib.git
git clone https://github.com/Locoduino/RingBuffer.git
git clone [email protected]:project-sternbergia/arduino-CAN.git
git clone https://github.com/project-sternbergia/cybergear_m5.git
  1. Open cybergear_m5/examples/control_mode_example.ino with Arduino IDE

    image

    Put this file in the same folder as control_mode_example.ino (for Arduino IDE)

  2. Build and write firmware to M5Stack

Sample Code

control_mode_example.ino

Check cybergear behaviour using M5 stack.

  • Middle Button - Change Control Mode (Position Mode -> Speed Mode -> Current Mode)
  • Right Button - Increase control value
  • Left Button - Decrease control value

CyberGear_M5_Control_Mode

cybergear_bilateral.ino

This example use two cybergears for leader and follower. Before you test this example, please change cybergear can id as follows. After that write cybergear_m5/examples/cybergear_bilateral.ino to m5 stack throughout Arduino IDE.

  • leader cybergear : 0x7F
  • follower cybergear : 0x7E

CyberGear_Bilateral

References

LICENSE

MIT

cybergear_m5's People

Contributors

chikuta avatar plastic-gear avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cybergear_m5's Issues

always restart

Now I am using M5stack Basic V2.6. The communication uses the mcp2515 module. It keeps restarting after booting. What is the reason?

The log printed by the serial port is as follows:
`
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
M5Stack initializing...
OK
Entering Configuration Mode Failure...
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump:
PC : 0x400dad0a PS : 0x00060430 A0 : 0x800d2d2b A1 : 0x3ffb2120
A2 : 0xffffffff A3 : 0x00000000 A4 : 0x98968000 A5 : 0x00000001
A6 : 0xffffffff A7 : 0x00000000 A8 : 0x000000ff A9 : 0x00040000
A10 : 0x00000007 A11 : 0xff000000 A12 : 0x00000015 A13 : 0x00000000
A14 : 0x00060420 A15 : 0x00000001 SAR : 0x0000000b EXCCAUSE: 0x0000001c
EXCVADDR: 0x98968004 LBEG : 0x40084929 LEND : 0x40084931 LCOUNT : 0x00000027

Backtrace: 0x400dad07:0x3ffb2120 0x400d2d28:0x3ffb2140 0x400d21a6:0x3ffb2160 0x400d2945:0x3ffb2190 0x400d2a8a:0x3ffb21b0 0x400d2ac5:0x3ffb21d0 0x400d8f82:0x3ffb21f0 0x400d9074:0x3ffb2220 0x400d1dac:0x3ffb2240 0x400dbea9:0x3ffb2290

ELF file SHA256: d19d29a71b289377
`

[Bug] Speed control via bridge is not functioning properly

Describe the bug

When I sent commands from ROS 2 to control the speed, it became apparent that the motor was not behaving correctly. The motor would rotate slightly only when the speed was altered, but when the same speed value was applied, the motor would only oscillate and not rotate.

To reproduce

  1. Using this repository, write a bridge for ROS communication to M5Stack.
  2. Build this repository into the ROS environment and send speed commands to the motor for speed control.

To resolve

There is a bug in cybergear_bridge.cpp. Originally, send_speed_command should be used to send speed commands, but send_current_command is used, and current values are being sent. Therefore, send_current_command should be replaced with send_speed_command.

System Info

  • M5Stack Gray
  • CyberGear
  • PC (Ubuntu 22.04, ROS 2 Humble)

Feature request: MOVE_JOG support

Guess from decoding the protocol:

1rad/s
ID=0x1200fd7f data=[05, 70, 00, 00, 07, 01, 84, 43]
    pub async fn move_jog_stop(&mut self, motor_id: u8) -> Status {
        self.send_raw_mesage(
            motor_id,
            protocol::WRITE_PARAM,
            &[0x05, 0x70, 0x00, 0x00, 0x07, 0x00, 0x7f, 0xff],
        );

        self.receive_response().await
    }

    /// speed: -30 to 30, rad/s
    pub async fn move_jog(&mut self, motor_id: u8, speed: f32, clockwise: bool) -> Status {
        if speed < 0.05 {
            return self.move_jog_stop(motor_id).await;
        }
        let speed = if clockwise { speed } else { -speed };
        let speed = map_f32_to_u16(speed, -30.0, 30.0);

        let mut data = [0u8; 8];

        // UNDOCUMENTED, guess from reverse engineering
        data[0..2].copy_from_slice(&u16::to_le_bytes(params::RUN_MODE));
        data[4] = 0x07;
        data[5] = 1;
        data[6..8].copy_from_slice(&u16::to_be_bytes(speed));

        self.send_raw_mesage(motor_id, protocol::WRITE_PARAM, &data);

        self.receive_response().await
    }

Error with new CAN communication

Ignore the name of my .ino file in the picture below, it is act
ually just the bilateral control example.

I am encountering an error with two methods used in cybergear_can_interface_esp32.cpp, where CAN.packetTxId() and CAN.packet_RxId() do not exist. It asks if it's being mistaken for 'packetId'

error_from_text_image

I have all of my files up to date, and tried both the arduino-CAN library that Chikuta forked, and Sandeep Mistry's version (both are the same though).

Is this somehow just user error on my part?

Here is the full output if needed.
error.txt

Mutli motor control and status reading

I am attempting to control 6 motors and read their status. I used the cybergear_bilateral.ino for help and expanded the code for 6 motor IDs, they are simply changing velocity (not follow).

My issue is a set number of motors always return null values, when I check their ID its reads 0x28 (not what I assigned).
The motors which behave like this are predictable in a order;
when controlling 6 motors, the 3rd, 4th, 5th return null,
when controlling 5 motors, the 3rd, 4th return null,
when controlling 4 motors, the 3rd, return null, in order of IDs in the vector.
Its never the first few or the last.

Can this be a issue with the library? Have you ever tested with more than 2 motors?

M5STACK.h not found

I imported the four libraries. When I try running the example code, I get this error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.