How a smart electric bike was created

How a smart electric bike was created
Habré often writes about electric transport. And about bikes. And also about AI. Cloud4Y decided to combine these three topics by talking about a "smart" e-bike that is always online. We are talking about the model Greyp G6.

To make it more interesting for you, we have divided the article into two parts. The first is devoted to the process of creating a device, platform and communication protocols. The second is the technical specifications, a description of the filling and capabilities of the bike.

Part one, backend

Greyp Bikes is a Croatian premium electric bike manufacturer owned by local exotic supercar manufacturer Rimac. The company creates really interesting bikes. What is only the previous model, G12S double suspension. It was something between an electric bike and an electric motorcycle, since the device could accelerate to 70 km / h, had a powerful motor and ran 120 km on a single charge.

G6 turned out to be more elegant and off-road, but its main feature is “connectivity”. Greyp Bikes made an important step towards the development of IoT by offering a bike that is always “on the network”. But let's talk first about how a "smart" electric bike was created in general.

Birth of an idea

A wide variety of devices are connected to the Internet. What's wrong with bicycles? So Greyp Bikes came up with the idea that became the G6. At any given time, this bike maintains a connection with cloud server. The mobile operator provides communication, and the eSIM is sewn directly into the bike. And this opens up a lot of interesting opportunities for both athletes and ordinary cyclists.

Platform

When creating a platform for an innovative product, there are many nuances to consider. Therefore, the choice of a cloud platform to host and run all the services required by a modern e-bike was a very important issue. The company opted for Amazon Web Services (AWS). This was partly due to the fact that Greyp Bikes already had experience with the service. Partly because of its popularity, wide adoption among developers around the world and good attitude towards Java / JVM (yes, they are actively used in Greyp Bikes).

AWS had a good IoT MQTT broker (Cloud4Y wrote about protocols earlier), ideal for easy data exchange with the bike. True, it was necessary to somehow establish a connection with the smartphone application. There were attempts to implement this on their own using Websockets, but later the company decided not to reinvent the wheel and switched to the Google Firebase platform, which is widely used by mobile developers. Since the beginning of development, the system architecture has undergone many improvements and changes. This is how it looks like now:

How a smart electric bike was created
tech stack

implementation

The company has provided two ways to log in. Each of them is implemented separately, with different technologies for their use case.

From bike to smartphone

The first thing to consider when creating a system entry point is which communication protocol to use. As already mentioned, the company chose MQTT because of its light "nature". The protocol is good in terms of throughput, works great with potentially unreliable connections, saves battery power, which is especially important for Greyp's e-bike.

The MQTT broker used is required to download all the data coming from the bike. Inside the AWS network is Lambda, which reads the binary data provided by the MQTT broker, parses it, and delivers it to Apache Kafka for further processing.

Apache Kafka is the backbone of the system. All data must pass through it to reach the final destination. At present, the core of the system has several agents. The most important of these is the one that collects the data and transfers it to the "cold storage" of InfluxDB. The other one transfers the data to the Firebase Realtime database, making it available to smartphone applications. This is where Apache Kafka really comes in - cold storage (InfluxDB) saves all the data it gets from the bike and Firebase can get up-to-date information (like real-time metrics - current speed).

Kafka allows you to receive messages at different speeds and deliver them almost immediately to Firebase (for display in an application on a smartphone) and eventually transfer them to InfluxDB (for data analysis, statistics, monitoring).

Using Kafka also allows you to scale out with increasing load, as well as connect other agents that can process incoming data at their own pace and for their own use case (for example, in a competition between a group of bicycles). That is, the solution allows cyclists to compete with each other on a variety of characteristics. For example, maximum speed, maximum jump, maximum performance, etc.

All services (called "GVC" - Greyp Vehicle Cloud) are primarily implemented in Spring Boot and Java, although other languages ​​are also used. Each build is packaged in a Docker image hosted in an ECR repository and run and hosted by Amazon ECS. While NoSQL is quite convenient and popular for a number of uses, Firebase can't always meet all of Greyp's needs, and so the company also uses MySQL (in RDS) for ad hoc queries (Firebase uses a JSON tree, which is more efficient in some cases) and specific data storage. Another storage used is Amazon S3, which ensures the security of the collected data.

From smartphone to bike

As we have already said, communication with smartphones is established through Firebase. The platform is used to authenticate the users of the application and their piece of the database in real time. In fact, Firebase is a combination of two things: one is a database for persistent data storage, and the other is for delivering real-time data to smartphones via a Websocket connection. The ideal option for this type of connection is to issue commands to the bike when the devices are not close to each other (no BT/Wi-Fi connection available).

In this case, Greyp has developed its own command processing engine that receives messages from the smartphone through the database in real-time mode. This mechanism is part of the Core Application Services (GVC), whose task is to convert smartphone commands into MQTT messages transmitted to the bike through the IoT broker. When the bike receives a command, it processes it, performs the appropriate action, and returns a response to Firebase (smartphone).

Monitoring

How a smart electric bike was created
Parameter control

Pretty much every backend developer likes to sleep at night without checking servers every 10 minutes. And this means that you need to implement automated monitoring and alerting solutions in the system. This rule also applies to the Greyp cycling ecosystem. There are also connoisseurs of a normal night's sleep, so the company uses two cloud solutions: Amazon CloudWatch and jmxtrans.

CloudWatch is a monitoring and observation service that collects monitoring and operational data in the form of logs, metrics, and events to help you gain a unified view of AWS applications, services, and resources running on the AWS platform as well as on-premises. CloudWatch makes it easy to detect anomalous behavior in your environments, set up alerts, create shared visualizations of logs and metrics, perform automated actions, troubleshoot issues, and learn insights that help keep your applications running smoothly.

CloudWatch collects user metrics and delivers them to the dashboard. There, they are combined with data from other Amazon-managed resources. The JVM receives metrics through a JMX endpoint using a "connector" called jmxtrans (also hosted as a Docker container inside ECS).

Part two, characteristics

How a smart electric bike was created

So what did the electric bike turn out to be? The Greyp G6 electric mountain bike is equipped with a 36V, 700 Wh lithium-ion battery powered by LG cells. Instead of hiding the battery like many e-bike manufacturers do, Greyp placed the removable battery right in the center of the frame. The G6 is equipped with an MPF ​​motor rated at 250W (and there is also a 450W option).

The Greyp G6 is a mountain bike equipped with a Rockhox rear suspension tucked in close to the top tube and leaving plenty of room for a removable battery between the rider's knees. The frame is enduro style and offers 150mm of travel thanks to the suspension. The cable and brake lines are passed inside the frame. This ensures an aesthetic appearance and reduces the risk of catching on branches.

The 100% carbon fiber frame was custom-designed at Greyp using the experience gained during the creation of the Concept One electric hypercar.

The electronics suite on the Greyp G6 is controlled by a central intelligence module (CIM) on the stem. It includes a color display, WiFi, Bluetooth, 4G connectivity, a gyroscope, a USB C connector, a front-facing camera, as well as an under-seat rear camera interface. By the way, rear camera Surrounded by 4 LEDs. Wide-angle cameras (1080p 30 fps) are primarily designed for shooting video while traveling.

Photo examplesHow a smart electric bike was created

How a smart electric bike was created

How a smart electric bike was created

The company pays special attention to the eSTEM solution.

“Greyp eSTEM is a bicycle central intelligence module that controls two cameras (front and rear), monitors the rider’s heart rate, has a built-in gyroscope, navigation system and eSIM, which allows you to connect it at any time. The e-bike system uses the smartphone as the user interface, and the mobile app creates a unique user experience with various new options such as remote bike switch, photo capture, text to bike, and power limit.”

There is a special “Share” button on the bike handlebars. If something interesting or exciting happens during the ride, you can press a button and automatically save the last 15-30 seconds of the video by uploading it to the cyclist's social media account. Additional data may also be overlaid on the video. For example, the energy consumption of a bicycle, speed, travel time, etc.

With the phone mounted on the bike in dashboard mode, the Greyp G6 can provide a wealth of information, not just the current speed or battery level. So, a cyclist can choose any point on the map (for example, a high hill), and the computer will calculate whether the battery is enough to get to the top. Or calculate the point of no return, if suddenly you do not want to pedal on the way back. Although the pedals are quite possible and twist. The manufacturer claims that the bike is not heavy (although this is how you look, its weight is 25 kg).

How a smart electric bike was created
Greyp G6 is quite possible to lift

Greyp G6 has an anti-theft system that is similar to Sentry mode from Tesla. That is, if you touch a parked bike, it will notify the owner about this and give him access to the camera to find out who is spinning around the electric bike. The rider can then choose to disable the bike remotely to prevent the intruder from driving away. And given that these systems have been in development at Greyp for years, it's likely that they actually came up with this system before Tesla implemented it.

There are several models of this series on sale: G6.1, G6.2, G6.3. G6.1 accelerates to 25 km/h (15,5 mph) and costs 6 euros. The G499 has a top speed of 6.3 km/h (45 mph) and costs €28. What makes the G7 different is unclear, but it costs 499 euros.

What else can you read on the blog? Cloud4Y

The path of artificial intelligence from a fantastic idea to a scientific industry
4 ways to save on cloud backups
Configuring top in GNU/Linux
Summer is almost over. There is almost no unleaked data left
IoT, fog and clouds: let's talk about technology?

Subscribe to our Telegram-channel, so as not to miss the next article! We write no more than twice a week and only on business.

Source: habr.com

Add a comment